From 49597012c129747679b4315ec4d16d314ce69701 Mon Sep 17 00:00:00 2001 From: Jake Ginnivan Date: Mon, 30 Oct 2023 15:49:35 +0800 Subject: [PATCH] Fix CLI build --- apps/cli/package.json | 4 ++-- apps/cli/project.json | 41 +++++++++++++++++++++++++++++---------- apps/cli/src/main.ts | 9 +++++++-- package.json | 2 -- pnpm-lock.yaml | 45 ++++++++++++++++++++++++++++++++----------- tsconfig.json | 3 +++ 6 files changed, 77 insertions(+), 27 deletions(-) diff --git a/apps/cli/package.json b/apps/cli/package.json index 2f5855fa..c160b301 100644 --- a/apps/cli/package.json +++ b/apps/cli/package.json @@ -1,12 +1,12 @@ { "name": "@featureboard/cli", "version": "0.2.1", + "types": "module", "license": "MIT", - "dependencies": { + "devDependencies": { "@commander-js/extra-typings": "^11.1.0", "@featureboard/code-generator": "workspace:*", "ejs": "^3.1.9", - "figlet": "^1.7.0", "prompts": "^2.4.2" }, "type": "module", diff --git a/apps/cli/project.json b/apps/cli/project.json index c59e2cd1..a20f3470 100644 --- a/apps/cli/project.json +++ b/apps/cli/project.json @@ -4,11 +4,42 @@ "sourceRoot": "apps/cli/src", "projectType": "application", "targets": { + "build": { + "executor": "@nx/esbuild:esbuild", + "outputs": ["{options.outputPath}"], + "defaultConfiguration": "production", + "options": { + "platform": "node", + "outputPath": "apps/cli/dist", + "assets": [], + "format": ["esm"], + "bundle": true, + "skipTypeCheck": true, + + "main": "apps/cli/src/main.ts", + "tsConfig": "apps/cli/tsconfig.json", + "esbuildOptions": { + "sourcemap": true, + "outExtension": { + ".js": ".js" + }, + "banner": { + "js": "const require = (await import('node:module')).createRequire(import.meta.url);const __filename = (await import('node:url')).fileURLToPath(import.meta.url);const __dirname = (await import('node:path')).dirname(__filename);" + } + }, + "thirdParty": true + }, + "configurations": { + "development": {}, + "production": {} + } + }, "serve": { "executor": "@nx/js:node", "defaultConfiguration": "development", "options": { "buildTarget": "cli:build", + "args": [ "code-gen", "--output-path", @@ -24,16 +55,6 @@ } } }, - "package": { - "executor": "nx:run-commands", - "options": { - "commands": [ - "tsup src/main.ts -d dist --sourcemap --format esm --external @featureboard/code-generator" - ], - "cwd": "apps/cli", - "parallel": false - } - }, "lint": { "executor": "@nx/eslint:lint", "outputs": ["{options.outputFile}"], diff --git a/apps/cli/src/main.ts b/apps/cli/src/main.ts index 3ed1dec9..f7f8267f 100644 --- a/apps/cli/src/main.ts +++ b/apps/cli/src/main.ts @@ -9,7 +9,6 @@ import { flushChanges, printChanges, } from '@featureboard/code-generator' -import figlet from 'figlet' import fs from 'fs' import fsAsync from 'fs/promises' import path from 'path' @@ -20,7 +19,13 @@ import prompts from 'prompts' const packageJson: { version: string } = JSON.parse( fs.readFileSync(path.join(__dirname, '../package.json'), 'utf8'), ) -const titleText = figlet.textSync(`FeatureBoard CLI V${packageJson.version}`) + +// https://manytools.org/hacker-tools/ascii-banner/ +const titleText = ` ___ _ ___ _ ___ _ ___ +| __|__ __ _| |_ _ _ _ _ ___| _ ) ___ __ _ _ _ __| | / __| | |_ _| +| _/ -_) _\` | _| || | '_/ -_) _ \\/ _ \\/ _\` | '_/ _\` | | (__| |__ | | +|_|\\___\\__,_|\\__|\\_,_|_| \\___|___/\\___/\\__,_|_| \\__,_| \\___|____|___| + ` const program = new Command() .description(`${titleText}\nA Code generator for FeatureBoard`) diff --git a/package.json b/package.json index 905651cc..1f880688 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,6 @@ "@testing-library/react": "^14.0.0", "@types/debug": "^4.1.10", "@types/ejs": "^3.1.4", - "@types/figlet": "^1.5.7", "@types/node": "20.8.9", "@types/prompts": "^2.4.7", "@types/react": "^18.2.32", @@ -75,7 +74,6 @@ "eslint-plugin-prettier": "^5.0.1", "eslint-plugin-react": "^7.33.2", "eslint-plugin-react-hooks": "^4.6.0", - "figlet": "^1.7.0", "happy-dom": "^12.9.1", "jsonc-eslint-parser": "^2.4.0", "msw": "^2.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4b37fc01..574f674e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -78,9 +78,6 @@ importers: '@types/ejs': specifier: ^3.1.4 version: 3.1.4 - '@types/figlet': - specifier: ^1.5.7 - version: 1.5.7 '@types/node': specifier: 20.8.9 version: 20.8.9 @@ -141,9 +138,6 @@ importers: eslint-plugin-react-hooks: specifier: ^4.6.0 version: 4.6.0(eslint@8.52.0) - figlet: - specifier: ^1.7.0 - version: 1.7.0 happy-dom: specifier: ^12.9.1 version: 12.9.1 @@ -194,7 +188,7 @@ importers: version: 0.34.6(@vitest/ui@0.34.6)(happy-dom@12.9.1) apps/cli: - dependencies: + devDependencies: '@commander-js/extra-typings': specifier: ^11.1.0 version: 11.1.0(commander@11.1.0) @@ -204,6 +198,39 @@ importers: ejs: specifier: ^3.1.9 version: 3.1.9 + prompts: + specifier: ^2.4.2 + version: 2.4.2 + + apps/cli/dist: + devDependencies: + '@commander-js/extra-typings': + specifier: ^11.1.0 + version: 11.1.0(commander@11.1.0) + '@featureboard/code-generator': + specifier: workspace:* + version: link:../../../libs/code-generator + ejs: + specifier: ^3.1.9 + version: 3.1.9 + figlet: + specifier: ^1.7.0 + version: 1.7.0 + prompts: + specifier: ^2.4.2 + version: 2.4.2 + + apps/cli/tsc-out: + dependencies: + '@commander-js/extra-typings': + specifier: ^11.1.0 + version: 11.1.0(commander@11.1.0) + '@featureboard/code-generator': + specifier: workspace:* + version: link:../../../libs/code-generator + ejs: + specifier: ^3.1.9 + version: 3.1.9 figlet: specifier: ^1.7.0 version: 1.7.0 @@ -3591,10 +3618,6 @@ packages: resolution: {integrity: sha512-fnM/NjByiWdSRJRrmGxgqOSAnmOnsvX1QcNYk5TVyIIj+7ZqOKMb9gQa4OIl/lil2w/8TiTWV+nz3q8yqxez/w==} dev: true - /@types/figlet@1.5.7: - resolution: {integrity: sha512-0+XwDLeH346mAl3fmw/AaEctBrhkcJl0wZezoNUQ5Tg6J5YW7xL2v9hH3Yg5L4dk/sogEdQexTrNncqjGKwoVw==} - dev: true - /@types/graceful-fs@4.1.8: resolution: {integrity: sha512-NhRH7YzWq8WiNKVavKPBmtLYZHxNY19Hh+az28O/phfp68CF45pMFud+ZzJ8ewnxnC5smIdF3dqFeiSUQ5I+pw==} dependencies: diff --git a/tsconfig.json b/tsconfig.json index b1203963..bfcf0c35 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,6 +4,9 @@ "disableSourceOfProjectReferenceRedirect": true }, "references": [ + { + "path": "./apps/cli" + }, { "path": "./libs/contracts" },