Просмотр исходного кода

feat(create): Ship Vendure CLI with new projects

Michael Bromley 1 год назад
Родитель
Сommit
faf69a926a

+ 2 - 7
packages/create/src/create-vendure-app.ts

@@ -105,7 +105,6 @@ export async function createVendureApp(
         envDtsSource,
         indexSource,
         indexWorkerSource,
-        migrationSource,
         readmeSource,
         dockerfileSource,
         dockerComposeSource,
@@ -131,9 +130,6 @@ export async function createVendureApp(
             'start:server': 'node ./dist/index.js',
             'start:worker': 'node ./dist/index-worker.js',
             start: packageManager === 'yarn' ? 'concurrently yarn:start:*' : 'concurrently npm:start:*',
-            'migration:generate': 'ts-node migration generate',
-            'migration:run': 'ts-node migration run',
-            'migration:revert': 'ts-node migration revert',
         },
     };
 
@@ -186,7 +182,6 @@ export async function createVendureApp(
             .then(() => fs.writeFile(srcPathScript('environment.d'), envDtsSource))
             .then(() => fs.writeFile(srcPathScript('index'), indexSource))
             .then(() => fs.writeFile(srcPathScript('index-worker'), indexWorkerSource))
-            .then(() => fs.writeFile(rootPathScript('migration'), migrationSource))
             .then(() => fs.writeFile(path.join(root, 'README.md'), readmeSource))
             .then(() => fs.writeFile(path.join(root, 'Dockerfile'), dockerfileSource))
             .then(() => fs.writeFile(path.join(root, 'docker-compose.yml'), dockerComposeSource))
@@ -221,8 +216,8 @@ export async function createVendureApp(
             logLevel === 'silent'
                 ? LogLevel.Error
                 : logLevel === 'verbose'
-                ? LogLevel.Verbose
-                : LogLevel.Info;
+                  ? LogLevel.Verbose
+                  : LogLevel.Info;
 
         const bootstrapFn = async () => {
             await checkDbConnection(config.dbConnectionOptions, root);

+ 0 - 1
packages/create/src/gather-user-responses.ts

@@ -204,7 +204,6 @@ async function generateSources(
         configSource: await createSourceFile('vendure-config.hbs', true),
         envSource: await createSourceFile('.env.hbs', true),
         envDtsSource: await createSourceFile('environment.d.hbs', true),
-        migrationSource: await createSourceFile('migration.hbs'),
         readmeSource: await createSourceFile('readme.hbs'),
         dockerfileSource: await createSourceFile('Dockerfile.hbs'),
         dockerComposeSource: await createSourceFile('docker-compose.hbs'),

+ 1 - 1
packages/create/src/helpers.ts

@@ -265,7 +265,7 @@ export function getDependencies(
         dbDriverPackage(dbType),
         `typescript@${TYPESCRIPT_VERSION}`,
     ];
-    const devDependencies = ['concurrently', 'ts-node'];
+    const devDependencies = ['concurrently', `@vendure/cli${vendurePkgVersion}`];
     return { dependencies, devDependencies };
 }
 

+ 0 - 1
packages/create/src/types.ts

@@ -6,7 +6,6 @@ export interface FileSources {
     configSource: string;
     envSource: string;
     envDtsSource: string;
-    migrationSource: string;
     readmeSource: string;
     dockerfileSource: string;
     dockerComposeSource: string;

+ 0 - 27
packages/create/templates/migration.hbs

@@ -1,27 +0,0 @@
-import { generateMigration, revertLastMigration, runMigrations } from '@vendure/core';
-import program from 'commander';
-
-import { config } from './src/vendure-config';
-
-program
-    .command('generate <name>')
-    .description('Generate a new migration file with the given name')
-    .action(name => {
-        return generateMigration(config, { name, outputDir: './src/migrations' });
-    });
-
-program
-    .command('run')
-    .description('Run all pending migrations')
-    .action(() => {
-        return runMigrations(config);
-    });
-
-program
-    .command('revert')
-    .description('Revert the last applied migration')
-    .action(() => {
-        return revertLastMigration(config);
-    });
-
-program.parse(process.argv);

+ 11 - 13
packages/create/templates/readme.hbs

@@ -89,15 +89,23 @@ database may be orchestrated with Docker Compose.
 In Vendure, your custom functionality will live in [plugins](https://www.vendure.io/docs/plugins/).
 These should be located in the `./src/plugins` directory.
 
+To create a new plugin run:
+
+```
+{{#if useYarn}}yarn{{else}}npx{{/if}} vendure add
+```
+
+and select `[Plugin] Create a new Vendure plugin`.
+
 ## Migrations
 
 [Migrations](https://www.vendure.io/docs/developer-guide/migrations/) allow safe updates to the database schema. Migrations
 will be required whenever you make changes to the `customFields` config or define new entities in a plugin.
 
-The following npm scripts can be used to generate migrations:
+To generate a new migration, run:
 
 ```
-{{#if useYarn}}yarn{{else}}npm run{{/if}} migration:generate [name]
+{{#if useYarn}}yarn{{else}}npx{{/if}} vendure migrate
 ```
 
 The generated migration file will be found in the `./src/migrations/` directory, and should be committed to source control.
@@ -111,14 +119,4 @@ data that you cannot lose.
 
 ---
 
-You can also run any pending migrations manually, without starting the server by running:
-
-```
-{{#if useYarn}}yarn{{else}}npm run{{/if}} migration:run
-```
-
-You can revert the most recently-applied migration with:
-
-```
-{{#if useYarn}}yarn{{else}}npm run{{/if}} migration:revert
-```
+You can also run any pending migrations manually, without starting the server via the "vendure migrate" command.