1
0
Эх сурвалжийг харах

chore(create): Update dependencies, use picocolors

Michael Bromley 2 жил өмнө
parent
commit
500afdd7b1

+ 5 - 4
packages/create/package.json

@@ -11,6 +11,7 @@
     "assets/**/*"
   ],
   "scripts": {
+    "dev": "ts-node src/create-vendure-app.ts",
     "copy-assets": "rimraf assets && ts-node ./build.ts",
     "build": "yarn copy-assets && rimraf lib && tsc -p ./tsconfig.build.json",
     "watch": "yarn copy-assets && rimraf lib && tsc -p ./tsconfig.build.json -w",
@@ -35,13 +36,13 @@
   },
   "dependencies": {
     "@vendure/common": "^2.0.0-next.28",
-    "chalk": "^4.1.0",
-    "commander": "^7.1.0",
+    "commander": "^10.0.0",
     "cross-spawn": "^7.0.3",
-    "detect-port": "^1.3.0",
-    "fs-extra": "^10.0.0",
+    "detect-port": "^1.5.1",
+    "fs-extra": "^11.1.1",
     "handlebars": "^4.7.6",
     "listr": "^0.14.3",
+    "picocolors": "^1.0.0",
     "prompts": "^2.3.2",
     "rxjs": "^7.5.4",
     "semver": "^7.3.2",

+ 16 - 16
packages/create/src/create-vendure-app.ts

@@ -1,11 +1,11 @@
 /* eslint-disable no-console */
-import chalk from 'chalk';
-import program from 'commander';
+import { program } from 'commander';
 import detectPort from 'detect-port';
 import fs from 'fs-extra';
 import Listr from 'listr';
 import os from 'os';
 import path from 'path';
+import pc from 'picocolors';
 import { Observable } from 'rxjs';
 
 import { REQUIRED_NODE_VERSION, SERVER_PORT } from './constants';
@@ -38,7 +38,7 @@ process.env[createEnvVar] = 'true';
 program
     .version(packageJson.version)
     .arguments('<project-directory>')
-    .usage(`${chalk.green('<project-directory>')} [options]`)
+    .usage(`${pc.green('<project-directory>')} [options]`)
     .action(name => {
         projectName = name;
     })
@@ -53,9 +53,9 @@ program
     .parse(process.argv);
 
 const options = program.opts();
-void createApp(projectName, options.useNpm, options.logLevel || 'silent', options.ci);
+void createVendureApp(projectName, options.useNpm, options.logLevel || 'silent', options.ci);
 
-async function createApp(
+export async function createVendureApp(
     name: string | undefined,
     useNpm: boolean,
     logLevel: CliLogLevel,
@@ -65,11 +65,11 @@ async function createApp(
         return;
     }
     if (await isServerPortInUse()) {
-        console.log(chalk.red(`Port ${SERVER_PORT} is in use. Please make it available and then re-try.`));
+        console.log(pc.red(`Port ${SERVER_PORT} is in use. Please make it available and then re-try.`));
         process.exit(1);
     }
 
-    console.log(chalk.cyan(`Welcome to @vendure/create v${packageJson.version as string}!`));
+    console.log(pc.cyan(`Welcome to @vendure/create v${packageJson.version as string}!`));
     console.log();
     console.log("Let's configure a new Vendure project. First a few questions:");
     console.log();
@@ -80,7 +80,7 @@ async function createApp(
     const useYarn = useNpm ? false : shouldUseYarn();
     if (scaffoldExists) {
         console.log(
-            chalk.green(
+            pc.green(
                 'It appears that a new Vendure project scaffold already exists. Re-using the existing files...',
             ),
         );
@@ -126,7 +126,7 @@ async function createApp(
     };
 
     console.log();
-    console.log(`Setting up your new Vendure project in ${chalk.green(root)}`);
+    console.log(`Setting up your new Vendure project in ${pc.green(root)}`);
     console.log('This may take a few minutes...');
     console.log();
 
@@ -281,7 +281,7 @@ async function createApp(
                 }
             } catch (e: any) {
                 console.log();
-                console.error(chalk.red(e.message));
+                console.error(pc.red(e.message));
                 console.log();
                 console.log(e);
                 throw e;
@@ -298,12 +298,12 @@ async function createApp(
     }
     const startCommand = useYarn ? 'yarn dev' : 'npm run dev';
     console.log();
-    console.log(chalk.green(`Success! Created a new Vendure server at ${root}`));
+    console.log(pc.green(`Success! Created a new Vendure server at ${root}`));
     console.log();
     console.log('We suggest that you start by typing:');
     console.log();
-    console.log(chalk.green(`    cd ${name}`));
-    console.log(chalk.green(`    ${startCommand}`));
+    console.log(pc.green(`    cd ${name}`));
+    console.log(pc.green(`    ${startCommand}`));
     console.log();
     console.log('Happy hacking!');
     process.exit(0);
@@ -316,10 +316,10 @@ async function createApp(
 function runPreChecks(name: string | undefined, useNpm: boolean): name is string {
     if (typeof name === 'undefined') {
         console.error('Please specify the project directory:');
-        console.log(`  ${chalk.cyan(program.name())} ${chalk.green('<project-directory>')}`);
+        console.log(`  ${pc.cyan(program.name())} ${pc.green('<project-directory>')}`);
         console.log();
         console.log('For example:');
-        console.log(`  ${chalk.cyan(program.name())} ${chalk.green('my-vendure-app')}`);
+        console.log(`  ${pc.cyan(program.name())} ${pc.green('my-vendure-app')}`);
         process.exit(1);
         return false;
     }
@@ -348,6 +348,6 @@ async function copyEmailTemplates(root: string) {
     try {
         await fs.copy(templateDir, path.join(root, 'static', 'email', 'templates'));
     } catch (err: any) {
-        console.error(chalk.red('Failed to copy email templates.'));
+        console.error(pc.red('Failed to copy email templates.'));
     }
 }

+ 13 - 15
packages/create/src/helpers.ts

@@ -1,9 +1,9 @@
 /* eslint-disable no-console */
-import chalk from 'chalk';
 import { execSync } from 'child_process';
 import spawn from 'cross-spawn';
 import fs from 'fs-extra';
 import path from 'path';
+import pc from 'picocolors';
 import semver from 'semver';
 
 import { SERVER_PORT, TYPESCRIPT_VERSION } from './constants';
@@ -57,7 +57,7 @@ export function isSafeToCreateProjectIn(root: string, name: string) {
         .filter(file => !errorLogFilePatterns.some(pattern => file.indexOf(pattern) === 0));
 
     if (conflicts.length > 0) {
-        console.log(`The directory ${chalk.green(name)} contains files that could conflict:`);
+        console.log(`The directory ${pc.green(name)} contains files that could conflict:`);
         console.log();
         for (const file of conflicts) {
             console.log(`  ${file}`);
@@ -90,7 +90,7 @@ export function scaffoldAlreadyExists(root: string, name: string): boolean {
 export function checkNodeVersion(requiredVersion: string) {
     if (!semver.satisfies(process.version, requiredVersion)) {
         console.error(
-            chalk.red(
+            pc.red(
                 'You are running Node %s.\n' +
                     'Vendure requires Node %s or higher. \n' +
                     'Please update your version of Node.',
@@ -145,24 +145,22 @@ export function checkThatNpmCanReadCwd() {
         return true;
     }
     console.error(
-        chalk.red(
+        pc.red(
             'Could not start an npm process in the right directory.\n\n' +
-                `The current directory is: ${chalk.bold(cwd)}\n` +
-                `However, a newly started npm process runs in: ${chalk.bold(npmCWD)}\n\n` +
+                `The current directory is: ${pc.bold(cwd)}\n` +
+                `However, a newly started npm process runs in: ${pc.bold(npmCWD)}\n\n` +
                 'This is probably caused by a misconfigured system terminal shell.',
         ),
     );
     if (process.platform === 'win32') {
         console.error(
-            chalk.red('On Windows, this can usually be fixed by running:\n\n') +
-                `  ${chalk.cyan(
-                    'reg',
-                )} delete "HKCU\\Software\\Microsoft\\Command Processor" /v AutoRun /f\n` +
-                `  ${chalk.cyan(
+            pc.red('On Windows, this can usually be fixed by running:\n\n') +
+                `  ${pc.cyan('reg')} delete "HKCU\\Software\\Microsoft\\Command Processor" /v AutoRun /f\n` +
+                `  ${pc.cyan(
                     'reg',
                 )} delete "HKLM\\Software\\Microsoft\\Command Processor" /v AutoRun /f\n\n` +
-                chalk.red('Try to run the above two lines in the terminal.\n') +
-                chalk.red(
+                pc.red('Try to run the above two lines in the terminal.\n') +
+                pc.red(
                     'To learn more about this problem, read: https://blogs.msdn.microsoft.com/oldnewthing/20071121-00/?p=24433/',
                 ),
         );
@@ -276,7 +274,7 @@ function dbDriverPackage(dbType: DbType): string {
             return 'oracledb';
         default:
             const n: never = dbType;
-            console.error(chalk.red(`No driver package configured for type "${dbType as string}"`));
+            console.error(pc.red(`No driver package configured for type "${dbType as string}"`));
             return '';
     }
 }
@@ -388,7 +386,7 @@ export function isServerPortInUse(): Promise<boolean> {
     try {
         return tcpPortUsed.check(SERVER_PORT);
     } catch (e: any) {
-        console.log(chalk.yellow(`Warning: could not determine whether port ${SERVER_PORT} is available`));
+        console.log(pc.yellow(`Warning: could not determine whether port ${SERVER_PORT} is available`));
         return Promise.resolve(false);
     }
 }

+ 47 - 14
yarn.lock

@@ -7625,7 +7625,7 @@ detect-node@^2.0.4:
   resolved "https://registry.yarnpkg.com/detect-node/-/detect-node-2.1.0.tgz#c9c70775a49c3d03bc2c06d9a73be550f978f8b1"
   integrity sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g==
 
-detect-port@^1.3.0:
+detect-port@^1.5.1:
   version "1.5.1"
   resolved "https://registry.yarnpkg.com/detect-port/-/detect-port-1.5.1.tgz#451ca9b6eaf20451acb0799b8ab40dff7718727b"
   integrity sha512-aBzdj76lueB6uUst5iAs7+0H/oOjqI5D16XUWxlWMIMROhcM0rfsNVk93zTngq1dDNpoXRr++Sus7ETAExppAQ==
@@ -9049,7 +9049,7 @@ fs-extra@^10.0.0:
     jsonfile "^6.0.1"
     universalify "^2.0.0"
 
-fs-extra@^11.0.0, fs-extra@^11.1.0:
+fs-extra@^11.0.0, fs-extra@^11.1.0, fs-extra@^11.1.1:
   version "11.1.1"
   resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-11.1.1.tgz#da69f7c39f3b002378b0954bb6ae7efdc0876e2d"
   integrity sha512-MGIE4HOvQCeUCzmlHs0vXpih4ysz4wg9qiSAu6cd42lVwPbTM1TjV7RusoyQqMmk/95gdQZX72u+YW+c3eEpFQ==
@@ -10141,12 +10141,19 @@ ieee754@^1.1.13, ieee754@^1.1.4, ieee754@^1.2.1:
   resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352"
   integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==
 
-ignore-walk@^3.0.1:
-  version "3.0.4"
-  resolved "https://registry.yarnpkg.com/ignore-walk/-/ignore-walk-3.0.4.tgz#c9a09f69b7c7b479a5d74ac1a3c0d4236d2a6335"
-  integrity sha512-PY6Ii8o1jMRA1z4F2hRkH/xN59ox43DavKvD3oDpfurRlOJyAHpifIwpbdv1n4jt4ov0jSpw3kQ4GhJnpBL6WQ==
+ignore-walk@^5.0.1:
+  version "5.0.1"
+  resolved "https://registry.yarnpkg.com/ignore-walk/-/ignore-walk-5.0.1.tgz#5f199e23e1288f518d90358d461387788a154776"
+  integrity sha512-yemi4pMf51WKT7khInJqAvsIGzoqYXblnsz0ql8tM+yi1EKYTY1evX4NAbJrLL/Aanr2HyZeluqU+Oi7MGHokw==
   dependencies:
-    minimatch "^3.0.4"
+    minimatch "^5.0.1"
+
+ignore-walk@^6.0.0:
+  version "6.0.2"
+  resolved "https://registry.yarnpkg.com/ignore-walk/-/ignore-walk-6.0.2.tgz#c48f48397cf8ef6174fcc28aa5f8c1de6203d389"
+  integrity sha512-ezmQ1Dg2b3jVZh2Dh+ar6Eu2MqNSTkyb32HU2MAQQQX9tKM3q/UQ/9lf03lQ5hW+fOeoMnwxwkleZ0xcNp0/qg==
+  dependencies:
+    minimatch "^7.4.2"
 
 ignore@5.2.4, ignore@^5.0.4, ignore@^5.2.0:
   version "5.2.4"
@@ -13310,13 +13317,20 @@ now-and-later@^2.0.0:
   dependencies:
     once "^1.3.2"
 
-npm-bundled@^1.0.1, npm-bundled@^1.1.1:
+npm-bundled@^1.1.1, npm-bundled@^1.1.2:
   version "1.1.2"
   resolved "https://registry.yarnpkg.com/npm-bundled/-/npm-bundled-1.1.2.tgz#944c78789bd739035b70baa2ca5cc32b8d860bc1"
   integrity sha512-x5DHup0SuyQcmL3s7Rx/YQ8sbw/Hzg0rj48eN0dV7hf5cmQq5PXIeioroH3raV1QC1yh3uTYuMThvEQF3iKgGQ==
   dependencies:
     npm-normalize-package-bin "^1.0.1"
 
+npm-bundled@^2.0.0:
+  version "2.0.1"
+  resolved "https://registry.yarnpkg.com/npm-bundled/-/npm-bundled-2.0.1.tgz#94113f7eb342cd7a67de1e789f896b04d2c600f4"
+  integrity sha512-gZLxXdjEzE/+mOstGDqR6b0EkhJ+kM6fxM6vUuckuctuVPh80Q6pw/rSZj9s4Gex9GxWtIicO1pc8DB9KZWudw==
+  dependencies:
+    npm-normalize-package-bin "^2.0.0"
+
 npm-bundled@^3.0.0:
   version "3.0.0"
   resolved "https://registry.yarnpkg.com/npm-bundled/-/npm-bundled-3.0.0.tgz#7e8e2f8bb26b794265028491be60321a25a39db7"
@@ -13382,13 +13396,32 @@ npm-package-arg@^9.0.0, npm-package-arg@^9.0.1:
     semver "^7.3.5"
     validate-npm-package-name "^4.0.0"
 
-npm-packlist@1.1.12, npm-packlist@5.1.1, npm-packlist@^5.1.0, npm-packlist@^7.0.0:
-  version "1.1.12"
-  resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-1.1.12.tgz#22bde2ebc12e72ca482abd67afc51eb49377243a"
-  integrity sha512-WJKFOVMeAlsU/pjXuqVdzU0WfgtIBCupkEVwn+1Y0ERAbUfWw8R4GjgVbaKnUjRoD2FoQbHOCbOyT5Mbs9Lw4g==
+npm-packlist@5.1.1:
+  version "5.1.1"
+  resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-5.1.1.tgz#79bcaf22a26b6c30aa4dd66b976d69cc286800e0"
+  integrity sha512-UfpSvQ5YKwctmodvPPkK6Fwk603aoVsf8AEbmVKAEECrfvL8SSe1A2YIwrJ6xmTHAITKPwwZsWo7WwEbNk0kxw==
+  dependencies:
+    glob "^8.0.1"
+    ignore-walk "^5.0.1"
+    npm-bundled "^1.1.2"
+    npm-normalize-package-bin "^1.0.1"
+
+npm-packlist@^5.1.0:
+  version "5.1.3"
+  resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-5.1.3.tgz#69d253e6fd664b9058b85005905012e00e69274b"
+  integrity sha512-263/0NGrn32YFYi4J533qzrQ/krmmrWwhKkzwTuM4f/07ug51odoaNjUexxO4vxlzURHcmYMH1QjvHjsNDKLVg==
+  dependencies:
+    glob "^8.0.1"
+    ignore-walk "^5.0.1"
+    npm-bundled "^2.0.0"
+    npm-normalize-package-bin "^2.0.0"
+
+npm-packlist@^7.0.0:
+  version "7.0.4"
+  resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-7.0.4.tgz#033bf74110eb74daf2910dc75144411999c5ff32"
+  integrity sha512-d6RGEuRrNS5/N84iglPivjaJPxhDbZmlbTwTDX2IbcRHG5bZCdtysYMhwiPvcF4GisXHGn7xsxv+GQ7T/02M5Q==
   dependencies:
-    ignore-walk "^3.0.1"
-    npm-bundled "^1.0.1"
+    ignore-walk "^6.0.0"
 
 npm-pick-manifest@8.0.1, npm-pick-manifest@^8.0.0, npm-pick-manifest@^8.0.1:
   version "8.0.1"