Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Add option for skipping Git working tree check #38

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ To bypass the prompts use one of the following commands:
yarn @strapi/codemods migrate:application <path>
```

💡 If you want to skip the Git working tree check, run the command with the `--skip-working-tree-check` argument. This is especially useful for monorepos where Strapi doesn't have its own `.git` directory.

```bash
yarn @strapi/codemods migrate:application <path> --skip-working-tree-check
```

- `Plugin` migration

```bash
Expand Down
9 changes: 7 additions & 2 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,14 @@ program
// `$ strapi-codemods migrate:application`
program
.command('migrate:application [path]')
.option(
"--skip-working-tree-check",
"Skip checking whether the Git working tree is clean. Especially useful for monorepos.",
undefined
)
.description('Migrate a v3 Strapi application to v4')
.action(async (path) => {
await migrate('application', path);
.action(async (path, options) => {
await migrate('application', path, undefined, options);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my other comment, then here: {type: 'application', path, cliOptions: options}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and you will have to make the update anywhere else migrate is called

});

// `$ strapi-codemods migrate:plugin`
Expand Down
10 changes: 6 additions & 4 deletions bin/commands/migrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const { migratePlugin, migrateApiFolder, migrateDependencies, migrateApplication
// Global utils
const { isPathStrapiApp, logger, isCleanGitRepo, promptUser } = require('../../lib/global/utils');

const migrate = async (type, path, pathForV4Plugin) => {
const migrate = async (type, path, pathForV4Plugin, cliOptions) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should change this to accept an object {type, path, pathForV4Plugin, cliOptions}

// Check the path exists
const exists = await fs.pathExists(resolve(path));
if (!exists) {
Expand All @@ -24,7 +24,7 @@ const migrate = async (type, path, pathForV4Plugin) => {
try {
switch (type) {
case 'application':
await migrateApplicationToV4(path);
await migrateApplicationToV4(path, cliOptions);
break;
case 'dependencies':
await migrateDependenciesToV4(path);
Expand All @@ -40,7 +40,7 @@ const migrate = async (type, path, pathForV4Plugin) => {
};

// `strapi-codemods migrate:application`
const migrateApplicationToV4 = async (path) => {
const migrateApplicationToV4 = async (path, cliOptions) => {
const promptOptions = {
type: 'input',
name: 'path',
Expand All @@ -51,7 +51,9 @@ const migrateApplicationToV4 = async (path) => {
const options = await promptUser(promptOptions);
const projectPath = path || options.path;

await isCleanGitRepo(projectPath);
if (!cliOptions.skipWorkingTreeCheck) {
await isCleanGitRepo(projectPath);
}
await isPathStrapiApp(projectPath);
await migrateDependencies(projectPath);
await migrateApplicationFolderStructure(projectPath);
Expand Down