diff --git a/nx.json b/nx.json index 1e83b22..37d24e5 100644 --- a/nx.json +++ b/nx.json @@ -13,50 +13,57 @@ "default", "!{projectRoot}/.eslintrc.json", "!{projectRoot}/eslint.config.js", - "!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)", - "!{projectRoot}/tsconfig.spec.json", - "!{projectRoot}/jest.config.[jt]s", - "!{projectRoot}/src/test-setup.[jt]s", - "!{projectRoot}/test-setup.[jt]s" + "!{projectRoot}/test/**/?(*.)+(test).ts?(x)?(.snap)", + "!{projectRoot}/tsconfig.test.json", + "!{projectRoot}/jest.config.ts" ], "sharedGlobals": [] }, "targetDefaults": { - "lint": { - "inputs": [ - "default", - "{projectRoot}/**/*.ts", - "{workspaceRoot}/.eslintrc.json", - "{workspaceRoot}/.eslintignore" - ], - "cache": true - }, - "@nx/js:tsc": { - "cache": true, - "dependsOn": ["^build"], - "inputs": ["production", "^production"] - }, "@nx/eslint:lint": { + "inputs": ["default", "{workspaceRoot}/.eslintrc.json", "{workspaceRoot}/.eslintignore"], "cache": true, - "inputs": [ - "default", - "{workspaceRoot}/.eslintrc.json", - "{workspaceRoot}/.eslintignore" - ] + "options": { + "lintFilePatterns": ["{projectRoot}/**/*.ts", "{projectRoot}/package.json"] + }, + "configurations": { + "fix": { + "fix": true, + "cache": false + } + } }, "@nx/jest:jest": { "cache": true, + "outputs": ["{options.outputFile}"], "inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"], "options": { - "passWithNoTests": true, - "runInBand": true + "jestConfig": "{projectRoot}/jest.config.ts", + "runInBand": true, + "passWithNoTests": true }, "configurations": { + "watch": { + "watch": true + }, "ci": { "ci": true, "codeCoverage": true + }, + "updateSnapshot": { + "updateSnapshot": true } } + }, + "@nx/js:tsc": { + "inputs": ["production", "^production"], + "outputs": ["{options.outputPath}"], + "dependsOn": ["^build", "test"], + "cache": true, + "options": { + "outputPath": "dist/{projectRoot}", + "tsConfig": "{projectRoot}/tsconfig.build.json" + } } }, "release": { diff --git a/package.json b/package.json index 5883423..cdbd371 100644 --- a/package.json +++ b/package.json @@ -10,18 +10,18 @@ "private": true, "packageManager": "pnpm@8.15.8", "dependencies": { - "@nx/devkit": "19.1.0", - "create-nx-workspace": "19.0.4", + "@nx/devkit": "19.1.1", + "create-nx-workspace": "19.1.1", "tslib": "^2.6.2" }, "devDependencies": { - "@nx/eslint": "19.1.0", - "@nx/eslint-plugin": "19.1.0", - "@nx/jest": "19.1.0", - "@nx/js": "19.1.0", - "@nx/linter": "19.1.0", - "@nx/plugin": "19.1.0", - "@nx/workspace": "19.1.0", + "@nx/eslint": "19.1.1", + "@nx/eslint-plugin": "19.1.1", + "@nx/jest": "19.1.1", + "@nx/js": "19.1.1", + "@nx/linter": "19.1.1", + "@nx/plugin": "19.1.1", + "@nx/workspace": "19.1.1", "@swc-node/register": "~1.8.0", "@swc/cli": "~0.3.12", "@swc/core": "~1.3.85", @@ -35,7 +35,7 @@ "husky": "^9.0.11", "jest": "^29.4.1", "jest-environment-jsdom": "^29.7.0", - "nx": "19.1.0", + "nx": "19.1.1", "prettier": "^2.8.8", "ts-jest": "^29.1.0", "ts-node": "10.9.1", diff --git a/packages/e2e/jest.config.ts b/packages/e2e/jest.config.ts index ff1889b..0cc52eb 100644 --- a/packages/e2e/jest.config.ts +++ b/packages/e2e/jest.config.ts @@ -9,6 +9,6 @@ export default { }, moduleFileExtensions: ['ts', 'js', 'html'], coverageDirectory: '../../coverage/packages/e2e', - globalSetup: '/src/helper/startLocalRegistry.ts', - globalTeardown: '/src/helper/stopLocalRegistry.ts', + globalSetup: '/src/helper/globalSetup.ts', + globalTeardown: '/src/helper/globalTeardown.ts', }; diff --git a/packages/e2e/project.json b/packages/e2e/project.json index 31343a5..87e4597 100644 --- a/packages/e2e/project.json +++ b/packages/e2e/project.json @@ -7,22 +7,13 @@ "targets": { "e2e": { "executor": "@nx/jest:jest", - "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], "options": { - "jestConfig": "{projectRoot}/jest.config.ts", - "runInBand": true, - "codeCoverage": false, + "codeCoverage": false }, "dependsOn": ["^build"] }, "lint": { "executor": "@nx/eslint:lint" - }, - "lint-fix": { - "executor": "@nx/eslint:lint", - "options": { - "fix": true - } } } } diff --git a/packages/e2e/src/generators/application.test.ts b/packages/e2e/src/generators/application.test.ts index d36904c..5e21968 100644 --- a/packages/e2e/src/generators/application.test.ts +++ b/packages/e2e/src/generators/application.test.ts @@ -1,35 +1,26 @@ -import { createTestWorkspace, execNx } from '../helper/functions'; +import { execNx, getTestWorkspaceRoot } from '../helper/functions'; import { existsSync } from 'fs'; import { join } from 'path'; describe('Application', () => { - let workspaceRoot; + const workspaceRoot = getTestWorkspaceRoot(); - beforeAll(() => { - workspaceRoot = createTestWorkspace('application-test'); - }); - - afterAll(() => { - if (!workspaceRoot) { - return; - } - execNx(workspaceRoot, 'reset'); - }); - - describe.each(['backend'])('Application[%s]', (type) => { + describe.each(['backend', 'frontend'])('Application[%s]', (type) => { beforeAll(() => { execNx(workspaceRoot, `g @hexancore/nx:app acme/${type} --type ${type}`); }); test('should be created', () => { - expect(existsSync(join(workspaceRoot, `apps/acme/${type}`, 'package.json'))).toBeTruthy(); + expect(existsSync(join(workspaceRoot, `apps/acme/${type}`, 'project.json'))).toBeTruthy(); }); test('target build should pass', () => { execNx(workspaceRoot, `run app-acme-${type}:build`); - expect(existsSync(join(workspaceRoot, `dist/apps/acme/${type}/src/main.js`))).toBeTruthy(); + const mainFile = type === 'frontend' ? 'index.html' : 'src/main.js'; + + expect(existsSync(join(workspaceRoot, `dist/apps/acme/${type}/${mainFile}`))).toBeTruthy(); }); test('target test should pass', () => { diff --git a/packages/e2e/src/generators/library.test.ts b/packages/e2e/src/generators/library.test.ts index e8a3ecf..223ff3b 100644 --- a/packages/e2e/src/generators/library.test.ts +++ b/packages/e2e/src/generators/library.test.ts @@ -1,22 +1,11 @@ -import { createTestWorkspace, execNx } from '../helper/functions'; +import { execNx, getTestWorkspaceRoot } from '../helper/functions'; import { existsSync } from 'fs'; import { join } from 'path'; describe('Library', () => { - let workspaceRoot; + const workspaceRoot = getTestWorkspaceRoot(); - beforeAll(() => { - workspaceRoot = createTestWorkspace('library-test'); - }); - - afterAll(() => { - if (!workspaceRoot) { - return; - } - execNx(workspaceRoot, 'reset'); - }); - - describe.each(['backend', 'shared'])('Library %s', (type) => { + describe.each(['backend', 'frontend', 'shared'])('Library %s', (type) => { beforeAll(() => { execNx(workspaceRoot, `g @hexancore/nx:lib acme/${type} --type ${type}`); }); @@ -28,7 +17,9 @@ describe('Library', () => { test('target build should pass', () => { execNx(workspaceRoot, `run acme-${type}:build`); - expect(existsSync(join(workspaceRoot, `dist/libs/acme/${type}/src/index.js`))).toBeTruthy(); + const expectedIndex = type === 'frontend' ? 'index.mjs' : 'src/index.js'; + + expect(existsSync(join(workspaceRoot, `dist/libs/acme/${type}/${expectedIndex}`))).toBeTruthy(); }); test('target test should pass', () => { diff --git a/packages/e2e/src/generators/preset.test.ts b/packages/e2e/src/generators/preset.test.ts index f5a0344..b6ccaf2 100644 --- a/packages/e2e/src/generators/preset.test.ts +++ b/packages/e2e/src/generators/preset.test.ts @@ -1,14 +1,11 @@ import { existsSync } from 'fs'; import { join } from 'path'; - -import { createTestWorkspace } from '../helper/functions'; +import { getTestWorkspaceRoot } from '../helper/functions'; describe('Preset', () => { - let workspaceRoot: string; + const workspaceRoot = getTestWorkspaceRoot(); test('should be installed', () => { - workspaceRoot = createTestWorkspace('preset-test'); - expect(existsSync(join(workspaceRoot, 'package.json'))).toBeTruthy(); }); }); diff --git a/packages/e2e/src/helper/functions.ts b/packages/e2e/src/helper/functions.ts index 1257d1e..4b6e13e 100644 --- a/packages/e2e/src/helper/functions.ts +++ b/packages/e2e/src/helper/functions.ts @@ -2,7 +2,17 @@ import { execSync } from 'child_process'; import { join, dirname } from 'path'; import { existsSync, mkdirSync, rmSync } from 'fs'; -export function createTestWorkspace(name: string): string { +export function getTestWorkspaceRoot(): string { + const root = process.env['TEST_WORKSPACE_ROOT'] ?? null; + + if (!root) { + throw new Error('Empty env[TEST_WORKSPACE_ROOT]'); + } + + return root; +} + +export function createTestWorkspace(name = 'test-workspace'): string { process.env['HUSKY'] = '0'; const cwd = process.cwd(); @@ -13,6 +23,8 @@ export function createTestWorkspace(name: string): string { rmSync(workspaceRoot, { recursive: true, force: true, + maxRetries: 3, + retryDelay: 3 * 1000, }); } @@ -42,6 +54,6 @@ export function execNx(workspaceRoot: string, command: string): void { cwd: workspaceRoot, stdio: 'inherit', env: process.env, - timeout: 3*60*1000 + timeout: 3 * 60 * 1000 }); } \ No newline at end of file diff --git a/packages/e2e/src/helper/startLocalRegistry.ts b/packages/e2e/src/helper/globalSetup.ts similarity index 78% rename from packages/e2e/src/helper/startLocalRegistry.ts rename to packages/e2e/src/helper/globalSetup.ts index 5280d2a..3e534db 100644 --- a/packages/e2e/src/helper/startLocalRegistry.ts +++ b/packages/e2e/src/helper/globalSetup.ts @@ -1,8 +1,11 @@ import { startLocalRegistry } from '@nx/js/plugins/jest/local-registry'; -import { existsSync, rmSync } from 'fs'; +import { execSync } from 'child_process'; +import { existsSync} from 'fs'; import { releasePublish, releaseVersion } from 'nx/release'; import { join } from 'path'; +import { createTestWorkspace } from './functions'; + export default async () => { // local registry target to run const localRegistryTarget = '@nx-hexancore/source:local-registry'; @@ -12,9 +15,8 @@ export default async () => { const cwd = process.cwd(); process.env['PNPM_HOME'] = join(cwd, 'tmp', 'pnpm-store'); if (existsSync(process.env['PNPM_HOME'])) { - rmSync(process.env['PNPM_HOME'], { - recursive: true, - force: true, + execSync('pnpm store prune', { + env: process.env }); } @@ -38,4 +40,6 @@ export default async () => { tag: 'e2e', firstRelease: true, }); + + process.env['TEST_WORKSPACE_ROOT'] = createTestWorkspace(); }; diff --git a/packages/e2e/src/helper/globalTeardown.ts b/packages/e2e/src/helper/globalTeardown.ts new file mode 100644 index 0000000..ce2b4bf --- /dev/null +++ b/packages/e2e/src/helper/globalTeardown.ts @@ -0,0 +1,14 @@ +import { existsSync } from "fs"; +import { execNx, getTestWorkspaceRoot } from "./functions"; + +export default () => { + if (global.stopLocalRegistry) { + global.stopLocalRegistry(); + } + + const workspaceRoot = getTestWorkspaceRoot(); + if (existsSync(workspaceRoot)) { + execNx(workspaceRoot, 'reset'); + } +}; + diff --git a/packages/e2e/src/helper/stopLocalRegistry.ts b/packages/e2e/src/helper/stopLocalRegistry.ts deleted file mode 100644 index 1bf839a..0000000 --- a/packages/e2e/src/helper/stopLocalRegistry.ts +++ /dev/null @@ -1,5 +0,0 @@ -export default () => { - if (global.stopLocalRegistry) { - global.stopLocalRegistry(); - } -}; diff --git a/packages/plugin/package.json b/packages/plugin/package.json index 28a4989..8d3edd1 100644 --- a/packages/plugin/package.json +++ b/packages/plugin/package.json @@ -22,7 +22,7 @@ "url": "https://andrzejwasiak.pl" }, "dependencies": { - "@nx/devkit": "19.1.0", + "@nx/devkit": "19.1.1", "tslib": "^2.6.2" }, "files": [ diff --git a/packages/plugin/project.json b/packages/plugin/project.json index a2225ff..13b3569 100644 --- a/packages/plugin/project.json +++ b/packages/plugin/project.json @@ -12,14 +12,16 @@ }, "tags": [], "targets": { + "lint": { + "executor": "@nx/eslint:lint" + }, + "test": { + "executor": "@nx/jest:jest" + }, "build": { "executor": "@nx/js:tsc", - "dependsOn": ["test"], - "outputs": ["{options.outputPath}"], "options": { - "outputPath": "dist/{projectRoot}", "main": "{projectRoot}/src/index.ts", - "tsConfig": "{projectRoot}/tsconfig.lib.json", "assets": [ { "input": "{projectRoot}/src", @@ -64,40 +66,6 @@ "registry": "http://localhost:4873/", "packageRoot": "dist/{projectRoot}" } - }, - "lint": { - "executor": "@nx/eslint:lint", - "outputs": ["{options.outputPath}"], - "options": { - "lintFilePatterns": [ - "{projectRoot}/**/*.ts", - "{projectRoot}/package.json" - ] - } - }, - "lint-fix": { - "executor": "@nx/eslint:lint", - "cache": false, - "options": { - "fix": true - } - }, - "test": { - "executor": "@nx/jest:jest", - "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], - "options": { - "jestConfig": "{projectRoot}/jest.config.ts", - "runInBand": true - } - }, - "test-watch": { - "executor": "@nx/jest:jest", - "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], - "options": { - "jestConfig": "{projectRoot}/jest.config.ts", - "runInBand": true, - "watch": true - } } } } diff --git a/packages/plugin/src/generators/application/applicationGenerator.ts b/packages/plugin/src/generators/application/applicationGenerator.ts index 178417c..b53bad1 100644 --- a/packages/plugin/src/generators/application/applicationGenerator.ts +++ b/packages/plugin/src/generators/application/applicationGenerator.ts @@ -8,10 +8,6 @@ import { ApplicationGeneratorSchema } from './schema'; export async function applicationGenerator(tree: Tree, options: ApplicationGeneratorSchema): Promise { - if (options.type === 'frontend') { - throw new Error('Not supported yet'); - } - const helper = new HcNxHelper(tree); const project: ProjectMeta = helper.project.addApplication(options.directory, options.type); diff --git a/packages/plugin/src/generators/application/files/backend/README.md.template b/packages/plugin/src/generators/application/files/backend/README.md.template index b88fb93..9ea5465 100644 --- a/packages/plugin/src/generators/application/files/backend/README.md.template +++ b/packages/plugin/src/generators/application/files/backend/README.md.template @@ -1,9 +1,2 @@ # <%= project.name %> -## Building - -Run `nx build <%= project.name %>` to build the application. - -## Running tests - -Run `nx test <%= project.name %>` to execute the tests. diff --git a/packages/plugin/src/generators/application/files/frontend/README.md.template b/packages/plugin/src/generators/application/files/frontend/README.md.template index b88fb93..9ea5465 100644 --- a/packages/plugin/src/generators/application/files/frontend/README.md.template +++ b/packages/plugin/src/generators/application/files/frontend/README.md.template @@ -1,9 +1,2 @@ # <%= project.name %> -## Building - -Run `nx build <%= project.name %>` to build the application. - -## Running tests - -Run `nx test <%= project.name %>` to execute the tests. diff --git a/packages/plugin/src/generators/application/files/frontend/index.html__tmpl__ b/packages/plugin/src/generators/application/files/frontend/index.html__tmpl__ new file mode 100644 index 0000000..1175e6b --- /dev/null +++ b/packages/plugin/src/generators/application/files/frontend/index.html__tmpl__ @@ -0,0 +1,16 @@ + + + + + + + app-pmt-web + + +
+ + + + diff --git a/packages/plugin/src/generators/application/files/frontend/src/Core/Service/Plugin/PiniaCorePlugin.ts__tmpl__ b/packages/plugin/src/generators/application/files/frontend/src/Core/Service/Plugin/PiniaCorePlugin.ts__tmpl__ index 45f0f2f..9177699 100644 --- a/packages/plugin/src/generators/application/files/frontend/src/Core/Service/Plugin/PiniaCorePlugin.ts__tmpl__ +++ b/packages/plugin/src/generators/application/files/frontend/src/Core/Service/Plugin/PiniaCorePlugin.ts__tmpl__ @@ -1,6 +1,5 @@ import { App } from "vue"; import { createPinia } from "pinia"; -import { useMenuStore } from "../Router/MenuStore"; export function PiniaCorePlugin(app: App) { const pinia = createPinia(); diff --git a/packages/plugin/src/generators/application/files/frontend/src/Core/Service/Router/Router.ts__tmpl__ b/packages/plugin/src/generators/application/files/frontend/src/Core/Service/Router/Router.ts__tmpl__ index 2ee4f6b..8298d7c 100644 --- a/packages/plugin/src/generators/application/files/frontend/src/Core/Service/Router/Router.ts__tmpl__ +++ b/packages/plugin/src/generators/application/files/frontend/src/Core/Service/Router/Router.ts__tmpl__ @@ -1,6 +1,6 @@ import { createRouter, createWebHistory } from 'vue-router'; import AppLayout from '../../Component/Layout/AppLayout.vue'; -import CoreRoutes from '../../Component/View/CoreRoutes.ts'; +import CoreRoutes from '../../Component/View/CoreRoutes'; const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), diff --git a/packages/plugin/src/generators/application/files/frontend/src/main.ts__tmpl__ b/packages/plugin/src/generators/application/files/frontend/src/main.ts__tmpl__ index ae5dc6b..bfabbe9 100644 --- a/packages/plugin/src/generators/application/files/frontend/src/main.ts__tmpl__ +++ b/packages/plugin/src/generators/application/files/frontend/src/main.ts__tmpl__ @@ -3,10 +3,10 @@ process = process ?? { env: {} }; import { createApp } from 'vue'; import App from './Core/Component/View/App.vue'; -import { PrimeVueCorePlugin } from './Core/Service/Plugin/PrimeVueCorePlugin.ts'; -import router from './Core/Service/Router/Router.ts'; -import { I18NCorePlugin } from './Core/Service/Plugin/I18NCorePlugin.ts'; -import { PiniaCorePlugin } from './Core/Service/Plugin/PiniaCorePlugin.ts'; +import { PrimeVueCorePlugin } from './Core/Service/Plugin/PrimeVueCorePlugin'; +import router from './Core/Service/Router/Router'; +import { I18NCorePlugin } from './Core/Service/Plugin/I18NCorePlugin'; +import { PiniaCorePlugin } from './Core/Service/Plugin/PiniaCorePlugin'; const app = createApp(App); diff --git a/packages/plugin/src/generators/application/files/frontend/vite.config.ts__tmpl__ b/packages/plugin/src/generators/application/files/frontend/vite.config.ts__tmpl__ index 07e077f..7ef23bd 100644 --- a/packages/plugin/src/generators/application/files/frontend/vite.config.ts__tmpl__ +++ b/packages/plugin/src/generators/application/files/frontend/vite.config.ts__tmpl__ @@ -1,89 +1,9 @@ -import { defineConfig } from 'vite'; -import vue from '@vitejs/plugin-vue'; -import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; -import path from 'path'; +import { defineAppProjectViteConfig } from "<%= project.relative.workspaceRoot %>/.workspace/vite/vite.preset"; -import resolvePlugin from '@rollup/plugin-node-resolve'; -import basicSsl from '@vitejs/plugin-basic-ssl'; +const project = { + workspaceRootRelative: '<%= project.relative.workspaceRoot %>', + root: '<%= project.root %>', + name: '<%= project.name %>' +}; -import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'; - -import { assetDir, chunkFileNames, entryFileNames, processAssetFileNames } from './vite/Assets'; - - -export default defineConfig({ - root: __dirname, - cacheDir: '<%= project.workspaceRootRelative %>tmp/vite/<%= project.name %>', - server: { - port: 20021, - host: 'localhost', - - fs: { - // Allow serving files from one level up to the project root - strict: false, - }, - }, - - preview: { - port: 20022, - host: 'localhost', - }, - - publicDir: path.resolve(__dirname, './public'), - build: { - outDir: '<%= project.workspaceRootRelative %>dist/<%= project.root %>', - reportCompressedSize: true, - commonjsOptions: { transformMixedEsModules: true }, - minify: true, - assetsDir: assetDir, - // don't inline anything for demo - assetsInlineLimit: 0, - emptyOutDir: true, - rollupOptions: { - preserveSymlinks: true, - output: { - entryFileNames: entryFileNames, - assetFileNames: processAssetFileNames, - chunkFileNames: chunkFileNames - } - } - }, - - plugins: [ - vue({ - template: { - compilerOptions: { - //isCustomElement: (tag) => /^[A-Z]/.test(tag) - }, - }, - }), - nxViteTsPaths(), - VueI18nPlugin({ - include: [path.resolve(__dirname, './src/*/Asset/Locale/**')], - defaultSFCLang: 'yaml', - allowDynamic: true, - dropMessageCompiler: true, - }), - resolvePlugin(undefined), - basicSsl(), - ], - - // Uncomment this if you are using workers. - // worker: { - // plugins: [ nxViteTsPaths() ], - // }, - - test: { - reporters: ['default'], - coverage: { - reportsDirectory: '<%= project.workspaceRootRelative %>coverage/<%= project.root %>', - provider: 'v8', - }, - globals: true, - cache: { - dir: '<%= project.workspaceRootRelative %>tmp/vitest/<%= project.name %>', - }, - environment: 'jsdom', - include: ['test/**/*.test.ts'], - }, -}); +export default defineAppProjectViteConfig(__dirname, project); diff --git a/packages/plugin/src/generators/application/schema.json b/packages/plugin/src/generators/application/schema.json index 67bff4f..57c7fa3 100644 --- a/packages/plugin/src/generators/application/schema.json +++ b/packages/plugin/src/generators/application/schema.json @@ -1,34 +1,26 @@ { - "$schema": "https://json-schema.org/schema", + "$schema": "https://json-schema.org/draft/2020-12/output/schema", "$id": "Application", "title": "", "type": "object", "properties": { - "name": { - "type": "string", - "description": "", - "$default": { - "$source": "argv", - "index": 0 - }, - "x-prompt": "What name would you like to use?" - }, "directory": { "type": "string", - "description": "A directory where the application is placed.", + "description": "A directory where the application is placed in `apps/`. Project name pattern: 'acme/api' -> 'app-acme-api'", + "x-prompt": "Application project directory in `apps/`", "x-priority": "important", "$default": { "$source": "argv", "index": 0 - }, + } }, "type": { "description": "The application type.", "type": "string", - "enum": ["backend"], + "enum": ["backend", "frontend"], "x-prompt": "Which application type would you like to use ?", "x-priority": "important" } }, - "required": ["name", "type"] + "required": ["directory", "type"] } diff --git a/packages/plugin/src/generators/library/files/backend/README.md.template b/packages/plugin/src/generators/library/files/backend/README.md.template deleted file mode 100644 index 355cc03..0000000 --- a/packages/plugin/src/generators/library/files/backend/README.md.template +++ /dev/null @@ -1,9 +0,0 @@ -# <%= project.name %> - -## Building - -Run `nx build <%= project.name %>` to build the library. - -## Running tests - -Run `nx test <%= project.name %>` to execute the tests. diff --git a/packages/plugin/src/generators/library/files/backend/README.md__tmpl__ b/packages/plugin/src/generators/library/files/backend/README.md__tmpl__ new file mode 100644 index 0000000..97d2338 --- /dev/null +++ b/packages/plugin/src/generators/library/files/backend/README.md__tmpl__ @@ -0,0 +1,3 @@ +# <%= project.name %> + + diff --git a/packages/plugin/src/generators/library/files/frontend/README.md.template b/packages/plugin/src/generators/library/files/frontend/README.md.template deleted file mode 100644 index 355cc03..0000000 --- a/packages/plugin/src/generators/library/files/frontend/README.md.template +++ /dev/null @@ -1,9 +0,0 @@ -# <%= project.name %> - -## Building - -Run `nx build <%= project.name %>` to build the library. - -## Running tests - -Run `nx test <%= project.name %>` to execute the tests. diff --git a/packages/plugin/src/generators/library/files/frontend/README.md__tmpl__ b/packages/plugin/src/generators/library/files/frontend/README.md__tmpl__ new file mode 100644 index 0000000..97d2338 --- /dev/null +++ b/packages/plugin/src/generators/library/files/frontend/README.md__tmpl__ @@ -0,0 +1,3 @@ +# <%= project.name %> + + diff --git a/packages/plugin/src/generators/library/files/frontend/src/vue-shims.d.ts__tmpl__ b/packages/plugin/src/generators/library/files/frontend/src/vue-shims.d.ts__tmpl__ new file mode 100644 index 0000000..798e8fc --- /dev/null +++ b/packages/plugin/src/generators/library/files/frontend/src/vue-shims.d.ts__tmpl__ @@ -0,0 +1,5 @@ +declare module '*.vue' { + import { defineComponent } from 'vue'; + const component: ReturnType; + export default component; +} diff --git a/packages/plugin/src/generators/library/files/frontend/vite.config.ts__tmpl__ b/packages/plugin/src/generators/library/files/frontend/vite.config.ts__tmpl__ index 5a9e4ea..b6ddeff 100644 --- a/packages/plugin/src/generators/library/files/frontend/vite.config.ts__tmpl__ +++ b/packages/plugin/src/generators/library/files/frontend/vite.config.ts__tmpl__ @@ -1,12 +1,9 @@ -import { defineConfig } from 'vitest/config' +import { defineLibProjectViteConfig } from "<%= project.relative.dotWorkspace %>/vite/vite.preset"; -export default defineConfig({ - test: { - globals: true, - environment: 'jsdom', - include: ['test/**/*.test.ts'], - alias: { - '@/': new URL('./src/', import.meta.url).pathname, - }, - }, -}); +const project = { + workspaceRootRelative: '<%= project.relative.workspaceRoot %>', + root: '<%= project.root %>', + name: '<%= project.name %>' +}; + +export default defineLibProjectViteConfig(__dirname, project); diff --git a/packages/plugin/src/generators/library/files/shared/.eslintrc.json__tmpl__ b/packages/plugin/src/generators/library/files/shared/.eslintrc.json__tmpl__ index f03f4b3..b0654a1 100644 --- a/packages/plugin/src/generators/library/files/shared/.eslintrc.json__tmpl__ +++ b/packages/plugin/src/generators/library/files/shared/.eslintrc.json__tmpl__ @@ -1,5 +1,5 @@ { - "extends": ["<%= project.workspaceRootRelative %>.eslintrc.json"], + "extends": ["<%= project.relative.workspaceRoot %>/.eslintrc.json"], "ignorePatterns": ["!**/*"] } diff --git a/packages/plugin/src/generators/library/files/shared/README.md.template b/packages/plugin/src/generators/library/files/shared/README.md.template deleted file mode 100644 index 355cc03..0000000 --- a/packages/plugin/src/generators/library/files/shared/README.md.template +++ /dev/null @@ -1,9 +0,0 @@ -# <%= project.name %> - -## Building - -Run `nx build <%= project.name %>` to build the library. - -## Running tests - -Run `nx test <%= project.name %>` to execute the tests. diff --git a/packages/plugin/src/generators/library/files/shared/README.md__tmpl__ b/packages/plugin/src/generators/library/files/shared/README.md__tmpl__ new file mode 100644 index 0000000..9ea5465 --- /dev/null +++ b/packages/plugin/src/generators/library/files/shared/README.md__tmpl__ @@ -0,0 +1,2 @@ +# <%= project.name %> + diff --git a/packages/plugin/src/generators/library/files/shared/jest.config.ts__tmpl__ b/packages/plugin/src/generators/library/files/shared/jest.config.ts__tmpl__ index f92c2ee..f9bc5c2 100644 --- a/packages/plugin/src/generators/library/files/shared/jest.config.ts__tmpl__ +++ b/packages/plugin/src/generators/library/files/shared/jest.config.ts__tmpl__ @@ -1,5 +1,9 @@ -import createJestConfig from "<%= project.workspaceRootRelative %>jest.preset"; +import { defineProjectJestConfig } from "<%= project.relative.dotWorkspace %>/jest/jest.preset"; -const jestConfig = createJestConfig(__dirname); +const project = { + workspaceRootRelative: '<%= project.relative.workspaceRoot %>', + root: '<%= project.root %>', + name: '<%= project.name %>' +}; -export default jestConfig \ No newline at end of file +export default defineProjectJestConfig(__dirname, project); \ No newline at end of file diff --git a/packages/plugin/src/generators/library/files/shared/tsconfig.build.json__tmpl__ b/packages/plugin/src/generators/library/files/shared/tsconfig.build.json__tmpl__ index 22d9f5b..5c5199a 100644 --- a/packages/plugin/src/generators/library/files/shared/tsconfig.build.json__tmpl__ +++ b/packages/plugin/src/generators/library/files/shared/tsconfig.build.json__tmpl__ @@ -1,7 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "<%= project.workspaceRootRelative %>dist/out-tsc", + "outDir": "<%= project.relative.workspaceRoot %>/dist/out-tsc", "declaration": true }, "include": ["src/**/*.ts"], diff --git a/packages/plugin/src/generators/library/files/shared/tsconfig.json.template b/packages/plugin/src/generators/library/files/shared/tsconfig.json.template index fe0bfd2..05d4f54 100644 --- a/packages/plugin/src/generators/library/files/shared/tsconfig.json.template +++ b/packages/plugin/src/generators/library/files/shared/tsconfig.json.template @@ -1,5 +1,5 @@ { - "extends": "<%= project.workspaceRootRelative %>tsconfig.base.json", + "extends": "<%= project.relative.workspaceRoot %>/tsconfig.base.json", "compilerOptions": { "moduleResolution": "Node16", "module": "Node16", diff --git a/packages/plugin/src/generators/library/files/shared/tsconfig.test.json__tmpl__ b/packages/plugin/src/generators/library/files/shared/tsconfig.test.json__tmpl__ index 67a3bf3..4d015f8 100644 --- a/packages/plugin/src/generators/library/files/shared/tsconfig.test.json__tmpl__ +++ b/packages/plugin/src/generators/library/files/shared/tsconfig.test.json__tmpl__ @@ -1,13 +1,13 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "<%= project.workspaceRootRelative %>dist/out-tsc", + "outDir": "<%= project.relative.workspaceRoot %>/dist/out-tsc", "types": ["jest", "node"] }, "files": [ - "<%= project.workspaceRootRelative %>node_modules/jest-expect-message/types/index.d.ts", - "<%= project.workspaceRootRelative %>node_modules/@hexancore/common/lib/cjs/Test/Matchers.d.ts" + "<%= project.relative.workspaceRoot %>/node_modules/jest-expect-message/types/index.d.ts", + "<%= project.relative.workspaceRoot %>/node_modules/@hexancore/common/lib/cjs/Test/Matchers.d.ts" ], "include": [ "src/**/*.ts", diff --git a/packages/plugin/src/generators/library/libraryGenerator.ts b/packages/plugin/src/generators/library/libraryGenerator.ts index 95e4afd..7621108 100644 --- a/packages/plugin/src/generators/library/libraryGenerator.ts +++ b/packages/plugin/src/generators/library/libraryGenerator.ts @@ -7,11 +7,6 @@ import { ProjectMeta } from '../../util'; import { LibraryGeneratorSchema } from './schema'; export async function libraryGenerator(tree: Tree, options: LibraryGeneratorSchema): Promise { - - if (options.type === 'frontend') { - throw new Error('Not supported yet'); - } - const helper = new HcNxHelper(tree); const project: ProjectMeta = helper.project.addLibrary(options.directory, options.type); diff --git a/packages/plugin/src/generators/library/schema.json b/packages/plugin/src/generators/library/schema.json index 659fb69..72a30d3 100644 --- a/packages/plugin/src/generators/library/schema.json +++ b/packages/plugin/src/generators/library/schema.json @@ -1,34 +1,26 @@ { - "$schema": "https://json-schema.org/schema", + "$schema": "https://json-schema.org/draft/2020-12/output/schema", "$id": "Library", "title": "", "type": "object", "properties": { - "name": { - "type": "string", - "description": "", - "$default": { - "$source": "argv", - "index": 0 - }, - "x-prompt": "What name would you like to use?" - }, "directory": { "type": "string", - "description": "A directory where the lib is placed.", + "description": "A directory where the library is placed in `apps/`. Project name will be directory with replaced '/'", + "x-prompt": "Library project directory in `apps/`", "x-priority": "important", "$default": { "$source": "argv", "index": 0 - }, + } }, "type": { "description": "The library type.", "type": "string", - "enum": ["backend", "shared"], - "x-prompt": "Which library type would you like to use ? Choose 'none' to skip build setup.", + "enum": ["backend", "shared", "frontend"], + "x-prompt": "Which library type would you like to use ?", "x-priority": "important" } }, - "required": ["name", "type"] + "required": ["directory", "type"] } diff --git a/packages/plugin/src/generators/preset/files/workspace/.eslintrc.json__tmpl__ b/packages/plugin/src/generators/preset/files/workspace/.eslintrc.json__tmpl__ index 0189870..84f54a3 100644 --- a/packages/plugin/src/generators/preset/files/workspace/.eslintrc.json__tmpl__ +++ b/packages/plugin/src/generators/preset/files/workspace/.eslintrc.json__tmpl__ @@ -1,37 +1,60 @@ { "root": true, - "plugins": ["@nx"], + "plugins": [ + "@nx" + ], "overrides": [ { - "files": ["*.json"], + "files": [ + "*.json" + ], "parser": "jsonc-eslint-parser", "rules": { "@nx/dependency-checks": [ "error", { - "buildTargets": ["build"], + "buildTargets": [ + "build" + ], "includeTransitiveDependencies": true, "checkMissingDependencies": true, "checkObsoleteDependencies": true, "checkVersionMismatches": true, - "ignoredFiles": ["vite.config.ts"], - "ignoredDependencies": ["ts-jest", "tslib"] + "ignoredFiles": [ + "vite.config.ts" + ], + "ignoredDependencies": [ + "ts-jest", + "tslib", + "@vitejs/plugin-basic-ssl", + "vite", + "vue", + "@vitejs/plugin-vue", + "@rollup/plugin-node-resolve" + ] } ] } }, { - "files": ["*.ts", "*.js", "*.vue"], + "files": [ + "*.ts", + "*.js", + "*.vue" + ], + "excludedFiles": ["**/.storybook/**/*", "**/vite.config.ts", "**/jest.config.ts"], "rules": { "@nx/enforce-module-boundaries": [ "error", { "enforceBuildableLibDependency": true, - "allow": ["jest.preset.ts", "../../../jest.preset"], + "allow": [], "depConstraints": [ { "sourceTag": "*", - "onlyDependOnLibsWithTags": ["*"] + "onlyDependOnLibsWithTags": [ + "*" + ] } ] } @@ -39,8 +62,12 @@ } }, { - "files": ["*.ts"], - "extends": ["plugin:@nx/typescript"], + "files": [ + "*.ts" + ], + "extends": [ + "plugin:@nx/typescript" + ], "rules": { "@typescript-eslint/no-explicit-any": "off", "no-empty-function": "off", @@ -50,19 +77,25 @@ } }, { - "files": ["*.js"], - "extends": ["plugin:@nx/javascript"], + "files": [ + "*.js" + ], + "extends": [ + "plugin:@nx/javascript" + ], "rules": { "@typescript-eslint/no-extra-semi": "error", "no-extra-semi": "off" } }, { - "files": ["*.test.ts"], + "files": [ + "*.test.ts" + ], "env": { "jest": true }, "rules": {} } ] -} +} \ No newline at end of file diff --git a/packages/plugin/src/generators/preset/files/.husky/install.mjs.template b/packages/plugin/src/generators/preset/files/workspace/.husky/install.mjs__tmpl__ similarity index 100% rename from packages/plugin/src/generators/preset/files/.husky/install.mjs.template rename to packages/plugin/src/generators/preset/files/workspace/.husky/install.mjs__tmpl__ diff --git a/packages/plugin/src/generators/preset/files/.husky/pre-commit b/packages/plugin/src/generators/preset/files/workspace/.husky/pre-commit__tmpl__ similarity index 100% rename from packages/plugin/src/generators/preset/files/.husky/pre-commit rename to packages/plugin/src/generators/preset/files/workspace/.husky/pre-commit__tmpl__ diff --git a/packages/plugin/src/generators/preset/files/workspace/.prettierignore__tmpl__ b/packages/plugin/src/generators/preset/files/workspace/.prettierignore__tmpl__ new file mode 100644 index 0000000..cd61731 --- /dev/null +++ b/packages/plugin/src/generators/preset/files/workspace/.prettierignore__tmpl__ @@ -0,0 +1,10 @@ +node_modules +tmp +dist +coverage +.nx +.workspace + +**/*.ts +**/*.vue +**/*.tsx \ No newline at end of file diff --git a/packages/plugin/src/generators/preset/files/workspace/.prettierrc.js__tmpl__ b/packages/plugin/src/generators/preset/files/workspace/.prettierrc.js__tmpl__ new file mode 100644 index 0000000..4182006 --- /dev/null +++ b/packages/plugin/src/generators/preset/files/workspace/.prettierrc.js__tmpl__ @@ -0,0 +1,10 @@ +module.exports = { + semi: true, + trailingComma: 'all', + singleQuote: true, + bracketSpacing: true, + arrowParens: 'always', + printWidth: 150, + tabWidth: 2, + useTabs: false, +}; diff --git a/packages/plugin/src/generators/preset/files/vscode/extensions.json b/packages/plugin/src/generators/preset/files/workspace/.vscode/extensions.json__tmpl__ similarity index 100% rename from packages/plugin/src/generators/preset/files/vscode/extensions.json rename to packages/plugin/src/generators/preset/files/workspace/.vscode/extensions.json__tmpl__ diff --git a/packages/plugin/src/generators/preset/files/vscode/settings.json b/packages/plugin/src/generators/preset/files/workspace/.vscode/settings.json.template__tmpl__ similarity index 100% rename from packages/plugin/src/generators/preset/files/vscode/settings.json rename to packages/plugin/src/generators/preset/files/workspace/.vscode/settings.json.template__tmpl__ diff --git a/packages/plugin/src/generators/preset/files/bin/util/MakeHelp__tmpl__ b/packages/plugin/src/generators/preset/files/workspace/.workspace/bin/util/MakeHelp__tmpl__ similarity index 100% rename from packages/plugin/src/generators/preset/files/bin/util/MakeHelp__tmpl__ rename to packages/plugin/src/generators/preset/files/workspace/.workspace/bin/util/MakeHelp__tmpl__ diff --git a/packages/plugin/src/generators/preset/files/bin/util/util.sh__tmpl__ b/packages/plugin/src/generators/preset/files/workspace/.workspace/bin/util/util.sh__tmpl__ similarity index 100% rename from packages/plugin/src/generators/preset/files/bin/util/util.sh__tmpl__ rename to packages/plugin/src/generators/preset/files/workspace/.workspace/bin/util/util.sh__tmpl__ diff --git a/packages/plugin/src/generators/preset/files/workspace/docker/app/Dockerfile__tmpl__ b/packages/plugin/src/generators/preset/files/workspace/.workspace/docker/app/Dockerfile__tmpl__ similarity index 100% rename from packages/plugin/src/generators/preset/files/workspace/docker/app/Dockerfile__tmpl__ rename to packages/plugin/src/generators/preset/files/workspace/.workspace/docker/app/Dockerfile__tmpl__ diff --git a/packages/plugin/src/generators/preset/files/workspace/docker/app/pm2.config.cjs__tmpl__ b/packages/plugin/src/generators/preset/files/workspace/.workspace/docker/app/pm2.config.cjs__tmpl__ similarity index 100% rename from packages/plugin/src/generators/preset/files/workspace/docker/app/pm2.config.cjs__tmpl__ rename to packages/plugin/src/generators/preset/files/workspace/.workspace/docker/app/pm2.config.cjs__tmpl__ diff --git a/packages/plugin/src/generators/preset/files/workspace/docker/dev/.env b/packages/plugin/src/generators/preset/files/workspace/.workspace/docker/dev/.env similarity index 100% rename from packages/plugin/src/generators/preset/files/workspace/docker/dev/.env rename to packages/plugin/src/generators/preset/files/workspace/.workspace/docker/dev/.env diff --git a/packages/plugin/src/generators/preset/files/workspace/docker/dev/ca/ca.crt b/packages/plugin/src/generators/preset/files/workspace/.workspace/docker/dev/ca/ca.crt similarity index 100% rename from packages/plugin/src/generators/preset/files/workspace/docker/dev/ca/ca.crt rename to packages/plugin/src/generators/preset/files/workspace/.workspace/docker/dev/ca/ca.crt diff --git a/packages/plugin/src/generators/preset/files/workspace/docker/dev/ca/ca.key b/packages/plugin/src/generators/preset/files/workspace/.workspace/docker/dev/ca/ca.key similarity index 100% rename from packages/plugin/src/generators/preset/files/workspace/docker/dev/ca/ca.key rename to packages/plugin/src/generators/preset/files/workspace/.workspace/docker/dev/ca/ca.key diff --git a/packages/plugin/src/generators/preset/files/workspace/docker/dev/ca/ca.srl b/packages/plugin/src/generators/preset/files/workspace/.workspace/docker/dev/ca/ca.srl similarity index 100% rename from packages/plugin/src/generators/preset/files/workspace/docker/dev/ca/ca.srl rename to packages/plugin/src/generators/preset/files/workspace/.workspace/docker/dev/ca/ca.srl diff --git a/packages/plugin/src/generators/preset/files/workspace/docker/dev/ca/certs/db/db.crt b/packages/plugin/src/generators/preset/files/workspace/.workspace/docker/dev/ca/certs/db/db.crt similarity index 100% rename from packages/plugin/src/generators/preset/files/workspace/docker/dev/ca/certs/db/db.crt rename to packages/plugin/src/generators/preset/files/workspace/.workspace/docker/dev/ca/certs/db/db.crt diff --git a/packages/plugin/src/generators/preset/files/workspace/docker/dev/ca/certs/db/db.key b/packages/plugin/src/generators/preset/files/workspace/.workspace/docker/dev/ca/certs/db/db.key similarity index 100% rename from packages/plugin/src/generators/preset/files/workspace/docker/dev/ca/certs/db/db.key rename to packages/plugin/src/generators/preset/files/workspace/.workspace/docker/dev/ca/certs/db/db.key diff --git a/packages/plugin/src/generators/preset/files/workspace/docker/dev/ca/certs/redis/redis.crt b/packages/plugin/src/generators/preset/files/workspace/.workspace/docker/dev/ca/certs/redis/redis.crt similarity index 100% rename from packages/plugin/src/generators/preset/files/workspace/docker/dev/ca/certs/redis/redis.crt rename to packages/plugin/src/generators/preset/files/workspace/.workspace/docker/dev/ca/certs/redis/redis.crt diff --git a/packages/plugin/src/generators/preset/files/workspace/docker/dev/ca/certs/redis/redis.key b/packages/plugin/src/generators/preset/files/workspace/.workspace/docker/dev/ca/certs/redis/redis.key similarity index 100% rename from packages/plugin/src/generators/preset/files/workspace/docker/dev/ca/certs/redis/redis.key rename to packages/plugin/src/generators/preset/files/workspace/.workspace/docker/dev/ca/certs/redis/redis.key diff --git a/packages/plugin/src/generators/preset/files/workspace/docker/dev/ca/create_ca.sh b/packages/plugin/src/generators/preset/files/workspace/.workspace/docker/dev/ca/create_ca.sh similarity index 100% rename from packages/plugin/src/generators/preset/files/workspace/docker/dev/ca/create_ca.sh rename to packages/plugin/src/generators/preset/files/workspace/.workspace/docker/dev/ca/create_ca.sh diff --git a/packages/plugin/src/generators/preset/files/workspace/docker/dev/ca/gen_cert.sh b/packages/plugin/src/generators/preset/files/workspace/.workspace/docker/dev/ca/gen_cert.sh similarity index 100% rename from packages/plugin/src/generators/preset/files/workspace/docker/dev/ca/gen_cert.sh rename to packages/plugin/src/generators/preset/files/workspace/.workspace/docker/dev/ca/gen_cert.sh diff --git a/packages/plugin/src/generators/preset/files/workspace/docker-compose-dev.yaml b/packages/plugin/src/generators/preset/files/workspace/.workspace/docker/dev/docker-compose-dev.yaml similarity index 100% rename from packages/plugin/src/generators/preset/files/workspace/docker-compose-dev.yaml rename to packages/plugin/src/generators/preset/files/workspace/.workspace/docker/dev/docker-compose-dev.yaml diff --git a/packages/plugin/src/generators/preset/files/workspace/docker/dev/redis/users.acl b/packages/plugin/src/generators/preset/files/workspace/.workspace/docker/dev/redis/users.acl similarity index 100% rename from packages/plugin/src/generators/preset/files/workspace/docker/dev/redis/users.acl rename to packages/plugin/src/generators/preset/files/workspace/.workspace/docker/dev/redis/users.acl diff --git a/packages/plugin/src/generators/preset/files/workspace/jest.preset.ts__tmpl__ b/packages/plugin/src/generators/preset/files/workspace/.workspace/jest/jest.preset.ts__tmpl__ similarity index 64% rename from packages/plugin/src/generators/preset/files/workspace/jest.preset.ts__tmpl__ rename to packages/plugin/src/generators/preset/files/workspace/.workspace/jest/jest.preset.ts__tmpl__ index 2513bdc..50ceaa6 100644 --- a/packages/plugin/src/generators/preset/files/workspace/jest.preset.ts__tmpl__ +++ b/packages/plugin/src/generators/preset/files/workspace/.workspace/jest/jest.preset.ts__tmpl__ @@ -1,13 +1,19 @@ -import type { JestConfigWithTsJest } from 'ts-jest' -import { pathsToModuleNameMapper } from 'ts-jest' +import type { JestConfigWithTsJest } from 'ts-jest'; +import { pathsToModuleNameMapper } from 'ts-jest'; import * as fs from 'fs'; import * as path from 'path'; -function createJestConfig(projectDir: string): JestConfigWithTsJest { +export interface ProjectMeta { + name: string; + workspaceRootRelative: string; + root: string; +} + +export function defineProjectJestConfig(projectDir: string, project: ProjectMeta): JestConfigWithTsJest { const tsConfig = JSON.parse(fs.readFileSync(`${projectDir}/tsconfig.json`, 'utf-8')); const jestConfig: JestConfigWithTsJest = { extensionsToTreatAsEsm: ['.ts'], - displayName: path.basename(projectDir), + displayName: project.name, resolver: '@nx/jest/plugins/resolver', transform: { '^.+\\.m?[tj]sx?$': ['ts-jest', { tsconfig: `${projectDir}/tsconfig.test.json` }], @@ -18,11 +24,10 @@ function createJestConfig(projectDir: string): JestConfigWithTsJest { testMatch: ["/test/**/*.test.ts"], setupFiles: [], setupFilesAfterEnv: ["jest-expect-message", "/test/config.ts"], - coverageDirectory: "./test/coverage", + coverageDirectory: `${project.workspaceRootRelative}/tmp/coverage/${project.name}`, testEnvironment: "node", transformIgnorePatterns: ["/node_modules/"] - } + }; + return jestConfig; } - -export default createJestConfig; diff --git a/packages/plugin/src/generators/preset/files/workspace/.workspace/storybook/storybook.preset.ts__tmpl__ b/packages/plugin/src/generators/preset/files/workspace/.workspace/storybook/storybook.preset.ts__tmpl__ new file mode 100644 index 0000000..c531057 --- /dev/null +++ b/packages/plugin/src/generators/preset/files/workspace/.workspace/storybook/storybook.preset.ts__tmpl__ @@ -0,0 +1,28 @@ +import { StorybookConfig } from '@storybook/vue3-vite'; + +export function defineProjectStorybookConfig(projectRoot: string): StorybookConfig { + return { + stories: ['../src/**/*.stories.@(ts|tsx)'], + addons: ['@storybook/addon-essentials', '@storybook/addon-interactions'], + + core: { + disableTelemetry: true, + }, + + framework: { + name: '@storybook/vue3-vite', + options: { + + builder: { + viteConfigPath: `${projectRoot}/vite.config.ts`, + }, + }, + }, + + docs: {}, + }; +} + +// To customize your Vite configuration you can use the viteFinal field. +// Check https://storybook.js.org/docs/react/builders/vite#configuration +// and https://nx.dev/recipes/storybook/custom-builder-configs diff --git a/packages/plugin/src/generators/preset/files/workspace/.workspace/vite/assets.ts__tmpl__ b/packages/plugin/src/generators/preset/files/workspace/.workspace/vite/assets.ts__tmpl__ new file mode 100644 index 0000000..a46c7fb --- /dev/null +++ b/packages/plugin/src/generators/preset/files/workspace/.workspace/vite/assets.ts__tmpl__ @@ -0,0 +1,47 @@ +import { PreRenderedAsset } from "rollup"; + +export interface AssetOutputEntry { + output: string; + regex: RegExp; +} + +interface ViteProjectAssetsBuildOptions { + assetsDir: string; + entryFileNames: string; + chunkFileNames: string; + assetFileNames: (info: PreRenderedAsset) => string; +} + +export function defineProjectAssetsBuildOptions(assetTypes?: AssetOutputEntry[]): ViteProjectAssetsBuildOptions { + const assetsDir = "assets"; + assetTypes = assetTypes ?? []; + assetTypes.push(...[ + { + output: `${assetsDir}/img/[name]-[hash][extname]`, + regex: /\.(png|jpe?g|gif|svg|webp|avif)$/ + }, + { + regex: /\.css$/, + output: `${assetsDir}/css/[name]-[hash][extname]` + }, + { + output: `${assetsDir}/js/[name]-[hash][extname]`, + regex: /\.js$/ + } + ]); + return { + assetsDir, + entryFileNames: `${assetsDir}/js/[name]-[hash].js`, + chunkFileNames: `${assetsDir}/js/[name]-[hash]-chunk.js`, + assetFileNames: (info: PreRenderedAsset): string => { + if (info && info.name) { + const name = info.name as string; + const result = assetTypes.find(a => a.regex.test(name)); + if (result) { + return result.output; + } + } + return `${assetsDir}/[name]-[hash][extname]`; + } + }; +} \ No newline at end of file diff --git a/packages/plugin/src/generators/preset/files/workspace/.workspace/vite/vite.preset.ts__tmpl__ b/packages/plugin/src/generators/preset/files/workspace/.workspace/vite/vite.preset.ts__tmpl__ new file mode 100644 index 0000000..6e9609e --- /dev/null +++ b/packages/plugin/src/generators/preset/files/workspace/.workspace/vite/vite.preset.ts__tmpl__ @@ -0,0 +1,185 @@ +/// +import { defineConfig } from 'vite'; +import vue from '@vitejs/plugin-vue'; +import dts from 'vite-plugin-dts'; +import * as path from 'path'; +import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; +import { libInjectCss } from 'vite-plugin-lib-inject-css'; + +import resolvePlugin from '@rollup/plugin-node-resolve'; +import basicSsl from '@vitejs/plugin-basic-ssl'; +import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'; +import { defineProjectAssetsBuildOptions, AssetOutputEntry } from './assets'; + +export interface ProjectMeta { + name: string; + workspaceRootRelative: string; + root: string; +} + +function createViteTestConfig(project: ProjectMeta) { + return { + globals: true, + cache: { + dir: `${project.workspaceRootRelative}/tmp/vitest/${project.name}`, + }, + environment: 'jsdom', + include: ['test/**/*.test.{ts,mts,cts,tsx}'], + + reporters: ['default'], + coverage: { + reportsDirectory: `${project.workspaceRootRelative}/tmp/coverage/${project.name}`, + provider: 'v8', + }, + }; +} + +export interface ProjectViteConfigOptions { + assetTypes?: AssetOutputEntry[]; +} + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface LibProjectViteConfigOptions extends ProjectViteConfigOptions { + +} + +export function defineLibProjectViteConfig(projectDir: string, project: ProjectMeta, options?: LibProjectViteConfigOptions) { + options = options ?? {}; + const assetsConfig = defineProjectAssetsBuildOptions(options.assetTypes); + return defineConfig({ + root: projectDir, + cacheDir: `${project.workspaceRootRelative}/tmp/vite/${project.name}`, + + plugins: [ + vue(), + nxViteTsPaths(), + dts({ + entryRoot: 'src', + tsconfigPath: path.join(projectDir, 'tsconfig.build.json'), + }), + libInjectCss(), + ], + + // Configuration for building your library. + // See: https://vitejs.dev/guide/build.html#library-mode + build: { + outDir: `${project.workspaceRootRelative}/dist/${project.root}`, + emptyOutDir: true, + cssCodeSplit: true, + reportCompressedSize: true, + commonjsOptions: { + transformMixedEsModules: true, + }, + lib: { + // Could also be a dictionary or array of multiple entry points. + entry: 'src/index.ts', + name: project.name, + fileName: 'index', + // Change this to the formats you want to support. + // Don't forget to update your package.json as well. + formats: ['es'], + }, + rollupOptions: { + rollupOptions: { + preserveSymlinks: true, + output: { + preserveModules: false, + entryFileNames: assetsConfig.entryFileNames, + assetFileNames: assetsConfig.assetFileNames, + chunkFileNames: assetsConfig.chunkFileNames + } + }, + // External packages that should not be bundled into your library. + external: [], + }, + }, + + test: createViteTestConfig(project) + }); +} + + +export interface AppProjectViteConfigOptions extends ProjectViteConfigOptions { + server?: { + port?: number, + host?: string; + }, + + preview?: { + port?: number, + host?: string; + }; +} + +export function defineAppProjectViteConfig(projectDir: string, project: ProjectMeta, options?: AppProjectViteConfigOptions) { + options = options ?? {}; + + const assetsConfig = defineProjectAssetsBuildOptions(options?.assetTypes); + return defineConfig({ + root: projectDir, + cacheDir: `${project.workspaceRootRelative}/tmp/vite/${project.name}`, + server: { + port: 20021, + host: 'localhost', + + fs: { + // Allow serving files from one level up to the project root + strict: false, + }, + + ...(options?.server ?? {}) + }, + + preview: { + port: 20022, + host: 'localhost', + ...(options?.preview ?? {}) + }, + + publicDir: path.resolve(projectDir, './public'), + build: { + outDir: `${project.workspaceRootRelative}/dist/${project.root}`, + reportCompressedSize: true, + commonjsOptions: { transformMixedEsModules: true }, + minify: true, + assetsDir: assetsConfig.assetsDir, + // don't inline anything for demo + assetsInlineLimit: 0, + emptyOutDir: true, + rollupOptions: { + preserveSymlinks: true, + output: { + entryFileNames: assetsConfig.entryFileNames, + assetFileNames: assetsConfig.assetFileNames, + chunkFileNames: assetsConfig.chunkFileNames + } + } + }, + + plugins: [ + vue({ + template: { + compilerOptions: { + //isCustomElement: (tag) => /^[A-Z]/.test(tag) + }, + }, + }), + nxViteTsPaths(), + VueI18nPlugin({ + include: [path.resolve(projectDir, './src/*/Asset/Locale/**')], + defaultSFCLang: 'yaml', + allowDynamic: true, + dropMessageCompiler: true, + }), + resolvePlugin(undefined), + basicSsl(), + ], + + // Uncomment this if you are using workers. + // worker: { + // plugins: [ nxViteTsPaths() ], + // }, + + test: createViteTestConfig(project) + }); +} \ No newline at end of file diff --git a/packages/plugin/src/generators/preset/files/workspace/Makefile__tmpl__ b/packages/plugin/src/generators/preset/files/workspace/Makefile__tmpl__ index 377bd5e..1db2e8c 100644 --- a/packages/plugin/src/generators/preset/files/workspace/Makefile__tmpl__ +++ b/packages/plugin/src/generators/preset/files/workspace/Makefile__tmpl__ @@ -2,22 +2,17 @@ export ENV ?= dev export WORKSPACE = <%= workspace.name %> ## PATHS -export BIN_ROOT_PATH = ./bin +export BIN_ROOT_PATH = ./.workspace/bin export UTIL_ROOT_PATH = $(realpath $(BIN_ROOT_PATH)/util) export UTIL_PATH = $(UTIL_ROOT_PATH)/util.sh -#ifndef CI -## dev.env - #include dev.env - #export $(shell sed 's/=.*//' dev.env) -#endif - ## VERSION ifeq "$(ENV)" "dev" export VERSION = dev endif -DC=docker compose -p $(WORKSPACE) +export DOCKER_DIR = .workspace/docker +DC=docker compose -p $(WORKSPACE) --project-directory . # Help target settings INFO = Showing targets for all of ENV(default: dev) @@ -52,7 +47,7 @@ up: chmod 777 ./tmp/docker chmod 640 -R ./docker/ca/certs/db fi - $(DC) -f docker-compose-dev.yaml --env-file ./docker/dev/.env up -d --wait --wait-timeout 5 + $(DC) -f $(DOCKER_DIR)/dev/docker-compose-dev.yaml --env-file $(DOCKER_DIR)/dev/.env up -d --wait --wait-timeout 5 sleep 3 ## Clear testing env @@ -60,5 +55,6 @@ down: $(DC) down -t 2 build_dev_image: - DOCKER_BUILDKIT=1 docker build -t <%= workspace.name %>/dev:latest -f ./docker/app/Dockerfile --target=dev . + DOCKER_BUILDKIT=1 docker build -t <%= workspace.name %>/dev:latest -f $(DOCKER_DIR)/app/Dockerfile --target=dev . + endif \ No newline at end of file diff --git a/packages/plugin/src/generators/preset/generator.ts b/packages/plugin/src/generators/preset/generator.ts index 8bb3ae5..e493657 100644 --- a/packages/plugin/src/generators/preset/generator.ts +++ b/packages/plugin/src/generators/preset/generator.ts @@ -1,6 +1,5 @@ import { Tree, - formatFiles, generateFiles, installPackagesTask } from '@nx/devkit'; @@ -9,7 +8,6 @@ import { HcNxHelper } from '../../util/HcNxHelper'; import { PresetNxJsonGenerator } from './helper/PresetNxJsonGenerator'; import { PresetPackageJsonGenerator } from './helper/PresetPackageJsonGenerator'; import { PresetGeneratorSchema } from './schema'; -import { readFileSync } from 'fs'; export async function presetGenerator( tree: Tree, @@ -30,14 +28,7 @@ export async function presetGenerator( } }; const filesPath = path.join(__dirname, 'files'); - - tree.write('.vscode/extensions.json', readFileSync(path.join(filesPath, 'vscode/extensions.json'))); - tree.write('.vscode/settings.json.template', readFileSync(path.join(filesPath, 'vscode/settings.json'))); - generateFiles(tree, path.join(filesPath, './.husky'), './.husky', templateContext); generateFiles(tree, path.join(filesPath, 'workspace'), './', templateContext); - generateFiles(tree, path.join(filesPath, 'bin'), './bin', templateContext); - - await formatFiles(tree); return () => { installPackagesTask(tree, true, undefined, 'pnpm'); diff --git a/packages/plugin/src/generators/preset/helper/PresetNxJsonGenerator.ts b/packages/plugin/src/generators/preset/helper/PresetNxJsonGenerator.ts index bf28712..1b49cb9 100644 --- a/packages/plugin/src/generators/preset/helper/PresetNxJsonGenerator.ts +++ b/packages/plugin/src/generators/preset/helper/PresetNxJsonGenerator.ts @@ -19,67 +19,8 @@ export class PresetNxJsonGenerator { } }; - o.namedInputs = o.namedInputs ?? {}; - o.namedInputs = { - "default": [ - "{projectRoot}/**/*", - "sharedGlobals" - ], - "sharedGlobals": [], - }; - o.namedInputs.production = [ - "default", - "!{projectRoot}/jest.config.{js,ts,mjs,mts}", - "!{projectRoot}/vite.config.{js,ts,mjs,mts}", - "!{projectRoot}/.eslintrc.json" - ]; - - o.targetDefaults = { - "build": { - "inputs": ["default", "!{projectRoot}/test/**/*"], - "dependsOn": ["^build"], - "cache": true - }, - "lint": { - "inputs": [ - "default", - "{workspaceRoot}/.eslintrc.json", - "{workspaceRoot}/.eslintignore" - ], - "cache": true - }, - "lint-fix": { - "cache": false - }, - "test": { - "inputs": [ - "default", - "^default", - "{workspaceRoot}/jest.preset.js" - ], - "cache": true - }, - "test-watch": { - "inputs": ["default", "^default", "{workspaceRoot}/jest.preset.js"], - "cache": true - }, - "@nx/vite:test": { - "cache": true, - "inputs": [ - "default", - "^default" - ] - }, - "@nx/eslint:lint": { - "inputs": [ - "default", - "{workspaceRoot}/.eslintrc.json", - "{workspaceRoot}/.eslintignore" - ], - "cache": true - } - }; - + o.namedInputs = { ...(o.namedInputs ?? {}), ...this.namedInputs() }; + o.targetDefaults = { ...(o.targetDefaults ?? {}), ...this.targetDefaults() }; o.generators = { "@nx/workspace:move": { "projectNameAndRootFormat": "as-provided" @@ -96,4 +37,179 @@ export class PresetNxJsonGenerator { return o; }); } + + private namedInputs(): Record { + return { + "default": [ + "{projectRoot}/**/*", + "!{projectRoot}/README.md", + "sharedGlobals" + ], + "sharedGlobals": [], + production: [ + "default", + "!{projectRoot}/test/**/*", + "!{projectRoot}/.vite/**/*", + "!{projectRoot}/.storybook/**/*", + "!{projectRoot}/jest.config.{js,ts,mjs,mts}", + "!{projectRoot}/tsconfig.test.json", + "!{projectRoot}/.eslintrc.json" + ] + }; + } + + private targetDefaults(): Record { + return { + "@nx/js:tsc": { + "inputs": ["production", "^production"], + "outputs": ["{options.outputPath}"], + "dependsOn": ["^build", "test"], + "cache": true, + "options": { + "outputPath": "dist/{projectRoot}", + "tsConfig": "{projectRoot}/tsconfig.build.json" + } + }, + + "@nx/jest:jest": { + "cache": true, + "inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"], + "options": { + "jestConfig": "{projectRoot}/jest.config.ts", + "runInBand": true, + "passWithNoTests": true + }, + "configurations": { + "watch": { + "watch": true + }, + "ci": { + "ci": true, + "codeCoverage": true + }, + "updateSnapshot": { + "updateSnapshot": true + }, + "codeCoverage": { + codeCoverage: true, + } + } + }, + "@nx/eslint:lint": { + "inputs": ["default", "{workspaceRoot}/.eslintrc.json", "{workspaceRoot}/.eslintignore"], + "cache": true, + "options": { + "lintFilePatterns": ["{projectRoot}/**/*.ts", "{projectRoot}/package.json"] + }, + "configurations": { + "fix": { + "fix": true, + "cache": false + } + } + }, + ...this.viteTargetsDefaults(), + ...this.storybookTargetsDefaults(), + }; + } + + private viteTargetsDefaults(): Record { + return { + "@nx/vite:build": { + "inputs": ["production", "^production"], + "outputs": ["{options.outputPath}"], + "defaultConfiguration": "production", + "options": { + "outputPath": "dist/{projectRoot}", + "skipTypeCheck": true, + "configFile": "{projectRoot}/vite.config.ts", + "tsConfig": "{projectRoot}/tsconfig.build.json", + "generatePackageJson": false + }, + "configurations": { + "development": { + "mode": "development" + }, + "production": { + "mode": "production" + } + } + }, + "@nx/vite:preview-server": { + "defaultConfiguration": "development", + "options": { + "buildTarget": "build" + }, + "configurations": { + "development": { + "buildTarget": "build:development" + }, + "production": { + "buildTarget": "build:production" + } + } + }, + "@nx/vite:test": { + "cache": true, + "inputs": ["default", "^default"], + "options": { + "configFile": "{projectRoot}/vite.config.ts", + "passWithNoTests": true, + "reportsDirectory": "../../../coverage/{projectRoot}" + }, + "configurations": { + "watch": { + "watch": true + } + } + }, + }; + } + + private storybookTargetsDefaults(): Record { + return { + "@nx/storybook:storybook": { + "options": { + "port": 4400, + "configDir": "libs/front/mao1/.storybook" + }, + "configurations": { + "ci": { + "quiet": true + } + } + }, + "@nx/storybook:build": { + "outputs": ["{options.outputDir}"], + "options": { + "outputDir": "dist/storybook/{projectRoot}", + "configDir": "{projectRoot}/.storybook" + }, + "configurations": { + "ci": { + "quiet": true + } + } + }, + "storybook-test": { + "executor": "nx:run-commands", + "options": { + "command": "test-storybook -c {projectRoot}/.storybook --url=http://localhost:4400" + } + }, + "storybook-static": { + "executor": "@nx/web:file-server", + "options": { + "buildTarget": "storybook-build", + "staticFilePath": "dist/storybook/{projectRoot}", + "spa": true + }, + "configurations": { + "ci": { + "buildTarget": "storybook-build:ci" + } + } + } + }; + } } \ No newline at end of file diff --git a/packages/plugin/src/generators/preset/helper/PresetPackageJsonGenerator.ts b/packages/plugin/src/generators/preset/helper/PresetPackageJsonGenerator.ts index 9d731cb..13f95ca 100644 --- a/packages/plugin/src/generators/preset/helper/PresetPackageJsonGenerator.ts +++ b/packages/plugin/src/generators/preset/helper/PresetPackageJsonGenerator.ts @@ -36,13 +36,13 @@ export class PresetPackageJsonGenerator { } private generateDeps(tree: Tree): void { - const deps = this.createDeps(); - const devDeps = this.createDevDeps(); + const deps = this.deps(); + const devDeps = this.devDeps(); removeDependenciesFromPackageJson(tree, ['@hexancore/nx'], []); addDependenciesToPackageJson(tree, deps, devDeps); } - private createDeps(): Record { + private deps(): Record { const hexancore = { '@hexancore/core': '0.14.*', '@hexancore/common': '0.13.*', @@ -59,39 +59,42 @@ export class PresetPackageJsonGenerator { }; } - private createDevDeps(): Record { + private devDeps(): Record { return { - ...this.createHexancoreDevDeps(), - ...this.createNxDevDeps(), - ...this.createFrontendDevDeps(), - ...this.createJestDevDeps(), - ...this.createEslintDevDeps(), - ...this.createEssentialsDevDeps() + ...this.hexancoreDevDeps(), + ...this.nxDevDeps(), + ...this.frontendDevDeps(), + ...this.jestDevDeps(), + ...this.eslintDevDeps(), + ...this.essentialsDevDeps() }; } - private createNxDevDeps(): Record { + private nxDevDeps(): Record { return { - "@nx/devkit": this.nxVersion, "@nx/esbuild": this.nxVersion, "@nx/eslint-plugin": this.nxVersion, "@nx/jest": this.nxVersion, "@nx/js": this.nxVersion, + "@nx/vite": this.nxVersion, + "@nx/vue": this.nxVersion, "@nx/linter": this.nxVersion, - "@nx/plugin": this.nxVersion, + "@nx/storybook": this.nxVersion, + "@nx/web": this.nxVersion, }; } - private createHexancoreDevDeps(): Record { + private hexancoreDevDeps(): Record { return { "@hexancore/nx": this.hcNxPluginVersion, "@hexancore/mocker": "^1.1.2", }; } - private createFrontendDevDeps(): Record { + private frontendDevDeps(): Record { const vue = { "@vue/eslint-config-typescript": "^11.0.3", + "@vue/eslint-config-prettier": "^7.1.0", "@vue/test-utils": "^2.4.5", "@vue/tsconfig": "^0.4.0", "vue": "^3.4.25", @@ -123,6 +126,8 @@ export class PresetPackageJsonGenerator { "@babel/core": "^7.24.4", "@babel/plugin-transform-modules-commonjs": "^7.24.1", "@babel/preset-env": "^7.24.4", + "vite-plugin-lib-inject-css": "2.1.1", + "vite-plugin-dts": "3.9.1", }; const primevue = { @@ -144,11 +149,25 @@ export class PresetPackageJsonGenerator { ...vueI18n, ...vite, ...primevue, - ...style + ...style, + ...this.storybookDevDeps() }; } - public createEslintDevDeps(): Record { + private storybookDevDeps(): Record { + const storybookVersion = "^8.1.5"; + return { + "@storybook/addon-essentials": storybookVersion, + "@storybook/addon-interactions": storybookVersion, + "@storybook/core-server": storybookVersion, + "@storybook/test": storybookVersion, + "@storybook/vue3": storybookVersion, + "@storybook/vue3-vite": storybookVersion, + "storybook": storybookVersion, + }; + } + + private eslintDevDeps(): Record { return { "eslint": "8.57.0", "eslint-plugin-import": "^2.29.1", @@ -158,7 +177,7 @@ export class PresetPackageJsonGenerator { }; } - public createJestDevDeps(): Record { + private jestDevDeps(): Record { return { "happy-dom": "^14.11.0", "jest": "^29.7.0", @@ -175,7 +194,7 @@ export class PresetPackageJsonGenerator { }; } - public createEssentialsDevDeps(): Record { + public essentialsDevDeps(): Record { return { "tsconfig": "^7.0.0", "typescript": "5.4.5", @@ -185,6 +204,7 @@ export class PresetPackageJsonGenerator { "@types/node": "20.12.12", "@nestjs/testing": "^10.3.8", "husky": "^9.0.11", + "prettier": "3.2.5" }; } } \ No newline at end of file diff --git a/packages/plugin/src/generators/preset/schema.json b/packages/plugin/src/generators/preset/schema.json index 2b6f91c..f54fcd6 100644 --- a/packages/plugin/src/generators/preset/schema.json +++ b/packages/plugin/src/generators/preset/schema.json @@ -1,5 +1,5 @@ { - "$schema": "https://json-schema.org/schema", + "$schema": "https://json-schema.org/draft/2020-12/output/schema", "$id": "Preset", "title": "", "type": "object", diff --git a/packages/plugin/src/generators/project/files/backend/.eslintrc.json__tmpl__ b/packages/plugin/src/generators/project/files/backend/.eslintrc.json__tmpl__ index f03f4b3..b0654a1 100644 --- a/packages/plugin/src/generators/project/files/backend/.eslintrc.json__tmpl__ +++ b/packages/plugin/src/generators/project/files/backend/.eslintrc.json__tmpl__ @@ -1,5 +1,5 @@ { - "extends": ["<%= project.workspaceRootRelative %>.eslintrc.json"], + "extends": ["<%= project.relative.workspaceRoot %>/.eslintrc.json"], "ignorePatterns": ["!**/*"] } diff --git a/packages/plugin/src/generators/project/files/backend/jest.config.ts__tmpl__ b/packages/plugin/src/generators/project/files/backend/jest.config.ts__tmpl__ index f92c2ee..f9bc5c2 100644 --- a/packages/plugin/src/generators/project/files/backend/jest.config.ts__tmpl__ +++ b/packages/plugin/src/generators/project/files/backend/jest.config.ts__tmpl__ @@ -1,5 +1,9 @@ -import createJestConfig from "<%= project.workspaceRootRelative %>jest.preset"; +import { defineProjectJestConfig } from "<%= project.relative.dotWorkspace %>/jest/jest.preset"; -const jestConfig = createJestConfig(__dirname); +const project = { + workspaceRootRelative: '<%= project.relative.workspaceRoot %>', + root: '<%= project.root %>', + name: '<%= project.name %>' +}; -export default jestConfig \ No newline at end of file +export default defineProjectJestConfig(__dirname, project); \ No newline at end of file diff --git a/packages/plugin/src/generators/project/files/backend/tsconfig.build.json__tmpl__ b/packages/plugin/src/generators/project/files/backend/tsconfig.build.json__tmpl__ index 22d9f5b..5c5199a 100644 --- a/packages/plugin/src/generators/project/files/backend/tsconfig.build.json__tmpl__ +++ b/packages/plugin/src/generators/project/files/backend/tsconfig.build.json__tmpl__ @@ -1,7 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "<%= project.workspaceRootRelative %>dist/out-tsc", + "outDir": "<%= project.relative.workspaceRoot %>/dist/out-tsc", "declaration": true }, "include": ["src/**/*.ts"], diff --git a/packages/plugin/src/generators/project/files/backend/tsconfig.json.template b/packages/plugin/src/generators/project/files/backend/tsconfig.json__tmpl__ similarity index 71% rename from packages/plugin/src/generators/project/files/backend/tsconfig.json.template rename to packages/plugin/src/generators/project/files/backend/tsconfig.json__tmpl__ index 7c000b5..48fae1e 100644 --- a/packages/plugin/src/generators/project/files/backend/tsconfig.json.template +++ b/packages/plugin/src/generators/project/files/backend/tsconfig.json__tmpl__ @@ -1,10 +1,14 @@ { - "extends": "<%= project.workspaceRootRelative %>tsconfig.base.json", + "extends": "<%= project.relative.workspaceRoot %>/tsconfig.base.json", "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", "paths": { + <%_ if (project.type === 'library') { _%> "<%= project.importName %>": [ "<%= project.root %>/src/index.ts" ], + <%_ } _%> "@": [ "<%= project.root %>/src" ], diff --git a/packages/plugin/src/generators/project/files/backend/tsconfig.test.json__tmpl__ b/packages/plugin/src/generators/project/files/backend/tsconfig.test.json__tmpl__ index 67a3bf3..4d015f8 100644 --- a/packages/plugin/src/generators/project/files/backend/tsconfig.test.json__tmpl__ +++ b/packages/plugin/src/generators/project/files/backend/tsconfig.test.json__tmpl__ @@ -1,13 +1,13 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "<%= project.workspaceRootRelative %>dist/out-tsc", + "outDir": "<%= project.relative.workspaceRoot %>/dist/out-tsc", "types": ["jest", "node"] }, "files": [ - "<%= project.workspaceRootRelative %>node_modules/jest-expect-message/types/index.d.ts", - "<%= project.workspaceRootRelative %>node_modules/@hexancore/common/lib/cjs/Test/Matchers.d.ts" + "<%= project.relative.workspaceRoot %>/node_modules/jest-expect-message/types/index.d.ts", + "<%= project.relative.workspaceRoot %>/node_modules/@hexancore/common/lib/cjs/Test/Matchers.d.ts" ], "include": [ "src/**/*.ts", diff --git a/packages/plugin/src/generators/project/files/frontend/.storybook/main.ts__tmpl__ b/packages/plugin/src/generators/project/files/frontend/.storybook/main.ts__tmpl__ new file mode 100644 index 0000000..3b7afa8 --- /dev/null +++ b/packages/plugin/src/generators/project/files/frontend/.storybook/main.ts__tmpl__ @@ -0,0 +1,3 @@ +import {defineProjectStorybookConfig} from "<%= project.relative.dotWorkspace %>/storybook/main.preset"; + +export default defineProjectStorybookConfig('<%= project.root %>'); diff --git a/packages/plugin/src/generators/project/files/frontend/.storybook/preview.ts__tmpl__ b/packages/plugin/src/generators/project/files/frontend/.storybook/preview.ts__tmpl__ new file mode 100644 index 0000000..50c10cc --- /dev/null +++ b/packages/plugin/src/generators/project/files/frontend/.storybook/preview.ts__tmpl__ @@ -0,0 +1 @@ +export const tags = ["autodocs"]; \ No newline at end of file diff --git a/packages/plugin/src/generators/project/files/frontend/tsconfig.build.json__tmpl__ b/packages/plugin/src/generators/project/files/frontend/tsconfig.build.json__tmpl__ index 4b12437..0d18747 100644 --- a/packages/plugin/src/generators/project/files/frontend/tsconfig.build.json__tmpl__ +++ b/packages/plugin/src/generators/project/files/frontend/tsconfig.build.json__tmpl__ @@ -4,5 +4,8 @@ "outDir": "../../../dist/out-tsc", "types": ["vite/client"] }, - "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.vue"] + "exclude": [ + "**/*.stories.ts" + ], + "include": ["src/**/*.ts","src/**/*.tsx", "src/**/*.vue"] } diff --git a/packages/plugin/src/generators/project/files/frontend/tsconfig.json__tmpl__ b/packages/plugin/src/generators/project/files/frontend/tsconfig.json__tmpl__ index 1365d7d..ed02c53 100644 --- a/packages/plugin/src/generators/project/files/frontend/tsconfig.json__tmpl__ +++ b/packages/plugin/src/generators/project/files/frontend/tsconfig.json__tmpl__ @@ -13,16 +13,18 @@ "isolatedModules": true, "types": ["vite/client", "vitest", "@intlify/unplugin-vue-i18n/messages"], "noEmit": true, - "lib": ["ESNext", "DOM"], + "lib": ["ES2022", "DOM"], "skipLibCheck": true, "noUnusedLocals": true, "noUnusedParameters": true, "noImplicitReturns": true, "paths": { + <%_ if (project.type === 'library') { _%> "<%= project.importName %>": [ "<%= project.root %>/src/index.ts" ], + <%_ } _%> "@": [ "<%= project.root %>/src" ], @@ -42,6 +44,9 @@ }, { "path": "./tsconfig.test.json" + }, + { + "path": "./tsconfig.storybook.json" } ] } diff --git a/packages/plugin/src/generators/project/files/frontend/tsconfig.storybook.json__tmpl__ b/packages/plugin/src/generators/project/files/frontend/tsconfig.storybook.json__tmpl__ new file mode 100644 index 0000000..4663ed5 --- /dev/null +++ b/packages/plugin/src/generators/project/files/frontend/tsconfig.storybook.json__tmpl__ @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "emitDecoratorMetadata": true + }, + "include": [ + "src/**/*.stories.ts", + "src/**/*.stories.tsx", + ".storybook/*.ts" + ] +} diff --git a/packages/plugin/src/generators/project/files/frontend/tsconfig.test.json__tmpl__ b/packages/plugin/src/generators/project/files/frontend/tsconfig.test.json__tmpl__ index bf01302..c7af05d 100644 --- a/packages/plugin/src/generators/project/files/frontend/tsconfig.test.json__tmpl__ +++ b/packages/plugin/src/generators/project/files/frontend/tsconfig.test.json__tmpl__ @@ -4,5 +4,5 @@ "outDir": "../../../dist/out-tsc", "types": ["vitest/globals", "vitest/importMeta", "vite/client", "node", "vitest"] }, - "include": ["vite.config.ts", "test/**/*.ts"] + "include": ["vite.config.ts", "test/**/*.ts", "test/**/*.tsx"] } diff --git a/packages/plugin/src/util/HcNxProjectHelper.ts b/packages/plugin/src/util/HcNxProjectHelper.ts index cfd8c78..6563325 100644 --- a/packages/plugin/src/util/HcNxProjectHelper.ts +++ b/packages/plugin/src/util/HcNxProjectHelper.ts @@ -27,7 +27,9 @@ export class HcNxProjectHelper { public addApplication(directory: string, type: ApplicationType): ApplicationProjectMeta { const project = this.createProjectMeta(directory, true, type); this.addProjectConfiguration(project); - ProjectPackageJsonGenerator.run(this.tree, { project }); + if (type === 'backend') { + ProjectPackageJsonGenerator.run(this.tree, { project }); + } return project; } @@ -42,10 +44,14 @@ export class HcNxProjectHelper { private createProjectMeta(directory: string, isApp: boolean, type: T): ProjectMeta { const name = HcNxProjectHelper.getProjectNameFromDirectory(directory, isApp); const projectRoot = HcNxProjectHelper.getProjectRoot(directory, isApp); + const relativeWorkspaceRoot = '../'.repeat(projectRoot.split('/').length).slice(0, -1); return { name, root: projectRoot, - workspaceRootRelative: '../'.repeat(projectRoot.split('/').length), + relative: { + workspaceRoot: relativeWorkspaceRoot, + dotWorkspace: relativeWorkspaceRoot + '/.workspace', + }, importName: this.helper.workspacePackageNamespace + '/' + name, type: isApp ? 'application' : 'library', subtype: type @@ -81,13 +87,7 @@ export class HcNxProjectHelper { root: project.root, projectType: project.type, sourceRoot: '{projectRoot}/src', - targets: { - build: this.targetHelper.buildTarget({ main: project.type === 'application' ? 'main.ts' : 'index.ts' }), - lint: this.targetHelper.lintTarget({}), - "lint-fix": this.targetHelper.lintTarget({ fix: true }), - test: this.targetHelper.testTarget({}), - 'test-watch': this.targetHelper.testTarget({ watch: true }), - } + targets: this.targetHelper.targets(project), }); } diff --git a/packages/plugin/src/util/HcNxProjectTargetHelper.ts b/packages/plugin/src/util/HcNxProjectTargetHelper.ts index b8c3f2d..bdaef32 100644 --- a/packages/plugin/src/util/HcNxProjectTargetHelper.ts +++ b/packages/plugin/src/util/HcNxProjectTargetHelper.ts @@ -1,43 +1,94 @@ +import type { ProjectMeta } from "./ProjectMeta"; + +export interface NxTargetMeta { + executor: string, + options?: Record; + configurations?: Record; +} + export class HcNxProjectTargetHelper { - public buildTarget(options: {main: string}) { + public targets(project: ProjectMeta): Record { + const targets = { + lint: this.lint(), + test: this.test(project), + build: this.build(project), + }; + + if (project.subtype === 'frontend' && project.type === 'application') { + targets['preview'] = this.preview(); + } + + if (project.subtype === 'frontend') { + targets['storybook'] = this.storybook(); + targets['storybook-test'] = this.storybookTest(); + targets['storybook-build'] = this.storybookBuild(); + targets['storybook-static'] = this.storybookStatic(); + } + + return targets; + } + public build(project: ProjectMeta): NxTargetMeta { + + if (project.subtype === 'backend' || project.subtype === 'shared') { + return { + "executor": "@nx/js:tsc", + "options": { + "main": `{projectRoot}/src/${project.type === 'application' ? 'main.ts' : 'index.ts'}`, + } + }; + } + return { - "executor": "@nx/js:tsc", - "outputs": [ - "{options.outputPath}" - ], - "options": { - "outputPath": "dist/{projectRoot}", - "main": `{projectRoot}/src/${options.main}`, - "tsConfig": "{projectRoot}/tsconfig.build.json" - } + "executor": "@nx/vite:build" }; } - public lintTarget(options: { fix?: boolean; }) { + public lint(): NxTargetMeta { return { executor: "@nx/eslint:lint", - options: { - lintFilePatterns: [ - "{projectRoot}/**/*.ts", - "{projectRoot}/package.json" - ], - ...options - } }; } - public testTarget(options: { watch?: boolean; }) { + public test(project: ProjectMeta): NxTargetMeta { + if (project.subtype === 'backend' || project.subtype === 'shared') { + return { + executor: "@nx/jest:jest", + }; + } + return { - executor: "@nx/jest:jest", - defaultConfiguration: "test", - options: { - jestConfig: "{projectRoot}/jest.config.ts", - runInBand: true, - passWithNoTests: true, - ...options, - } + "executor": "@nx/vite:test" }; } + public preview(): NxTargetMeta { + return { + "executor": "@nx/vite:preview-server" + }; + } + + public storybook(): NxTargetMeta { + return { + "executor": "@nx/storybook:storybook", + }; + } + + public storybookBuild(): NxTargetMeta { + return { + "executor": "@nx/storybook:build", + }; + } + + public storybookTest(): NxTargetMeta { + return { + "executor": "nx:run-commands", + }; + } + + public storybookStatic(): NxTargetMeta { + return { + "executor": "@nx/web:file-server", + }; + } } \ No newline at end of file diff --git a/packages/plugin/src/util/ProjectMeta.ts b/packages/plugin/src/util/ProjectMeta.ts index c992ce8..2b1cc7c 100644 --- a/packages/plugin/src/util/ProjectMeta.ts +++ b/packages/plugin/src/util/ProjectMeta.ts @@ -5,7 +5,10 @@ import type { LibraryType } from "../generators/library/LibraryType"; export interface ProjectMeta { name: string; root: string; - workspaceRootRelative: string, + relative: { + workspaceRoot: string, + dotWorkspace: string; + }, importName: string; type: ProjectType; subtype: Subtype; diff --git a/packages/plugin/src/util/ProjectPackageJsonGenerator.ts b/packages/plugin/src/util/ProjectPackageJsonGenerator.ts index fd455fc..df9231e 100644 --- a/packages/plugin/src/util/ProjectPackageJsonGenerator.ts +++ b/packages/plugin/src/util/ProjectPackageJsonGenerator.ts @@ -21,20 +21,36 @@ export class ProjectPackageJsonGenerator { - return { - "main": "./src/index.js", - "types": "./src/index.d.ts", - }; + if (this.options.project.type === 'library') { + return { + "main": this.options.project.subtype === 'frontend' ? "./src/index.mjs" : "./src/index.js", + "types": "./src/index.d.ts", + }; + } + + if (this.options.project.type === 'application' && this.options.project.subtype === 'backend') { + return { + "main": "./src/main.js" + }; + } + + return {}; } private generateDeps(): Record { @@ -44,4 +60,10 @@ export class ProjectPackageJsonGenerator { - describe('frontend', () => { - let tree: Tree; - const directory = 'task-manager/api'; - const projectRoot = `apps/${directory}`; +describe('Application Generator: Backend', () => { + let tree: Tree; + const type = 'backend'; + const projectDirectory = `acme/${type}`; + const projectRoot = `apps/${projectDirectory}`; + beforeAll(async () => { + tree = createEmptyNxTree(); + const options: ApplicationGeneratorSchema = { directory: projectDirectory, type }; + await applicationGenerator(tree, options); + }); - beforeAll(async () => { - tree = createTreeWithEmptyWorkspace(); - writeJson(tree, 'package.json', { - name: '@testcompany/source' - }); - const options: ApplicationGeneratorSchema = { directory, type: 'backend' }; - await applicationGenerator(tree, options); - }); + const expectedProjectFilesToMatchSnapshots = expectedFiles(`${projectRoot}/`, [ + 'README.md', + 'project.json', + 'package.json', + '.eslintrc.json', + 'jest.config.ts', + 'tsconfig.json', + 'tsconfig.test.json', + 'tsconfig.build.json', + 'src/main.ts' + ]); - const expectedProjectFilesToMatchSnapshots = [ - 'README.md', - 'project.json', - 'package.json', - '.eslintrc.json', - 'jest.config.ts', - 'tsconfig.json', - 'tsconfig.test.json', - 'tsconfig.build.json', - 'src/main.ts' - ].map(f => `${projectRoot}/` + f); + const expectedWorkspaceFilesToMatchSnapshots = [ + ...expectedProjectFilesToMatchSnapshots, + '.prettierrc', + 'package.json', + 'nx.json', + 'tsconfig.base.json', + ]; - const expectedWorkspaceFilesToMatchSnapshots = [ - 'tsconfig.base.json', - 'nx.json', - 'package.json', - ...expectedProjectFilesToMatchSnapshots - ]; - - test.each(expectedWorkspaceFilesToMatchSnapshots.map(i => [i]))('%s should match snapshot', (filePath) => { - exceptWorkspaceFileMatchSnapshot(tree, filePath); - }); + test.each(expectedWorkspaceFilesToMatchSnapshots.map(i => [i]))('%s should match snapshot', (filePath) => { + exceptWorkspaceFileMatchSnapshot(tree, filePath); + }); - test('only file from list should exist', () => { - const expectedWorkspaceFilesToExists = [ - '.prettierrc', - `${projectRoot}/test/helper/.gitkeep`, - `${projectRoot}/test/config.ts`, - `${projectRoot}/test/unit/sample.test.ts`, - `${projectRoot}/test/integration/.gitkeep`, - ...expectedWorkspaceFilesToMatchSnapshots - ]; - const diff = tree.listChanges().map(c => c.path).filter(x => !expectedWorkspaceFilesToExists.includes(x)); - expect(diff).toEqual([]); - }); + test('only file from list should exist', () => { + const expectedWorkspaceFilesToExists = [ + `${projectRoot}/test/helper/.gitkeep`, + `${projectRoot}/test/config.ts`, + `${projectRoot}/test/unit/sample.test.ts`, + `${projectRoot}/test/integration/.gitkeep`, + ...expectedWorkspaceFilesToMatchSnapshots + ]; + const diff = tree.listChanges().map(c => c.path).filter(x => !expectedWorkspaceFilesToExists.includes(x)); + expect(diff).toEqual([]); }); }); diff --git a/packages/plugin/test/generators/application/FrontendApplicationGenerator.test.ts b/packages/plugin/test/generators/application/FrontendApplicationGenerator.test.ts new file mode 100644 index 0000000..7d1457b --- /dev/null +++ b/packages/plugin/test/generators/application/FrontendApplicationGenerator.test.ts @@ -0,0 +1,85 @@ +import { Tree } from '@nx/devkit'; +import { applicationGenerator } from '../../../src/generators/application/applicationGenerator'; +import type { ApplicationGeneratorSchema } from '../../../src/generators/application/schema'; +import { createEmptyNxTree, exceptWorkspaceFileMatchSnapshot, expectedFiles } from '../../helper/functions'; + +describe('Application Generator: Frontend', () => { + let tree: Tree; + const type = 'frontend'; + const projectDirectory = `acme/${type}`; + const projectRoot = `apps/${projectDirectory}`; + beforeAll(async () => { + tree = createEmptyNxTree(); + const options: ApplicationGeneratorSchema = { directory: projectDirectory, type }; + await applicationGenerator(tree, options); + }); + + const expecteProjectSrcFiles = expectedFiles(`${projectRoot}/src/`, [ + 'constants.ts', + 'Core/Asset/Image/logo.png', + 'Core/Asset/Locale/en.yaml', + 'Core/Asset/Style/colors.module.css', + 'Core/Asset/Style/font.scss', + 'Core/Asset/Style/style.css', + 'Core/Asset/Style/theme.css', + 'Core/Asset/Style/theme.dark.css', + 'Core/Asset/Style/theme.light.css', + 'Core/Asset/Style/tokens.css', + 'Core/Asset/Style/typography.module.css', + 'Core/Asset/Style/variables.scss', + 'Core/Component/Layout/AppLayout.vue', + 'Core/Component/Misc/AppLogo.vue', + 'Core/Component/View/App.vue', + 'Core/Component/View/CoreRoutes.ts', + 'Core/Component/View/Dashboard.vue', + 'Core/Component/View/Error/404.vue', + 'Core/Service/Plugin/I18NCorePlugin.ts', + 'Core/Service/Plugin/PiniaCorePlugin.ts', + 'Core/Service/Plugin/PrimeVueCorePlugin.ts', + 'Core/Service/Router/Router.ts', + 'env.d.ts', + 'shims-vue.d.ts' + ]); + + const expectedProjectFilesToMatchSnapshots = expectedFiles(`${projectRoot}/`, [ + 'README.md', + 'project.json', + '.eslintrc.json', + 'tsconfig.json', + 'tsconfig.test.json', + 'tsconfig.build.json', + 'tsconfig.storybook.json', + 'src/main.ts', + '.storybook/main.ts', + '.storybook/preview.ts', + 'vite.config.ts', + '.env.development', + 'index.html' + ]); + + const expectedWorkspaceFilesToMatchSnapshots = [ + ...expectedProjectFilesToMatchSnapshots, + '.prettierrc', + 'package.json', + 'nx.json', + 'tsconfig.base.json', + ]; + + test.each(expectedWorkspaceFilesToMatchSnapshots.map(i => [i]))('%s should match snapshot', (filePath) => { + exceptWorkspaceFileMatchSnapshot(tree, filePath); + }); + + test('only file from list should exist', () => { + const expectedWorkspaceFilesToExists = [ + `${projectRoot}/test/helper/.gitkeep`, + `${projectRoot}/test/config.ts`, + `${projectRoot}/test/unit/sample.test.ts`, + `${projectRoot}/test/integration/.gitkeep`, + ...expectedWorkspaceFilesToMatchSnapshots, + ...expecteProjectSrcFiles, + `${projectRoot}/public/favicon.ico`, + ]; + const diff = tree.listChanges().map(c => c.path).filter(x => !expectedWorkspaceFilesToExists.includes(x)); + expect(diff).toEqual([]); + }); +}); diff --git a/packages/plugin/test/generators/application/__snapshots__/BackendApplicationGenerator.test.ts.snap b/packages/plugin/test/generators/application/__snapshots__/BackendApplicationGenerator.test.ts.snap index 8f7fdd0..02f12a1 100644 --- a/packages/plugin/test/generators/application/__snapshots__/BackendApplicationGenerator.test.ts.snap +++ b/packages/plugin/test/generators/application/__snapshots__/BackendApplicationGenerator.test.ts.snap @@ -1,6 +1,8 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Application Generator frontend apps/task-manager/api/.eslintrc.json should match snapshot 1`] = ` +exports[`Application Generator: Backend .prettierrc should match snapshot 1`] = `"{"singleQuote":true}"`; + +exports[`Application Generator: Backend apps/acme/backend/.eslintrc.json should match snapshot 1`] = ` "{ "extends": ["../../../.eslintrc.json"], "ignorePatterns": ["!**/*"] @@ -9,95 +11,54 @@ exports[`Application Generator frontend apps/task-manager/api/.eslintrc.json sho " `; -exports[`Application Generator frontend apps/task-manager/api/README.md should match snapshot 1`] = ` -"# app-task-manager-api - -## Building - -Run \`nx build app-task-manager-api\` to build the application. +exports[`Application Generator: Backend apps/acme/backend/README.md should match snapshot 1`] = ` +"# app-acme-backend -## Running tests - -Run \`nx test app-task-manager-api\` to execute the tests. " `; -exports[`Application Generator frontend apps/task-manager/api/jest.config.ts should match snapshot 1`] = ` -"import createJestConfig from "../../../jest.preset"; +exports[`Application Generator: Backend apps/acme/backend/jest.config.ts should match snapshot 1`] = ` +"import { defineProjectJestConfig } from "../../../.workspace/jest/jest.preset"; -const jestConfig = createJestConfig(__dirname); +const project = { + workspaceRootRelative: '../../..', + root: 'apps/acme/backend', + name: 'app-acme-backend' +}; -export default jestConfig" +export default defineProjectJestConfig(__dirname, project);" `; -exports[`Application Generator frontend apps/task-manager/api/package.json should match snapshot 1`] = ` +exports[`Application Generator: Backend apps/acme/backend/package.json should match snapshot 1`] = ` "{ - "name": "@testcompany/app-task-manager-api", + "name": "@testcompany/app-acme-backend", "type": "commonjs", "private": true, "dependencies": { "tslib": "2.6.2" }, - "main": "./src/index.js", - "types": "./src/index.d.ts" + "main": "./src/main.js" } " `; -exports[`Application Generator frontend apps/task-manager/api/project.json should match snapshot 1`] = ` +exports[`Application Generator: Backend apps/acme/backend/project.json should match snapshot 1`] = ` "{ - "name": "app-task-manager-api", + "name": "app-acme-backend", "$schema": "../../../node_modules/nx/schemas/project-schema.json", "projectType": "application", "sourceRoot": "{projectRoot}/src", "targets": { - "build": { - "executor": "@nx/js:tsc", - "outputs": [ - "{options.outputPath}" - ], - "options": { - "outputPath": "dist/{projectRoot}", - "main": "{projectRoot}/src/main.ts", - "tsConfig": "{projectRoot}/tsconfig.build.json" - } - }, "lint": { - "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "{projectRoot}/**/*.ts", - "{projectRoot}/package.json" - ] - } - }, - "lint-fix": { - "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "{projectRoot}/**/*.ts", - "{projectRoot}/package.json" - ], - "fix": true - } + "executor": "@nx/eslint:lint" }, "test": { - "executor": "@nx/jest:jest", - "defaultConfiguration": "test", - "options": { - "jestConfig": "{projectRoot}/jest.config.ts", - "runInBand": true, - "passWithNoTests": true - } + "executor": "@nx/jest:jest" }, - "test-watch": { - "executor": "@nx/jest:jest", - "defaultConfiguration": "test", + "build": { + "executor": "@nx/js:tsc", "options": { - "jestConfig": "{projectRoot}/jest.config.ts", - "runInBand": true, - "passWithNoTests": true, - "watch": true + "main": "{projectRoot}/src/main.ts" } } } @@ -105,9 +66,9 @@ exports[`Application Generator frontend apps/task-manager/api/project.json shoul " `; -exports[`Application Generator frontend apps/task-manager/api/src/main.ts should match snapshot 1`] = `"export const EXAMPLE = 1;"`; +exports[`Application Generator: Backend apps/acme/backend/src/main.ts should match snapshot 1`] = `"export const EXAMPLE = 1;"`; -exports[`Application Generator frontend apps/task-manager/api/tsconfig.build.json should match snapshot 1`] = ` +exports[`Application Generator: Backend apps/acme/backend/tsconfig.build.json should match snapshot 1`] = ` "{ "extends": "./tsconfig.json", "compilerOptions": { @@ -120,22 +81,21 @@ exports[`Application Generator frontend apps/task-manager/api/tsconfig.build.jso " `; -exports[`Application Generator frontend apps/task-manager/api/tsconfig.json should match snapshot 1`] = ` +exports[`Application Generator: Backend apps/acme/backend/tsconfig.json should match snapshot 1`] = ` "{ "extends": "../../../tsconfig.base.json", "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", "paths": { - "@testcompany/app-task-manager-api": [ - "apps/task-manager/api/src/index.ts" - ], "@": [ - "apps/task-manager/api/src" + "apps/acme/backend/src" ], "@/*": [ - "apps/task-manager/api/src/*" + "apps/acme/backend/src/*" ], "@test/*": [ - "apps/task-manager/api/test/helper/*" + "apps/acme/backend/test/helper/*" ] } }, @@ -152,7 +112,7 @@ exports[`Application Generator frontend apps/task-manager/api/tsconfig.json shou }" `; -exports[`Application Generator frontend apps/task-manager/api/tsconfig.test.json should match snapshot 1`] = ` +exports[`Application Generator: Backend apps/acme/backend/tsconfig.test.json should match snapshot 1`] = ` "{ "extends": "./tsconfig.json", "compilerOptions": { @@ -172,13 +132,13 @@ exports[`Application Generator frontend apps/task-manager/api/tsconfig.test.json " `; -exports[`Application Generator frontend nx.json should match snapshot 1`] = `"{"affected":{"defaultBase":"main"},"targetDefaults":{"build":{"cache":true},"lint":{"cache":true}}}"`; +exports[`Application Generator: Backend nx.json should match snapshot 1`] = `"{"affected":{"defaultBase":"main"},"targetDefaults":{"build":{"cache":true},"lint":{"cache":true}}}"`; -exports[`Application Generator frontend package.json should match snapshot 1`] = ` +exports[`Application Generator: Backend package.json should match snapshot 1`] = ` "{ "name": "@testcompany/source" } " `; -exports[`Application Generator frontend tsconfig.base.json should match snapshot 1`] = `"{"compilerOptions":{"paths":{}}}"`; +exports[`Application Generator: Backend tsconfig.base.json should match snapshot 1`] = `"{"compilerOptions":{"paths":{}}}"`; diff --git a/packages/plugin/test/generators/application/__snapshots__/FrontendApplicationGenerator.test.ts.snap b/packages/plugin/test/generators/application/__snapshots__/FrontendApplicationGenerator.test.ts.snap new file mode 100644 index 0000000..80176bf --- /dev/null +++ b/packages/plugin/test/generators/application/__snapshots__/FrontendApplicationGenerator.test.ts.snap @@ -0,0 +1,240 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Application Generator: Frontend .prettierrc should match snapshot 1`] = `"{"singleQuote":true}"`; + +exports[`Application Generator: Frontend apps/acme/frontend/.env.development should match snapshot 1`] = ` +"VITE_APP_API_URL=http://localhost:25021 +" +`; + +exports[`Application Generator: Frontend apps/acme/frontend/.eslintrc.json should match snapshot 1`] = ` +"{ + "extends": [ + "plugin:vue/vue3-essential", + "eslint:recommended", + "@vue/eslint-config-typescript", + "@vue/eslint-config-prettier/skip-formatting", + "../../../.eslintrc.json" + ], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx", "*.vue"], + "rules": { + "vue/multi-word-component-names": "off" + } + } + ] +} +" +`; + +exports[`Application Generator: Frontend apps/acme/frontend/.storybook/main.ts should match snapshot 1`] = ` +"import {defineProjectStorybookConfig} from "../../../.workspace/storybook/main.preset"; + +export default defineProjectStorybookConfig('apps/acme/frontend'); +" +`; + +exports[`Application Generator: Frontend apps/acme/frontend/.storybook/preview.ts should match snapshot 1`] = `"export const tags = ["autodocs"];"`; + +exports[`Application Generator: Frontend apps/acme/frontend/README.md should match snapshot 1`] = ` +"# app-acme-frontend + +" +`; + +exports[`Application Generator: Frontend apps/acme/frontend/index.html should match snapshot 1`] = ` +" + + + + + + app-pmt-web + + +
+ + + + +" +`; + +exports[`Application Generator: Frontend apps/acme/frontend/project.json should match snapshot 1`] = ` +"{ + "name": "app-acme-frontend", + "$schema": "../../../node_modules/nx/schemas/project-schema.json", + "projectType": "application", + "sourceRoot": "{projectRoot}/src", + "targets": { + "lint": { + "executor": "@nx/eslint:lint" + }, + "test": { + "executor": "@nx/vite:test" + }, + "build": { + "executor": "@nx/vite:build" + }, + "preview": { + "executor": "@nx/vite:preview-server" + }, + "storybook": { + "executor": "@nx/storybook:storybook" + }, + "storybook-test": { + "executor": "nx:run-commands" + }, + "storybook-build": { + "executor": "@nx/storybook:build" + }, + "storybook-static": { + "executor": "@nx/web:file-server" + } + } +} +" +`; + +exports[`Application Generator: Frontend apps/acme/frontend/src/main.ts should match snapshot 1`] = ` +"process = process ?? { env: {} }; + +import { createApp } from 'vue'; +import App from './Core/Component/View/App.vue'; + +import { PrimeVueCorePlugin } from './Core/Service/Plugin/PrimeVueCorePlugin'; +import router from './Core/Service/Router/Router'; +import { I18NCorePlugin } from './Core/Service/Plugin/I18NCorePlugin'; +import { PiniaCorePlugin } from './Core/Service/Plugin/PiniaCorePlugin'; + +const app = createApp(App); + +PrimeVueCorePlugin(app); +I18NCorePlugin(app); +PiniaCorePlugin(app); +app.use(router); + +app.mount('#root'); +" +`; + +exports[`Application Generator: Frontend apps/acme/frontend/tsconfig.build.json should match snapshot 1`] = ` +"{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../../dist/out-tsc", + "types": ["vite/client"] + }, + "exclude": [ + "**/*.stories.ts" + ], + "include": ["src/**/*.ts","src/**/*.tsx", "src/**/*.vue"] +} +" +`; + +exports[`Application Generator: Frontend apps/acme/frontend/tsconfig.json should match snapshot 1`] = ` +"{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "allowJs": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "strict": true, + "jsx": "preserve", + "jsxImportSource": "vue", + "resolveJsonModule": true, + "verbatimModuleSyntax": false, + "useDefineForClassFields": true, + "isolatedModules": true, + "types": ["vite/client", "vitest", "@intlify/unplugin-vue-i18n/messages"], + "noEmit": true, + "lib": ["ES2022", "DOM"], + "skipLibCheck": true, + + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "paths": { + "@": [ + "apps/acme/frontend/src" + ], + "@/*": [ + "apps/acme/frontend/src/*" + ], + "@test/*": [ + "apps/acme/frontend/test/helper/*" + ] + } + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.build.json" + }, + { + "path": "./tsconfig.test.json" + }, + { + "path": "./tsconfig.storybook.json" + } + ] +} +" +`; + +exports[`Application Generator: Frontend apps/acme/frontend/tsconfig.storybook.json should match snapshot 1`] = ` +"{ + "extends": "./tsconfig.json", + "compilerOptions": { + "emitDecoratorMetadata": true + }, + "include": [ + "src/**/*.stories.ts", + "src/**/*.stories.tsx", + ".storybook/*.ts" + ] +} +" +`; + +exports[`Application Generator: Frontend apps/acme/frontend/tsconfig.test.json should match snapshot 1`] = ` +"{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../../dist/out-tsc", + "types": ["vitest/globals", "vitest/importMeta", "vite/client", "node", "vitest"] + }, + "include": ["vite.config.ts", "test/**/*.ts", "test/**/*.tsx"] +} +" +`; + +exports[`Application Generator: Frontend apps/acme/frontend/vite.config.ts should match snapshot 1`] = ` +"import { defineAppProjectViteConfig } from "../../../.workspace/vite/vite.preset"; + +const project = { + workspaceRootRelative: '../../..', + root: 'apps/acme/frontend', + name: 'app-acme-frontend' +}; + +export default defineAppProjectViteConfig(__dirname, project); +" +`; + +exports[`Application Generator: Frontend nx.json should match snapshot 1`] = `"{"affected":{"defaultBase":"main"},"targetDefaults":{"build":{"cache":true},"lint":{"cache":true}}}"`; + +exports[`Application Generator: Frontend package.json should match snapshot 1`] = ` +"{ + "name": "@testcompany/source" +} +" +`; + +exports[`Application Generator: Frontend tsconfig.base.json should match snapshot 1`] = `"{"compilerOptions":{"paths":{}}}"`; diff --git a/packages/plugin/test/generators/library/BackendLibraryGenerator.test.ts b/packages/plugin/test/generators/library/BackendLibraryGenerator.test.ts index 79abde1..5436b32 100644 --- a/packages/plugin/test/generators/library/BackendLibraryGenerator.test.ts +++ b/packages/plugin/test/generators/library/BackendLibraryGenerator.test.ts @@ -7,7 +7,7 @@ import { createEmptyNxTree, exceptOnlyFilesFromListExistInWorkspace, exceptWorks describe('Library Generator: Backend', () => { let tree: Tree; const type = 'backend'; - const projectDirectory = `task-manager/${type}`; + const projectDirectory = `acme/${type}`; const projectRoot = `libs/${projectDirectory}`; beforeAll(async () => { tree = createEmptyNxTree(); diff --git a/packages/plugin/test/generators/library/FrontendLibraryGenerator.test.ts b/packages/plugin/test/generators/library/FrontendLibraryGenerator.test.ts index de7bba6..bd900e6 100644 --- a/packages/plugin/test/generators/library/FrontendLibraryGenerator.test.ts +++ b/packages/plugin/test/generators/library/FrontendLibraryGenerator.test.ts @@ -4,7 +4,7 @@ import { libraryGenerator } from '../../../src/generators/library/libraryGenerat import { LibraryGeneratorSchema } from '../../../src/generators/library/schema'; import { createEmptyNxTree, exceptOnlyFilesFromListExistInWorkspace, exceptWorkspaceFileMatchSnapshot } from '../../helper/functions'; -describe.skip('Library Generator: Frontend', () => { +describe('Library Generator: Frontend', () => { let tree: Tree; const type = 'frontend'; const projectDirectory = `task-manager/${type}`; @@ -24,6 +24,10 @@ describe.skip('Library Generator: Frontend', () => { 'tsconfig.test.json', 'tsconfig.build.json', 'vite.config.ts', + '.storybook/main.ts', + '.storybook/preview.ts', + 'tsconfig.storybook.json', + 'src/vue-shims.d.ts' ].map(f => `${projectRoot}/` + f); const expectedWorkspaceFilesToMatchSnapshots = [ diff --git a/packages/plugin/test/generators/library/__snapshots__/BackendLibraryGenerator.test.ts.snap b/packages/plugin/test/generators/library/__snapshots__/BackendLibraryGenerator.test.ts.snap index 4698530..4e4810d 100644 --- a/packages/plugin/test/generators/library/__snapshots__/BackendLibraryGenerator.test.ts.snap +++ b/packages/plugin/test/generators/library/__snapshots__/BackendLibraryGenerator.test.ts.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Library Generator: Backend libs/task-manager/backend/.eslintrc.json should match snapshot 1`] = ` +exports[`Library Generator: Backend libs/acme/backend/.eslintrc.json should match snapshot 1`] = ` "{ "extends": ["../../../.eslintrc.json"], "ignorePatterns": ["!**/*"] @@ -9,30 +9,28 @@ exports[`Library Generator: Backend libs/task-manager/backend/.eslintrc.json sho " `; -exports[`Library Generator: Backend libs/task-manager/backend/README.md should match snapshot 1`] = ` -"# task-manager-backend +exports[`Library Generator: Backend libs/acme/backend/README.md should match snapshot 1`] = ` +"# acme-backend -## Building -Run \`nx build task-manager-backend\` to build the library. - -## Running tests - -Run \`nx test task-manager-backend\` to execute the tests. " `; -exports[`Library Generator: Backend libs/task-manager/backend/jest.config.ts should match snapshot 1`] = ` -"import createJestConfig from "../../../jest.preset"; +exports[`Library Generator: Backend libs/acme/backend/jest.config.ts should match snapshot 1`] = ` +"import { defineProjectJestConfig } from "../../../.workspace/jest/jest.preset"; -const jestConfig = createJestConfig(__dirname); +const project = { + workspaceRootRelative: '../../..', + root: 'libs/acme/backend', + name: 'acme-backend' +}; -export default jestConfig" +export default defineProjectJestConfig(__dirname, project);" `; -exports[`Library Generator: Backend libs/task-manager/backend/package.json should match snapshot 1`] = ` +exports[`Library Generator: Backend libs/acme/backend/package.json should match snapshot 1`] = ` "{ - "name": "@testcompany/task-manager-backend", + "name": "@testcompany/acme-backend", "type": "commonjs", "private": true, "dependencies": { @@ -44,60 +42,23 @@ exports[`Library Generator: Backend libs/task-manager/backend/package.json shoul " `; -exports[`Library Generator: Backend libs/task-manager/backend/project.json should match snapshot 1`] = ` +exports[`Library Generator: Backend libs/acme/backend/project.json should match snapshot 1`] = ` "{ - "name": "task-manager-backend", + "name": "acme-backend", "$schema": "../../../node_modules/nx/schemas/project-schema.json", "projectType": "library", "sourceRoot": "{projectRoot}/src", "targets": { - "build": { - "executor": "@nx/js:tsc", - "outputs": [ - "{options.outputPath}" - ], - "options": { - "outputPath": "dist/{projectRoot}", - "main": "{projectRoot}/src/index.ts", - "tsConfig": "{projectRoot}/tsconfig.build.json" - } - }, "lint": { - "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "{projectRoot}/**/*.ts", - "{projectRoot}/package.json" - ] - } - }, - "lint-fix": { - "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "{projectRoot}/**/*.ts", - "{projectRoot}/package.json" - ], - "fix": true - } + "executor": "@nx/eslint:lint" }, "test": { - "executor": "@nx/jest:jest", - "defaultConfiguration": "test", - "options": { - "jestConfig": "{projectRoot}/jest.config.ts", - "runInBand": true, - "passWithNoTests": true - } + "executor": "@nx/jest:jest" }, - "test-watch": { - "executor": "@nx/jest:jest", - "defaultConfiguration": "test", + "build": { + "executor": "@nx/js:tsc", "options": { - "jestConfig": "{projectRoot}/jest.config.ts", - "runInBand": true, - "passWithNoTests": true, - "watch": true + "main": "{projectRoot}/src/index.ts" } } } @@ -105,7 +66,7 @@ exports[`Library Generator: Backend libs/task-manager/backend/project.json shoul " `; -exports[`Library Generator: Backend libs/task-manager/backend/tsconfig.build.json should match snapshot 1`] = ` +exports[`Library Generator: Backend libs/acme/backend/tsconfig.build.json should match snapshot 1`] = ` "{ "extends": "./tsconfig.json", "compilerOptions": { @@ -118,22 +79,24 @@ exports[`Library Generator: Backend libs/task-manager/backend/tsconfig.build.jso " `; -exports[`Library Generator: Backend libs/task-manager/backend/tsconfig.json should match snapshot 1`] = ` +exports[`Library Generator: Backend libs/acme/backend/tsconfig.json should match snapshot 1`] = ` "{ "extends": "../../../tsconfig.base.json", "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", "paths": { - "@testcompany/task-manager-backend": [ - "libs/task-manager/backend/src/index.ts" + "@testcompany/acme-backend": [ + "libs/acme/backend/src/index.ts" ], "@": [ - "libs/task-manager/backend/src" + "libs/acme/backend/src" ], "@/*": [ - "libs/task-manager/backend/src/*" + "libs/acme/backend/src/*" ], "@test/*": [ - "libs/task-manager/backend/test/helper/*" + "libs/acme/backend/test/helper/*" ] } }, @@ -150,7 +113,7 @@ exports[`Library Generator: Backend libs/task-manager/backend/tsconfig.json shou }" `; -exports[`Library Generator: Backend libs/task-manager/backend/tsconfig.test.json should match snapshot 1`] = ` +exports[`Library Generator: Backend libs/acme/backend/tsconfig.test.json should match snapshot 1`] = ` "{ "extends": "./tsconfig.json", "compilerOptions": { @@ -183,8 +146,8 @@ exports[`Library Generator: Backend tsconfig.base.json should match snapshot 1`] "{ "compilerOptions": { "paths": { - "@testcompany/task-manager-backend": [ - "libs/task-manager/backend/src/index.ts" + "@testcompany/acme-backend": [ + "libs/acme/backend/src/index.ts" ] } } diff --git a/packages/plugin/test/generators/library/__snapshots__/FrontendLibraryGenerator.test.ts.snap b/packages/plugin/test/generators/library/__snapshots__/FrontendLibraryGenerator.test.ts.snap new file mode 100644 index 0000000..7d05743 --- /dev/null +++ b/packages/plugin/test/generators/library/__snapshots__/FrontendLibraryGenerator.test.ts.snap @@ -0,0 +1,229 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Library Generator: Frontend libs/task-manager/frontend/.eslintrc.json should match snapshot 1`] = ` +"{ + "extends": [ + "plugin:vue/vue3-essential", + "eslint:recommended", + "@vue/eslint-config-typescript", + "@vue/eslint-config-prettier/skip-formatting", + "../../../.eslintrc.json" + ], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx", "*.vue"], + "rules": { + "vue/multi-word-component-names": "off" + } + } + ] +} +" +`; + +exports[`Library Generator: Frontend libs/task-manager/frontend/.storybook/main.ts should match snapshot 1`] = ` +"import {defineProjectStorybookConfig} from "../../../.workspace/storybook/main.preset"; + +export default defineProjectStorybookConfig('libs/task-manager/frontend'); +" +`; + +exports[`Library Generator: Frontend libs/task-manager/frontend/.storybook/preview.ts should match snapshot 1`] = `"export const tags = ["autodocs"];"`; + +exports[`Library Generator: Frontend libs/task-manager/frontend/README.md should match snapshot 1`] = ` +"# task-manager-frontend + + +" +`; + +exports[`Library Generator: Frontend libs/task-manager/frontend/package.json should match snapshot 1`] = ` +"{ + "name": "@testcompany/task-manager-frontend", + "type": "commonjs", + "private": true, + "dependencies": { + "tslib": "2.6.2" + }, + "main": "./src/index.mjs", + "types": "./src/index.d.ts", + "sideEffects": [ + "**/*.css" + ] +} +" +`; + +exports[`Library Generator: Frontend libs/task-manager/frontend/project.json should match snapshot 1`] = ` +"{ + "name": "task-manager-frontend", + "$schema": "../../../node_modules/nx/schemas/project-schema.json", + "projectType": "library", + "sourceRoot": "{projectRoot}/src", + "targets": { + "lint": { + "executor": "@nx/eslint:lint" + }, + "test": { + "executor": "@nx/vite:test" + }, + "build": { + "executor": "@nx/vite:build" + }, + "storybook": { + "executor": "@nx/storybook:storybook" + }, + "storybook-test": { + "executor": "nx:run-commands" + }, + "storybook-build": { + "executor": "@nx/storybook:build" + }, + "storybook-static": { + "executor": "@nx/web:file-server" + } + } +} +" +`; + +exports[`Library Generator: Frontend libs/task-manager/frontend/src/vue-shims.d.ts should match snapshot 1`] = ` +"declare module '*.vue' { + import { defineComponent } from 'vue'; + const component: ReturnType; + export default component; +} +" +`; + +exports[`Library Generator: Frontend libs/task-manager/frontend/tsconfig.build.json should match snapshot 1`] = ` +"{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../../dist/out-tsc", + "types": ["vite/client"] + }, + "exclude": [ + "**/*.stories.ts" + ], + "include": ["src/**/*.ts","src/**/*.tsx", "src/**/*.vue"] +} +" +`; + +exports[`Library Generator: Frontend libs/task-manager/frontend/tsconfig.json should match snapshot 1`] = ` +"{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "allowJs": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "strict": true, + "jsx": "preserve", + "jsxImportSource": "vue", + "resolveJsonModule": true, + "verbatimModuleSyntax": false, + "useDefineForClassFields": true, + "isolatedModules": true, + "types": ["vite/client", "vitest", "@intlify/unplugin-vue-i18n/messages"], + "noEmit": true, + "lib": ["ES2022", "DOM"], + "skipLibCheck": true, + + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "paths": { + "@testcompany/task-manager-frontend": [ + "libs/task-manager/frontend/src/index.ts" + ], + "@": [ + "libs/task-manager/frontend/src" + ], + "@/*": [ + "libs/task-manager/frontend/src/*" + ], + "@test/*": [ + "libs/task-manager/frontend/test/helper/*" + ] + } + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.build.json" + }, + { + "path": "./tsconfig.test.json" + }, + { + "path": "./tsconfig.storybook.json" + } + ] +} +" +`; + +exports[`Library Generator: Frontend libs/task-manager/frontend/tsconfig.storybook.json should match snapshot 1`] = ` +"{ + "extends": "./tsconfig.json", + "compilerOptions": { + "emitDecoratorMetadata": true + }, + "include": [ + "src/**/*.stories.ts", + "src/**/*.stories.tsx", + ".storybook/*.ts" + ] +} +" +`; + +exports[`Library Generator: Frontend libs/task-manager/frontend/tsconfig.test.json should match snapshot 1`] = ` +"{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../../dist/out-tsc", + "types": ["vitest/globals", "vitest/importMeta", "vite/client", "node", "vitest"] + }, + "include": ["vite.config.ts", "test/**/*.ts", "test/**/*.tsx"] +} +" +`; + +exports[`Library Generator: Frontend libs/task-manager/frontend/vite.config.ts should match snapshot 1`] = ` +"import { defineLibProjectViteConfig } from "../../../.workspace/vite/vite.preset"; + +const project = { + workspaceRootRelative: '../../..', + root: 'libs/task-manager/frontend', + name: 'task-manager-frontend' +}; + +export default defineLibProjectViteConfig(__dirname, project); +" +`; + +exports[`Library Generator: Frontend nx.json should match snapshot 1`] = `"{"affected":{"defaultBase":"main"},"targetDefaults":{"build":{"cache":true},"lint":{"cache":true}}}"`; + +exports[`Library Generator: Frontend package.json should match snapshot 1`] = ` +"{ + "name": "@testcompany/source" +} +" +`; + +exports[`Library Generator: Frontend tsconfig.base.json should match snapshot 1`] = ` +"{ + "compilerOptions": { + "paths": { + "@testcompany/task-manager-frontend": [ + "libs/task-manager/frontend/src/index.ts" + ] + } + } +} +" +`; diff --git a/packages/plugin/test/generators/library/__snapshots__/SharedLibraryGenerator.test.ts.snap b/packages/plugin/test/generators/library/__snapshots__/SharedLibraryGenerator.test.ts.snap index 1b65134..6247de0 100644 --- a/packages/plugin/test/generators/library/__snapshots__/SharedLibraryGenerator.test.ts.snap +++ b/packages/plugin/test/generators/library/__snapshots__/SharedLibraryGenerator.test.ts.snap @@ -12,22 +12,19 @@ exports[`Library Generator: Shared libs/task-manager/shared/.eslintrc.json shoul exports[`Library Generator: Shared libs/task-manager/shared/README.md should match snapshot 1`] = ` "# task-manager-shared -## Building - -Run \`nx build task-manager-shared\` to build the library. - -## Running tests - -Run \`nx test task-manager-shared\` to execute the tests. " `; exports[`Library Generator: Shared libs/task-manager/shared/jest.config.ts should match snapshot 1`] = ` -"import createJestConfig from "../../../jest.preset"; +"import { defineProjectJestConfig } from "../../../.workspace/jest/jest.preset"; -const jestConfig = createJestConfig(__dirname); +const project = { + workspaceRootRelative: '../../..', + root: 'libs/task-manager/shared', + name: 'task-manager-shared' +}; -export default jestConfig" +export default defineProjectJestConfig(__dirname, project);" `; exports[`Library Generator: Shared libs/task-manager/shared/package.json should match snapshot 1`] = ` @@ -51,53 +48,16 @@ exports[`Library Generator: Shared libs/task-manager/shared/project.json should "projectType": "library", "sourceRoot": "{projectRoot}/src", "targets": { - "build": { - "executor": "@nx/js:tsc", - "outputs": [ - "{options.outputPath}" - ], - "options": { - "outputPath": "dist/{projectRoot}", - "main": "{projectRoot}/src/index.ts", - "tsConfig": "{projectRoot}/tsconfig.build.json" - } - }, "lint": { - "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "{projectRoot}/**/*.ts", - "{projectRoot}/package.json" - ] - } - }, - "lint-fix": { - "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "{projectRoot}/**/*.ts", - "{projectRoot}/package.json" - ], - "fix": true - } + "executor": "@nx/eslint:lint" }, "test": { - "executor": "@nx/jest:jest", - "defaultConfiguration": "test", - "options": { - "jestConfig": "{projectRoot}/jest.config.ts", - "runInBand": true, - "passWithNoTests": true - } + "executor": "@nx/jest:jest" }, - "test-watch": { - "executor": "@nx/jest:jest", - "defaultConfiguration": "test", + "build": { + "executor": "@nx/js:tsc", "options": { - "jestConfig": "{projectRoot}/jest.config.ts", - "runInBand": true, - "passWithNoTests": true, - "watch": true + "main": "{projectRoot}/src/index.ts" } } } diff --git a/packages/plugin/test/generators/preset/__snapshots__/generator.test.ts.snap b/packages/plugin/test/generators/preset/__snapshots__/generator.test.ts.snap index e76e89c..2870832 100644 --- a/packages/plugin/test/generators/preset/__snapshots__/generator.test.ts.snap +++ b/packages/plugin/test/generators/preset/__snapshots__/generator.test.ts.snap @@ -26,6 +26,450 @@ auto-install-peers=true " `; +exports[`preset generator .workspace/docker/app/Dockerfile should match snapshot 1`] = ` +"# pnpm https://github.com/moby/moby/issues/40449#issuecomment-1758956399 +ARG NODE_IMAGE=node:22-alpine3.18 +ARG PM2_VERSION=5.3.1 +ARG USER_UID=1000 + +FROM "$NODE_IMAGE" as deps + +ENV NODE_ENV=production +ENV PNPM_HOME="/app/.pnpm-store" +ENV PATH="$PNPM_HOME:$PATH" + +RUN mkdir -p /app/.pnpm-store && chown -R node:node /app && chmod -R 777 /app && corepack enable && pnpm config set store-dir "$PNPM_HOME" + +USER node +WORKDIR /app + +COPY --chown=node:node ./pnpm-lock.yaml ./ +RUN --mount=type=cache,target=/app/.pnpm-store,uid=\${USER_UID},gid=\${USER_UID} pnpm fetch --prod --ignore-scripts + +COPY --chown=node:node ./pnpm-lock.yaml ./package.json ./prod/ +RUN --mount=type=cache,ro,target=/app/.pnpm-store,uid=\${USER_UID},gid=\${USER_UID} cd prod && pnpm install --prod --offline --frozen-lockfile --ignore-scripts + +########################## +# DEV container tool stage +FROM deps as dev +RUN --mount=type=cache,target=/app/.pnpm-store,uid=\${USER_UID},gid=\${USER_UID} pnpm fetch --dev --ignore-scripts + +COPY --chown=node:node ./package.json ./ +RUN --mount=type=cache,ro,target=/app/.pnpm-store,uid=\${USER_UID},gid=\${USER_UID} pnpm install --prod=false --offline --frozen-lockfile --ignore-scripts + +EXPOSE 3000 + +CMD ["sleep", "1000"] + +####################### +# API application stage +FROM $NODE_IMAGE as app_api +ARG APP_ID + +RUN mkdir /app && chown node:node /app && chmod 770 /app && npm i -g pm2@\${PM2_VERSION} +WORKDIR /app + +RUN --mount=type=bind,from=deps,source=/app,target=/tmp/deps cp -R -p /tmp/deps/prod/* ./ + +COPY --chown=node:node ./dist/apps/\${APP_ID} ./apps/\${APP_ID} +COPY --chown=node:node ./dist/libs ./libs +COPY --chown=node:node ./docker/app/pm2.config.cjs ./pm2.config.cjs + +USER node +ENV NODE_ENV=production +EXPOSE 3000 +RUN ln -s apps/\${APP_ID}/src/index.js entrypoint + +CMD ["pm2-runtime", "--json", "pm2.config.cjs"] +" +`; + +exports[`preset generator .workspace/docker/app/pm2.config.cjs should match snapshot 1`] = ` +"var fs = require('fs'); +const configPath = process.env["PM2_CONFIG_PATH"] ?? './config/pm2.config.json'; +const config = JSON.parse(fs.readFileSync(configPath, { encoding: 'utf8' })); +module.exports = { + apps: [ + { + script: './entrypoint', + ...config, + }, + ], +}; +" +`; + +exports[`preset generator .workspace/docker/dev/.env should match snapshot 1`] = ` +"WORKSPACE=test-workspace + +HOST_DATA_DIR=./tmp/docker +HOST_CONFIG_DIR=./docker/dev +HOST_CA_DIR=./docker/dev/ca +HOST_CERTS_DIR=./docker/dev/ca/certs +HOST_CA_CRT=./docker/dev/ca/ca.crt + +# SERVICES + +# Redis +REDIS_HOST_PORT=25010 +REDIS_PASSWORD=testredis + +# DB +DB_HOST_PORT=25011 + +" +`; + +exports[`preset generator .workspace/docker/dev/docker-compose-dev.yaml should match snapshot 1`] = ` +"version: '3.6' +services: + redis: + image: bitnami/redis:7.2 + container_name: \${PROJECT}-redis + restart: always + environment: + - ALLOW_EMPTY_PASSWORD=no + - REDIS_AOF_ENABLED=no + - REDIS_PASSWORD=\${REDIS_PASSWORD} + - REDIS_ACLFILE=/bitnami/redis/config/users.acl + ports: + - \${REDIS_HOST_PORT}:6379 + volumes: + - \${HOST_CONFIG_DIR}/redis:/bitnami/redis/config + tmpfs: + - /bitnami/redis/data:size=64M + db: + image: bitnami/postgresql:16.2.0 + container_name: \${PROJECT}-db + restart: always + environment: + - POSTGRESQL_POSTGRES_PASSWORD=testroot + - POSTGRESQL_DATABASE=\${PROJECT} + - POSTGRESQL_USERNAME=\${PROJECT} + - POSTGRESQL_PASSWORD=test + - POSTGRESQL_ENABLE_TLS=yes + - POSTGRESQL_TLS_CERT_FILE=/opt/bitnami/postgresql/certs/db.crt + - POSTGRESQL_TLS_KEY_FILE=/opt/bitnami/postgresql/certs/db.key + - POSTGRESQL_TLS_CA_FILE=/opt/bitnami/postgresql/certs/ca.crt + volumes: + - \${HOST_CERTS_DIR}/db/db.crt:/opt/bitnami/postgresql/certs/db.crt + - \${HOST_CERTS_DIR}/db/db.key:/opt/bitnami/postgresql/certs/db.key + - \${HOST_CA_CRT}:/opt/bitnami/postgresql/certs/ca.crt + mem_limit: 512M + tmpfs: + - /tmp:size=256M + ports: + - \${DB_HOST_PORT}:5432 +" +`; + +exports[`preset generator .workspace/jest/jest.preset.ts should match snapshot 1`] = ` +"import type { JestConfigWithTsJest } from 'ts-jest'; +import { pathsToModuleNameMapper } from 'ts-jest'; +import * as fs from 'fs'; +import * as path from 'path'; + +export interface ProjectMeta { + name: string; + workspaceRootRelative: string; + root: string; +} + +export function defineProjectJestConfig(projectDir: string, project: ProjectMeta): JestConfigWithTsJest { + const tsConfig = JSON.parse(fs.readFileSync(\`\${projectDir}/tsconfig.json\`, 'utf-8')); + const jestConfig: JestConfigWithTsJest = { + extensionsToTreatAsEsm: ['.ts'], + displayName: project.name, + resolver: '@nx/jest/plugins/resolver', + transform: { + '^.+\\\\.m?[tj]sx?$': ['ts-jest', { tsconfig: \`\${projectDir}/tsconfig.test.json\` }], + }, + runner: "groups", + moduleFileExtensions: ["js", "json", "ts"], + moduleNameMapper: pathsToModuleNameMapper(tsConfig.compilerOptions.paths), + testMatch: ["/test/**/*.test.ts"], + setupFiles: [], + setupFilesAfterEnv: ["jest-expect-message", "/test/config.ts"], + coverageDirectory: \`\${project.workspaceRootRelative}/tmp/coverage/\${project.name}\`, + testEnvironment: "node", + transformIgnorePatterns: ["/node_modules/"] + }; + + return jestConfig; +} +" +`; + +exports[`preset generator .workspace/storybook/storybook.preset.ts should match snapshot 1`] = ` +"import { StorybookConfig } from '@storybook/vue3-vite'; + +export function defineProjectStorybookConfig(projectRoot: string): StorybookConfig { + return { + stories: ['../src/**/*.stories.@(ts|tsx)'], + addons: ['@storybook/addon-essentials', '@storybook/addon-interactions'], + + core: { + disableTelemetry: true, + }, + + framework: { + name: '@storybook/vue3-vite', + options: { + + builder: { + viteConfigPath: \`\${projectRoot}/vite.config.ts\`, + }, + }, + }, + + docs: {}, + }; +} + +// To customize your Vite configuration you can use the viteFinal field. +// Check https://storybook.js.org/docs/react/builders/vite#configuration +// and https://nx.dev/recipes/storybook/custom-builder-configs +" +`; + +exports[`preset generator .workspace/vite/assets.ts should match snapshot 1`] = ` +"import { PreRenderedAsset } from "rollup"; + +export interface AssetOutputEntry { + output: string; + regex: RegExp; +} + +interface ViteProjectAssetsBuildOptions { + assetsDir: string; + entryFileNames: string; + chunkFileNames: string; + assetFileNames: (info: PreRenderedAsset) => string; +} + +export function defineProjectAssetsBuildOptions(assetTypes?: AssetOutputEntry[]): ViteProjectAssetsBuildOptions { + const assetsDir = "assets"; + assetTypes = assetTypes ?? []; + assetTypes.push(...[ + { + output: \`\${assetsDir}/img/[name]-[hash][extname]\`, + regex: /\\.(png|jpe?g|gif|svg|webp|avif)$/ + }, + { + regex: /\\.css$/, + output: \`\${assetsDir}/css/[name]-[hash][extname]\` + }, + { + output: \`\${assetsDir}/js/[name]-[hash][extname]\`, + regex: /\\.js$/ + } + ]); + return { + assetsDir, + entryFileNames: \`\${assetsDir}/js/[name]-[hash].js\`, + chunkFileNames: \`\${assetsDir}/js/[name]-[hash]-chunk.js\`, + assetFileNames: (info: PreRenderedAsset): string => { + if (info && info.name) { + const name = info.name as string; + const result = assetTypes.find(a => a.regex.test(name)); + if (result) { + return result.output; + } + } + return \`\${assetsDir}/[name]-[hash][extname]\`; + } + }; +}" +`; + +exports[`preset generator .workspace/vite/vite.preset.ts should match snapshot 1`] = ` +"/// +import { defineConfig } from 'vite'; +import vue from '@vitejs/plugin-vue'; +import dts from 'vite-plugin-dts'; +import * as path from 'path'; +import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; +import { libInjectCss } from 'vite-plugin-lib-inject-css'; + +import resolvePlugin from '@rollup/plugin-node-resolve'; +import basicSsl from '@vitejs/plugin-basic-ssl'; +import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'; +import { defineProjectAssetsBuildOptions, AssetOutputEntry } from './assets'; + +export interface ProjectMeta { + name: string; + workspaceRootRelative: string; + root: string; +} + +function createViteTestConfig(project: ProjectMeta) { + return { + globals: true, + cache: { + dir: \`\${project.workspaceRootRelative}/tmp/vitest/\${project.name}\`, + }, + environment: 'jsdom', + include: ['test/**/*.test.{ts,mts,cts,tsx}'], + + reporters: ['default'], + coverage: { + reportsDirectory: \`\${project.workspaceRootRelative}/tmp/coverage/\${project.name}\`, + provider: 'v8', + }, + }; +} + +export interface ProjectViteConfigOptions { + assetTypes?: AssetOutputEntry[]; +} + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface LibProjectViteConfigOptions extends ProjectViteConfigOptions { + +} + +export function defineLibProjectViteConfig(projectDir: string, project: ProjectMeta, options?: LibProjectViteConfigOptions) { + options = options ?? {}; + const assetsConfig = defineProjectAssetsBuildOptions(options.assetTypes); + return defineConfig({ + root: projectDir, + cacheDir: \`\${project.workspaceRootRelative}/tmp/vite/\${project.name}\`, + + plugins: [ + vue(), + nxViteTsPaths(), + dts({ + entryRoot: 'src', + tsconfigPath: path.join(projectDir, 'tsconfig.build.json'), + }), + libInjectCss(), + ], + + // Configuration for building your library. + // See: https://vitejs.dev/guide/build.html#library-mode + build: { + outDir: \`\${project.workspaceRootRelative}/dist/\${project.root}\`, + emptyOutDir: true, + cssCodeSplit: true, + reportCompressedSize: true, + commonjsOptions: { + transformMixedEsModules: true, + }, + lib: { + // Could also be a dictionary or array of multiple entry points. + entry: 'src/index.ts', + name: project.name, + fileName: 'index', + // Change this to the formats you want to support. + // Don't forget to update your package.json as well. + formats: ['es'], + }, + rollupOptions: { + rollupOptions: { + preserveSymlinks: true, + output: { + preserveModules: false, + entryFileNames: assetsConfig.entryFileNames, + assetFileNames: assetsConfig.assetFileNames, + chunkFileNames: assetsConfig.chunkFileNames + } + }, + // External packages that should not be bundled into your library. + external: [], + }, + }, + + test: createViteTestConfig(project) + }); +} + + +export interface AppProjectViteConfigOptions extends ProjectViteConfigOptions { + server?: { + port?: number, + host?: string; + }, + + preview?: { + port?: number, + host?: string; + }; +} + +export function defineAppProjectViteConfig(projectDir: string, project: ProjectMeta, options?: AppProjectViteConfigOptions) { + options = options ?? {}; + + const assetsConfig = defineProjectAssetsBuildOptions(options?.assetTypes); + return defineConfig({ + root: projectDir, + cacheDir: \`\${project.workspaceRootRelative}/tmp/vite/\${project.name}\`, + server: { + port: 20021, + host: 'localhost', + + fs: { + // Allow serving files from one level up to the project root + strict: false, + }, + + ...(options?.server ?? {}) + }, + + preview: { + port: 20022, + host: 'localhost', + ...(options?.preview ?? {}) + }, + + publicDir: path.resolve(projectDir, './public'), + build: { + outDir: \`\${project.workspaceRootRelative}/dist/\${project.root}\`, + reportCompressedSize: true, + commonjsOptions: { transformMixedEsModules: true }, + minify: true, + assetsDir: assetsConfig.assetsDir, + // don't inline anything for demo + assetsInlineLimit: 0, + emptyOutDir: true, + rollupOptions: { + preserveSymlinks: true, + output: { + entryFileNames: assetsConfig.entryFileNames, + assetFileNames: assetsConfig.assetFileNames, + chunkFileNames: assetsConfig.chunkFileNames + } + } + }, + + plugins: [ + vue({ + template: { + compilerOptions: { + //isCustomElement: (tag) => /^[A-Z]/.test(tag) + }, + }, + }), + nxViteTsPaths(), + VueI18nPlugin({ + include: [path.resolve(projectDir, './src/*/Asset/Locale/**')], + defaultSFCLang: 'yaml', + allowDynamic: true, + dropMessageCompiler: true, + }), + resolvePlugin(undefined), + basicSsl(), + ], + + // Uncomment this if you are using workers. + // worker: { + // plugins: [ nxViteTsPaths() ], + // }, + + test: createViteTestConfig(project) + }); +}" +`; + exports[`preset generator CONTRIBUTING.md should match snapshot 1`] = ` "# Contributing to test-workspace @@ -33,6 +477,7 @@ First off, thanks for taking the time to contribute! 🎉 The following is a set of guidelines for contributing to test-workspace. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request. + ## How Can I Contribute? ### Reporting Bugs @@ -101,8 +546,7 @@ This section lists the labels we use to help us track and manage issues and pull --- -Thank you for your contributions! Your help is greatly appreciated. -" +Thank you for your contributions! Your help is greatly appreciated." `; exports[`preset generator Makefile should match snapshot 1`] = ` @@ -110,22 +554,17 @@ exports[`preset generator Makefile should match snapshot 1`] = ` export WORKSPACE = test-workspace ## PATHS -export BIN_ROOT_PATH = ./bin +export BIN_ROOT_PATH = ./.workspace/bin export UTIL_ROOT_PATH = $(realpath $(BIN_ROOT_PATH)/util) export UTIL_PATH = $(UTIL_ROOT_PATH)/util.sh -#ifndef CI -## dev.env - #include dev.env - #export $(shell sed 's/=.*//' dev.env) -#endif - ## VERSION ifeq "$(ENV)" "dev" export VERSION = dev endif -DC=docker compose -p $(WORKSPACE) +export DOCKER_DIR = .workspace/docker +DC=docker compose -p $(WORKSPACE) --project-directory . # Help target settings INFO = Showing targets for all of ENV(default: dev) @@ -160,7 +599,7 @@ up: chmod 777 ./tmp/docker chmod 640 -R ./docker/ca/certs/db fi - $(DC) -f docker-compose-dev.yaml --env-file ./docker/dev/.env up -d --wait --wait-timeout 5 + $(DC) -f $(DOCKER_DIR)/dev/docker-compose-dev.yaml --env-file $(DOCKER_DIR)/dev/.env up -d --wait --wait-timeout 5 sleep 3 ## Clear testing env @@ -168,7 +607,8 @@ down: $(DC) down -t 2 build_dev_image: - DOCKER_BUILDKIT=1 docker build -t test-workspace/dev:latest -f ./docker/app/Dockerfile --target=dev . + DOCKER_BUILDKIT=1 docker build -t test-workspace/dev:latest -f $(DOCKER_DIR)/app/Dockerfile --target=dev . + endif" `; @@ -182,160 +622,20 @@ Replace with Yours project workspace description. To start contributing you need install some tools and init developer environment. ### Tools - -- NodeJS -- pnpm -- Nx (\`pnpm add --global nx@19.1.0\`) -- Docker + Compose -- make + - NodeJS + - pnpm + - Nx (\`pnpm add --global nx@19.1.1\`) + - Docker + Compose + - make To init developer environment run: - \`\`\`bash make init_devenv \`\`\` ## Contributing -Contributing Guide is in separate file [CONTRIBUTING.md](./CONTRIBUTING.md) -" -`; - -exports[`preset generator docker/app/Dockerfile should match snapshot 1`] = ` -"# pnpm https://github.com/moby/moby/issues/40449#issuecomment-1758956399 -ARG NODE_IMAGE=node:22-alpine3.18 -ARG PM2_VERSION=5.3.1 -ARG USER_UID=1000 - -FROM "$NODE_IMAGE" as deps - -ENV NODE_ENV=production -ENV PNPM_HOME="/app/.pnpm-store" -ENV PATH="$PNPM_HOME:$PATH" - -RUN mkdir -p /app/.pnpm-store && chown -R node:node /app && chmod -R 777 /app && corepack enable && pnpm config set store-dir "$PNPM_HOME" - -USER node -WORKDIR /app - -COPY --chown=node:node ./pnpm-lock.yaml ./ -RUN --mount=type=cache,target=/app/.pnpm-store,uid=\${USER_UID},gid=\${USER_UID} pnpm fetch --prod --ignore-scripts - -COPY --chown=node:node ./pnpm-lock.yaml ./package.json ./prod/ -RUN --mount=type=cache,ro,target=/app/.pnpm-store,uid=\${USER_UID},gid=\${USER_UID} cd prod && pnpm install --prod --offline --frozen-lockfile --ignore-scripts - -########################## -# DEV container tool stage -FROM deps as dev -RUN --mount=type=cache,target=/app/.pnpm-store,uid=\${USER_UID},gid=\${USER_UID} pnpm fetch --dev --ignore-scripts - -COPY --chown=node:node ./package.json ./ -RUN --mount=type=cache,ro,target=/app/.pnpm-store,uid=\${USER_UID},gid=\${USER_UID} pnpm install --prod=false --offline --frozen-lockfile --ignore-scripts - -EXPOSE 3000 - -CMD ["sleep", "1000"] - -####################### -# API application stage -FROM $NODE_IMAGE as app_api -ARG APP_ID - -RUN mkdir /app && chown node:node /app && chmod 770 /app && npm i -g pm2@\${PM2_VERSION} -WORKDIR /app - -RUN --mount=type=bind,from=deps,source=/app,target=/tmp/deps cp -R -p /tmp/deps/prod/* ./ - -COPY --chown=node:node ./dist/apps/\${APP_ID} ./apps/\${APP_ID} -COPY --chown=node:node ./dist/libs ./libs -COPY --chown=node:node ./docker/app/pm2.config.cjs ./pm2.config.cjs - -USER node -ENV NODE_ENV=production -EXPOSE 3000 -RUN ln -s apps/\${APP_ID}/src/index.js entrypoint - -CMD ["pm2-runtime", "--json", "pm2.config.cjs"] -" -`; - -exports[`preset generator docker/app/pm2.config.cjs should match snapshot 1`] = ` -"var fs = require('fs'); -const configPath = process.env['PM2_CONFIG_PATH'] ?? './config/pm2.config.json'; -const config = JSON.parse(fs.readFileSync(configPath, { encoding: 'utf8' })); -module.exports = { - apps: [ - { - script: './entrypoint', - ...config, - }, - ], -}; -" -`; - -exports[`preset generator docker/dev/.env should match snapshot 1`] = ` -"WORKSPACE=test-workspace - -HOST_DATA_DIR=./tmp/docker -HOST_CONFIG_DIR=./docker/dev -HOST_CA_DIR=./docker/dev/ca -HOST_CERTS_DIR=./docker/dev/ca/certs -HOST_CA_CRT=./docker/dev/ca/ca.crt - -# SERVICES - -# Redis -REDIS_HOST_PORT=25010 -REDIS_PASSWORD=testredis - -# DB -DB_HOST_PORT=25011 - -" -`; - -exports[`preset generator docker-compose-dev.yaml should match snapshot 1`] = ` -"version: '3.6' -services: - redis: - image: bitnami/redis:7.2 - container_name: \${PROJECT}-redis - restart: always - environment: - - ALLOW_EMPTY_PASSWORD=no - - REDIS_AOF_ENABLED=no - - REDIS_PASSWORD=\${REDIS_PASSWORD} - - REDIS_ACLFILE=/bitnami/redis/config/users.acl - ports: - - \${REDIS_HOST_PORT}:6379 - volumes: - - \${HOST_CONFIG_DIR}/redis:/bitnami/redis/config - tmpfs: - - /bitnami/redis/data:size=64M - db: - image: bitnami/postgresql:16.2.0 - container_name: \${PROJECT}-db - restart: always - environment: - - POSTGRESQL_POSTGRES_PASSWORD=testroot - - POSTGRESQL_DATABASE=\${PROJECT} - - POSTGRESQL_USERNAME=\${PROJECT} - - POSTGRESQL_PASSWORD=test - - POSTGRESQL_ENABLE_TLS=yes - - POSTGRESQL_TLS_CERT_FILE=/opt/bitnami/postgresql/certs/db.crt - - POSTGRESQL_TLS_KEY_FILE=/opt/bitnami/postgresql/certs/db.key - - POSTGRESQL_TLS_CA_FILE=/opt/bitnami/postgresql/certs/ca.crt - volumes: - - \${HOST_CERTS_DIR}/db/db.crt:/opt/bitnami/postgresql/certs/db.crt - - \${HOST_CERTS_DIR}/db/db.key:/opt/bitnami/postgresql/certs/db.key - - \${HOST_CA_CRT}:/opt/bitnami/postgresql/certs/ca.crt - mem_limit: 512M - tmpfs: - - /tmp:size=256M - ports: - - \${DB_HOST_PORT}:5432 -" +Contributing Guide is in separate file [CONTRIBUTING.md](./CONTRIBUTING.md)" `; exports[`preset generator nx.json should match snapshot 1`] = ` @@ -345,40 +645,176 @@ exports[`preset generator nx.json should match snapshot 1`] = ` }, "targetDefaults": { "build": { - "inputs": ["default", "!{projectRoot}/test/**/*"], - "dependsOn": ["^build"], "cache": true }, "lint": { + "cache": true + }, + "@nx/js:tsc": { + "inputs": [ + "production", + "^production" + ], + "outputs": [ + "{options.outputPath}" + ], + "dependsOn": [ + "^build", + "test" + ], + "cache": true, + "options": { + "outputPath": "dist/{projectRoot}", + "tsConfig": "{projectRoot}/tsconfig.build.json" + } + }, + "@nx/jest:jest": { + "cache": true, + "inputs": [ + "default", + "^production", + "{workspaceRoot}/jest.preset.js" + ], + "options": { + "jestConfig": "{projectRoot}/jest.config.ts", + "runInBand": true, + "passWithNoTests": true + }, + "configurations": { + "watch": { + "watch": true + }, + "ci": { + "ci": true, + "codeCoverage": true + }, + "updateSnapshot": { + "updateSnapshot": true + }, + "codeCoverage": { + "codeCoverage": true + } + } + }, + "@nx/eslint:lint": { "inputs": [ "default", "{workspaceRoot}/.eslintrc.json", "{workspaceRoot}/.eslintignore" ], - "cache": true - }, - "lint-fix": { - "cache": false + "cache": true, + "options": { + "lintFilePatterns": [ + "{projectRoot}/**/*.ts", + "{projectRoot}/package.json" + ] + }, + "configurations": { + "fix": { + "fix": true, + "cache": false + } + } }, - "test": { - "inputs": ["default", "^default", "{workspaceRoot}/jest.preset.js"], - "cache": true + "@nx/vite:build": { + "inputs": [ + "production", + "^production" + ], + "outputs": [ + "{options.outputPath}" + ], + "defaultConfiguration": "production", + "options": { + "outputPath": "dist/{projectRoot}", + "skipTypeCheck": true, + "configFile": "{projectRoot}/vite.config.ts", + "tsConfig": "{projectRoot}/tsconfig.build.json", + "generatePackageJson": false + }, + "configurations": { + "development": { + "mode": "development" + }, + "production": { + "mode": "production" + } + } }, - "test-watch": { - "inputs": ["default", "^default", "{workspaceRoot}/jest.preset.js"], - "cache": true + "@nx/vite:preview-server": { + "defaultConfiguration": "development", + "options": { + "buildTarget": "build" + }, + "configurations": { + "development": { + "buildTarget": "build:development" + }, + "production": { + "buildTarget": "build:production" + } + } }, "@nx/vite:test": { "cache": true, - "inputs": ["default", "^default"] - }, - "@nx/eslint:lint": { "inputs": [ "default", - "{workspaceRoot}/.eslintrc.json", - "{workspaceRoot}/.eslintignore" + "^default" ], - "cache": true + "options": { + "configFile": "{projectRoot}/vite.config.ts", + "passWithNoTests": true, + "reportsDirectory": "../../../coverage/{projectRoot}" + }, + "configurations": { + "watch": { + "watch": true + } + } + }, + "@nx/storybook:storybook": { + "options": { + "port": 4400, + "configDir": "libs/front/mao1/.storybook" + }, + "configurations": { + "ci": { + "quiet": true + } + } + }, + "@nx/storybook:build": { + "outputs": [ + "{options.outputDir}" + ], + "options": { + "outputDir": "dist/storybook/{projectRoot}", + "configDir": "{projectRoot}/.storybook" + }, + "configurations": { + "ci": { + "quiet": true + } + } + }, + "storybook-test": { + "executor": "nx:run-commands", + "options": { + "command": "test-storybook -c {projectRoot}/.storybook --url=http://localhost:4400" + } + }, + "storybook-static": { + "executor": "@nx/web:file-server", + "options": { + "buildTarget": "storybook-build", + "staticFilePath": "dist/storybook/{projectRoot}", + "spa": true + }, + "configurations": { + "ci": { + "buildTarget": "storybook-build:ci" + } + } } }, "extends": "nx/presets/npm.json", @@ -388,12 +824,19 @@ exports[`preset generator nx.json should match snapshot 1`] = ` } }, "namedInputs": { - "default": ["{projectRoot}/**/*", "sharedGlobals"], + "default": [ + "{projectRoot}/**/*", + "!{projectRoot}/README.md", + "sharedGlobals" + ], "sharedGlobals": [], "production": [ "default", + "!{projectRoot}/test/**/*", + "!{projectRoot}/.vite/**/*", + "!{projectRoot}/.storybook/**/*", "!{projectRoot}/jest.config.{js,ts,mjs,mts}", - "!{projectRoot}/vite.config.{js,ts,mjs,mts}", + "!{projectRoot}/tsconfig.test.json", "!{projectRoot}/.eslintrc.json" ] }, @@ -435,15 +878,23 @@ exports[`preset generator package.json should match snapshot 1`] = ` "@intlify/unplugin-vue-i18n": "^4.0.0", "@jest/globals": "^29.7.0", "@nestjs/testing": "^10.3.8", - "@nx/devkit": "19.1.0", - "@nx/esbuild": "19.1.0", - "@nx/eslint-plugin": "19.1.0", - "@nx/jest": "19.1.0", - "@nx/js": "19.1.0", - "@nx/linter": "19.1.0", - "@nx/plugin": "19.1.0", + "@nx/esbuild": "19.1.1", + "@nx/eslint-plugin": "19.1.1", + "@nx/jest": "19.1.1", + "@nx/js": "19.1.1", + "@nx/linter": "19.1.1", + "@nx/storybook": "19.1.1", + "@nx/vite": "19.1.1", + "@nx/vue": "19.1.1", + "@nx/web": "19.1.1", "@rollup/plugin-node-resolve": "^15.2.3", "@samatech/postcss-basics": "^0.6.0", + "@storybook/addon-essentials": "^8.1.5", + "@storybook/addon-interactions": "^8.1.5", + "@storybook/core-server": "^8.1.5", + "@storybook/test": "^8.1.5", + "@storybook/vue3": "^8.1.5", + "@storybook/vue3-vite": "^8.1.5", "@stylistic/eslint-plugin": "^2.1.0", "@types/jest": "^29.5.12", "@types/node": "20.12.12", @@ -452,6 +903,7 @@ exports[`preset generator package.json should match snapshot 1`] = ` "@vitejs/plugin-vue": "^5.0.4", "@vitest/coverage-v8": "1.6.*", "@vitest/ui": "1.6.*", + "@vue/eslint-config-prettier": "^7.1.0", "@vue/eslint-config-typescript": "^11.0.3", "@vue/test-utils": "^2.4.5", "@vue/tsconfig": "^0.4.0", @@ -473,11 +925,13 @@ exports[`preset generator package.json should match snapshot 1`] = ` "jsdom": "^24.0.0", "pinia": "^2.1.7", "postcss": "^8.4.38", + "prettier": "3.2.5", "primeflex": "^3.3.1", "primeicons": "^7.0.0", "primevue": "^3.52.0", "rollup": "^4.17.0", "sass": "^1.75.0", + "storybook": "^8.1.5", "stylelint": "^16.6.0", "stylelint-config-standard": "^36.0.0", "ts-jest": "^29.1.2", @@ -487,6 +941,8 @@ exports[`preset generator package.json should match snapshot 1`] = ` "unplugin-swc": "^1.4.5", "vee-validate": "^4.12.6", "vite": "^5.2.10", + "vite-plugin-dts": "3.9.1", + "vite-plugin-lib-inject-css": "2.1.1", "vite-tsconfig-paths": "^4.3.2", "vitest": "1.6.*", "vue": "^3.4.25", @@ -513,7 +969,9 @@ exports[`preset generator tsconfig.base.json should match snapshot 1`] = ` "moduleResolution": "Node16", "module": "Node16", "target": "ES2022", - "lib": ["ES2022"], + "lib": [ + "ES2022" + ], "esModuleInterop": true, "sourceMap": true, "declaration": true, @@ -544,7 +1002,9 @@ exports[`preset generator tsconfig.base.json should match snapshot 1`] = ` } ] }, - "exclude": ["node_modules", "tmp"] -} -" + "exclude": [ + "node_modules", + "tmp" + ] +}" `; diff --git a/packages/plugin/test/generators/preset/generator.test.ts b/packages/plugin/test/generators/preset/generator.test.ts index d1927be..ae2f714 100644 --- a/packages/plugin/test/generators/preset/generator.test.ts +++ b/packages/plugin/test/generators/preset/generator.test.ts @@ -3,7 +3,7 @@ import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'; import { presetGenerator } from '../../../src/generators/preset/generator'; import { PresetGeneratorSchema } from '../../../src/generators/preset/schema'; -import { exceptWorkspaceFileMatchSnapshot } from '../../helper/functions'; +import { exceptWorkspaceFileMatchSnapshot, expectedFiles } from '../../helper/functions'; describe('preset generator', () => { let tree: Tree; @@ -14,6 +14,20 @@ describe('preset generator', () => { await presetGenerator(tree, options); }); + const expectedDotWorkspaceDirFilesToMatchSnapshots = expectedFiles('.workspace/', [ + 'jest/jest.preset.ts', + 'storybook/storybook.preset.ts', + 'vite/assets.ts', + 'vite/vite.preset.ts', + ]); + + const expectedDotDockerDirFilesToMatchSnapshots = expectedFiles('.workspace/docker/', [ + 'app/Dockerfile', + 'app/pm2.config.cjs', + 'dev/.env', + 'dev/docker-compose-dev.yaml', + ]); + const expectedWorkespaceFilesToMatchSnapshots = [ 'nx.json', 'package.json', @@ -23,13 +37,10 @@ describe('preset generator', () => { '.npmrc', 'CONTRIBUTING.md', 'README.md', - 'docker/app/Dockerfile', - 'docker/app/pm2.config.cjs', - 'docker/dev/.env', 'Makefile', 'tsconfig.base.json', - - 'docker-compose-dev.yaml', + ...expectedDotWorkspaceDirFilesToMatchSnapshots, + ...expectedDotDockerDirFilesToMatchSnapshots ]; test.each(expectedWorkespaceFilesToMatchSnapshots.map(i => [i]))('%s should match snapshot', (filePath) => { exceptWorkspaceFileMatchSnapshot(tree, filePath); @@ -44,24 +55,27 @@ describe('preset generator', () => { '.gitattributes', '.editorconfig', '.dockerignore', + '.prettierignore', + '.prettierrc.js', '.vscode/extensions.json', '.vscode/settings.json.template', '.husky/install.mjs', '.husky/pre-commit', 'jest.config.ts', - 'jest.preset.ts', - 'bin/util/MakeHelp', - 'bin/util/util.sh', - 'docker/dev/ca/ca.crt', - 'docker/dev/ca/ca.key', - 'docker/dev/ca/ca.srl', - 'docker/dev/ca/certs/db/db.crt', - 'docker/dev/ca/certs/db/db.key', - 'docker/dev/ca/certs/redis/redis.crt', - 'docker/dev/ca/certs/redis/redis.key', - 'docker/dev/ca/create_ca.sh', - 'docker/dev/ca/gen_cert.sh', - 'docker/dev/redis/users.acl', + '.workspace/bin/util/MakeHelp', + '.workspace/bin/util/util.sh', + ...expectedFiles('.workspace/docker/', [ + 'dev/ca/ca.crt', + 'dev/ca/ca.key', + 'dev/ca/ca.srl', + 'dev/ca/certs/db/db.crt', + 'dev/ca/certs/db/db.key', + 'dev/ca/certs/redis/redis.crt', + 'dev/ca/certs/redis/redis.key', + 'dev/ca/create_ca.sh', + 'dev/ca/gen_cert.sh', + 'dev/redis/users.acl', + ]), ...expectedWorkespaceFilesToMatchSnapshots ]; const diff = tree.listChanges().map(c => c.path).filter(x => !expectedWorkspaceFilesToExists.includes(x)); diff --git a/packages/plugin/test/helper/functions.ts b/packages/plugin/test/helper/functions.ts index 110d0a3..6da5a68 100644 --- a/packages/plugin/test/helper/functions.ts +++ b/packages/plugin/test/helper/functions.ts @@ -19,4 +19,8 @@ export function exceptWorkspaceFileMatchSnapshot(tree: Tree, filePath: string): export function exceptOnlyFilesFromListExistInWorkspace(tree: Tree, expected: string[]): void { const diff = tree.listChanges().map(c => c.path).filter(x => !expected.includes(x)); expect(diff).toEqual([]); +} + +export function expectedFiles(prefix: string, files: string[]) { + return files.map((f) => prefix + f); } \ No newline at end of file diff --git a/packages/plugin/tsconfig.lib.json b/packages/plugin/tsconfig.build.json similarity index 100% rename from packages/plugin/tsconfig.lib.json rename to packages/plugin/tsconfig.build.json diff --git a/packages/plugin/tsconfig.json b/packages/plugin/tsconfig.json index 70634b0..0f41fa4 100644 --- a/packages/plugin/tsconfig.json +++ b/packages/plugin/tsconfig.json @@ -4,10 +4,10 @@ "include": [], "references": [ { - "path": "./tsconfig.lib.json" + "path": "./tsconfig.build.json" }, { "path": "./tsconfig.test.json" } ] -} +} \ No newline at end of file diff --git a/packages/plugin/tsconfig.test.json b/packages/plugin/tsconfig.test.json index 9abe118..6645bc0 100644 --- a/packages/plugin/tsconfig.test.json +++ b/packages/plugin/tsconfig.test.json @@ -11,5 +11,5 @@ "jest.config.ts", "test/**/*.ts", "src/**/*.d.ts" - ] +, "src/generators/library/files/frontend/src/vue-shims.d.ts__tmpl__" ] } \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2410ff5..8331580 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,37 +6,37 @@ settings: dependencies: '@nx/devkit': - specifier: 19.1.0 - version: 19.1.0(nx@19.1.0) + specifier: 19.1.1 + version: 19.1.1(nx@19.1.1) create-nx-workspace: - specifier: 19.0.4 - version: 19.0.4 + specifier: 19.1.1 + version: 19.1.1 tslib: specifier: ^2.6.2 version: 2.6.2 devDependencies: '@nx/eslint': - specifier: 19.1.0 - version: 19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(eslint@8.57.0)(nx@19.1.0)(verdaccio@5.31.0) + specifier: 19.1.1 + version: 19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(eslint@8.57.0)(nx@19.1.1)(verdaccio@5.31.0) '@nx/eslint-plugin': - specifier: 19.1.0 - version: 19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(@typescript-eslint/parser@7.11.0)(eslint-config-prettier@9.1.0)(eslint@8.57.0)(nx@19.1.0)(typescript@5.4.5)(verdaccio@5.31.0) + specifier: 19.1.1 + version: 19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(@typescript-eslint/parser@7.11.0)(eslint-config-prettier@9.1.0)(eslint@8.57.0)(nx@19.1.1)(typescript@5.4.5)(verdaccio@5.31.0) '@nx/jest': - specifier: 19.1.0 - version: 19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(nx@19.1.0)(ts-node@10.9.1)(typescript@5.4.5)(verdaccio@5.31.0) + specifier: 19.1.1 + version: 19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(nx@19.1.1)(ts-node@10.9.1)(typescript@5.4.5)(verdaccio@5.31.0) '@nx/js': - specifier: 19.1.0 - version: 19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(nx@19.1.0)(typescript@5.4.5)(verdaccio@5.31.0) + specifier: 19.1.1 + version: 19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(nx@19.1.1)(typescript@5.4.5)(verdaccio@5.31.0) '@nx/linter': - specifier: 19.1.0 - version: 19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(eslint@8.57.0)(nx@19.1.0)(verdaccio@5.31.0) + specifier: 19.1.1 + version: 19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(eslint@8.57.0)(nx@19.1.1)(verdaccio@5.31.0) '@nx/plugin': - specifier: 19.1.0 - version: 19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(eslint@8.57.0)(nx@19.1.0)(ts-node@10.9.1)(typescript@5.4.5)(verdaccio@5.31.0) + specifier: 19.1.1 + version: 19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(eslint@8.57.0)(nx@19.1.1)(ts-node@10.9.1)(typescript@5.4.5)(verdaccio@5.31.0) '@nx/workspace': - specifier: 19.1.0 - version: 19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107) + specifier: 19.1.1 + version: 19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107) '@swc-node/register': specifier: ~1.8.0 version: 1.8.0(@swc/core@1.3.107)(@swc/types@0.1.7)(typescript@5.4.5) @@ -77,8 +77,8 @@ devDependencies: specifier: ^29.7.0 version: 29.7.0 nx: - specifier: 19.1.0 - version: 19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107) + specifier: 19.1.1 + version: 19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107) prettier: specifier: ^2.8.8 version: 2.8.8 @@ -1977,17 +1977,17 @@ packages: fastq: 1.17.1 dev: true - /@nrwl/devkit@19.1.0(nx@19.1.0): - resolution: {integrity: sha512-n4YxtAMSdlXAmwcSKcLEX48kpcPGI/sX7lCfDeoSnTKud8Y1tlNeD8rf0YZV3ae+srE6j4lxfoJrRCpWweMcEQ==} + /@nrwl/devkit@19.1.1(nx@19.1.1): + resolution: {integrity: sha512-CrbEy4zBRPPV8gGtwpSgfxJUElXRxEGvvxQlrhoCKmzH7v9407jFjXpzYOipwa9u65a7raCCtsSKYuRdecRglQ==} dependencies: - '@nx/devkit': 19.1.0(nx@19.1.0) + '@nx/devkit': 19.1.1(nx@19.1.1) transitivePeerDependencies: - nx - /@nrwl/eslint-plugin-nx@19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(@typescript-eslint/parser@7.11.0)(eslint-config-prettier@9.1.0)(eslint@8.57.0)(nx@19.1.0)(typescript@5.4.5)(verdaccio@5.31.0): - resolution: {integrity: sha512-ZH34DlUoWD7p9aDVu3Uor/+jROqEfBGI+XIzBLDLjnmHkobsFwmvjbvDqvFeTMM3qvVJih1GfezbVRAhh2f4ZA==} + /@nrwl/eslint-plugin-nx@19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(@typescript-eslint/parser@7.11.0)(eslint-config-prettier@9.1.0)(eslint@8.57.0)(nx@19.1.1)(typescript@5.4.5)(verdaccio@5.31.0): + resolution: {integrity: sha512-IQYQ7vaCRysK8WOlK3xRJYqE/Rnnj4B69H/b4hPVQyV0IVUbHBcbKhOQftj8zdJyDAKqrXFxqMZ/hqvAvN6sXg==} dependencies: - '@nx/eslint-plugin': 19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(@typescript-eslint/parser@7.11.0)(eslint-config-prettier@9.1.0)(eslint@8.57.0)(nx@19.1.0)(typescript@5.4.5)(verdaccio@5.31.0) + '@nx/eslint-plugin': 19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(@typescript-eslint/parser@7.11.0)(eslint-config-prettier@9.1.0)(eslint@8.57.0)(nx@19.1.1)(typescript@5.4.5)(verdaccio@5.31.0) transitivePeerDependencies: - '@babel/traverse' - '@swc-node/register' @@ -2004,10 +2004,10 @@ packages: - verdaccio dev: true - /@nrwl/jest@19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(nx@19.1.0)(ts-node@10.9.1)(typescript@5.4.5)(verdaccio@5.31.0): - resolution: {integrity: sha512-UZzpxvmF411xlvYF0lNOddLn0ZSCmqF4sn21W3touPEvQZglszUFR5BKnuk/A2Me86wpKOiJUMeNp8GpL6pGUQ==} + /@nrwl/jest@19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(nx@19.1.1)(ts-node@10.9.1)(typescript@5.4.5)(verdaccio@5.31.0): + resolution: {integrity: sha512-hpWLl05iN9f9fUnlyOqihTG7mU+yjQEQ+TsrSAx9mjwvTohHJCp9pDx10620uBD7nzIjpjienHYIn3fWVyHDhw==} dependencies: - '@nx/jest': 19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(nx@19.1.0)(ts-node@10.9.1)(typescript@5.4.5)(verdaccio@5.31.0) + '@nx/jest': 19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(nx@19.1.1)(ts-node@10.9.1)(typescript@5.4.5)(verdaccio@5.31.0) transitivePeerDependencies: - '@babel/traverse' - '@swc-node/register' @@ -2024,10 +2024,10 @@ packages: - verdaccio dev: true - /@nrwl/js@19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(nx@19.1.0)(typescript@5.4.5)(verdaccio@5.31.0): - resolution: {integrity: sha512-bzjHWDwOpQ/Xju6Kei4MFOJvsO6zhoHE94IRKJobj2yLewy0P2gStyp05XOE/bMpY4GJ6ggthINkaxgl6ae0DA==} + /@nrwl/js@19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(nx@19.1.1)(typescript@5.4.5)(verdaccio@5.31.0): + resolution: {integrity: sha512-MiQJeb/GcVcRj0DibOIQuQOgDsE6js7TGJZ0zTOydviTWc8YDyHSutVnpYvUzrrEtDyN5DdDvFYkscggBdCjpg==} dependencies: - '@nx/js': 19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(nx@19.1.0)(typescript@5.4.5)(verdaccio@5.31.0) + '@nx/js': 19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(nx@19.1.1)(typescript@5.4.5)(verdaccio@5.31.0) transitivePeerDependencies: - '@babel/traverse' - '@swc-node/register' @@ -2041,10 +2041,10 @@ packages: - verdaccio dev: true - /@nrwl/nx-plugin@19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(eslint@8.57.0)(nx@19.1.0)(ts-node@10.9.1)(typescript@5.4.5)(verdaccio@5.31.0): - resolution: {integrity: sha512-Z20AFAGau60x8QGXabdQbNYG1KkiuyaozazZ2XappEkyThkURC0DvImp7Hxh8Kn9Jr7m3diNSE8vqFrOmhDuQA==} + /@nrwl/nx-plugin@19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(eslint@8.57.0)(nx@19.1.1)(ts-node@10.9.1)(typescript@5.4.5)(verdaccio@5.31.0): + resolution: {integrity: sha512-zGDLLktYG0cipFaftjgCPHHj+0g3i++kgmOAE22YabyU6ncbfpWfygm5NGnyilV7yZNOwpQ+Ac+qtWXoCfQTww==} dependencies: - '@nx/plugin': 19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(eslint@8.57.0)(nx@19.1.0)(ts-node@10.9.1)(typescript@5.4.5)(verdaccio@5.31.0) + '@nx/plugin': 19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(eslint@8.57.0)(nx@19.1.1)(ts-node@10.9.1)(typescript@5.4.5)(verdaccio@5.31.0) transitivePeerDependencies: - '@babel/traverse' - '@swc-node/register' @@ -2063,45 +2063,45 @@ packages: - verdaccio dev: true - /@nrwl/tao@19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107): - resolution: {integrity: sha512-Mayqkuh2EXkac5prri5fQFd19RBRxBQRjVwTcezk7yTKWI7V+bJzbgZANybtcKGsPCH34cpqrlV4inVwtyaVzw==} + /@nrwl/tao@19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107): + resolution: {integrity: sha512-03iaf+rnOEf5HHLsiSA7QIk63mBtcU4vkqkggoYLxJpMthx5nD4Z12nk+G/Z5RKWYUG4k3j6G7CFiIQRYOy7TA==} hasBin: true dependencies: - nx: 19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107) + nx: 19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107) tslib: 2.6.2 transitivePeerDependencies: - '@swc-node/register' - '@swc/core' - debug - /@nrwl/workspace@19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107): - resolution: {integrity: sha512-NSscB84tRn0VRmqZ3W8Zn+tnowCrF0TNCNq8cTFLRqzmg8/kyKrJMEMJmUwPPR9F1u66ciYkbGPbGwGVlEGQSw==} + /@nrwl/workspace@19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107): + resolution: {integrity: sha512-lWmz9tVX1ShKOugdn/A0PbP40Pzq5MsWdkLMwpiKCZLF4WMNzX+cb5W05VvCagHKRAovgZT9Ao9qY2CTD9482Q==} dependencies: - '@nx/workspace': 19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107) + '@nx/workspace': 19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107) transitivePeerDependencies: - '@swc-node/register' - '@swc/core' - debug dev: true - /@nx/devkit@19.1.0(nx@19.1.0): - resolution: {integrity: sha512-jn8uNgavpRhYZ1u63YFNWc2lEoAr3YA7bvPK9yaBmV++tFj+Ig+eFKkQxRou4tvOUnIyVPrs/fmi/TBLVQcpQg==} + /@nx/devkit@19.1.1(nx@19.1.1): + resolution: {integrity: sha512-YMt5vFaNMeIKgBwQ3RIFQG7AoYOksd8vNxwunirN95q/70HMIoJQsnRCMT45jVd9D/GIWASgY8QsGTMJfcO0qQ==} peerDependencies: nx: '>= 17 <= 20' dependencies: - '@nrwl/devkit': 19.1.0(nx@19.1.0) + '@nrwl/devkit': 19.1.1(nx@19.1.1) ejs: 3.1.10 enquirer: 2.3.6 ignore: 5.3.1 minimatch: 9.0.3 - nx: 19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107) + nx: 19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107) semver: 7.6.2 tmp: 0.2.3 tslib: 2.6.2 yargs-parser: 21.1.1 - /@nx/eslint-plugin@19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(@typescript-eslint/parser@7.11.0)(eslint-config-prettier@9.1.0)(eslint@8.57.0)(nx@19.1.0)(typescript@5.4.5)(verdaccio@5.31.0): - resolution: {integrity: sha512-lLWJvBCvpREBFIxNWk+d1Xfoe0RqH2+v6fkZB/pk/n/q9mHPvSE7JwFMxIw+QrIguAxKhAHGqDskTRH4llzz6w==} + /@nx/eslint-plugin@19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(@typescript-eslint/parser@7.11.0)(eslint-config-prettier@9.1.0)(eslint@8.57.0)(nx@19.1.1)(typescript@5.4.5)(verdaccio@5.31.0): + resolution: {integrity: sha512-ae+rkkiuW2iNJpVO29foI04eIaz+H/hPkosUBTf6PdJ4XtRGtACA1O7MhJckxB2MGDQc7A3+OvtEIj2wEjBfvw==} peerDependencies: '@typescript-eslint/parser': ^6.13.2 || ^7.0.0 eslint-config-prettier: ^9.0.0 @@ -2109,9 +2109,9 @@ packages: eslint-config-prettier: optional: true dependencies: - '@nrwl/eslint-plugin-nx': 19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(@typescript-eslint/parser@7.11.0)(eslint-config-prettier@9.1.0)(eslint@8.57.0)(nx@19.1.0)(typescript@5.4.5)(verdaccio@5.31.0) - '@nx/devkit': 19.1.0(nx@19.1.0) - '@nx/js': 19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(nx@19.1.0)(typescript@5.4.5)(verdaccio@5.31.0) + '@nrwl/eslint-plugin-nx': 19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(@typescript-eslint/parser@7.11.0)(eslint-config-prettier@9.1.0)(eslint@8.57.0)(nx@19.1.1)(typescript@5.4.5)(verdaccio@5.31.0) + '@nx/devkit': 19.1.1(nx@19.1.1) + '@nx/js': 19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(nx@19.1.1)(typescript@5.4.5)(verdaccio@5.31.0) '@typescript-eslint/parser': 7.11.0(eslint@8.57.0)(typescript@5.4.5) '@typescript-eslint/type-utils': 7.11.0(eslint@8.57.0)(typescript@5.4.5) '@typescript-eslint/utils': 7.11.0(eslint@8.57.0)(typescript@5.4.5) @@ -2135,8 +2135,8 @@ packages: - verdaccio dev: true - /@nx/eslint@19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(eslint@8.57.0)(nx@19.1.0)(verdaccio@5.31.0): - resolution: {integrity: sha512-UIeNUyUw9Dq21dXP+0vXplOtowgcWET7WnOLP9p4FD9LVMAS0mlR8noVwHjo6V9YgGhGisfzr/DFlJB7xqEDEw==} + /@nx/eslint@19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(eslint@8.57.0)(nx@19.1.1)(verdaccio@5.31.0): + resolution: {integrity: sha512-okmq9o/o3zqvDXFz1xqfcQ0Skmbvo3xMkAsacjuYP8W9kNVsRKFGqzI55lMTbvTYNDeFE30mcHLSpwzkgIm43g==} peerDependencies: '@zkochan/js-yaml': 0.0.7 eslint: ^8.0.0 || ^9.0.0 @@ -2144,9 +2144,9 @@ packages: '@zkochan/js-yaml': optional: true dependencies: - '@nx/devkit': 19.1.0(nx@19.1.0) - '@nx/js': 19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(nx@19.1.0)(typescript@5.4.5)(verdaccio@5.31.0) - '@nx/linter': 19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(eslint@8.57.0)(nx@19.1.0)(verdaccio@5.31.0) + '@nx/devkit': 19.1.1(nx@19.1.1) + '@nx/js': 19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(nx@19.1.1)(typescript@5.4.5)(verdaccio@5.31.0) + '@nx/linter': 19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(eslint@8.57.0)(nx@19.1.1)(verdaccio@5.31.0) eslint: 8.57.0 semver: 7.6.2 tslib: 2.6.2 @@ -2163,14 +2163,14 @@ packages: - verdaccio dev: true - /@nx/jest@19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(nx@19.1.0)(ts-node@10.9.1)(typescript@5.4.5)(verdaccio@5.31.0): - resolution: {integrity: sha512-US8oW/ZvRnVE47kTqGveuCd8A4z66qNOCcFAvtDuzHDPXn7BOOf7ZIPsAheSyIUIkzu2xr4Efb6YsuFub9p9fQ==} + /@nx/jest@19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(nx@19.1.1)(ts-node@10.9.1)(typescript@5.4.5)(verdaccio@5.31.0): + resolution: {integrity: sha512-DlGfav1zbCHt5esX58URgR+i4ElWO7hRikQsW4RF6DLFoxRKjjr9nbwgV7BeCe8DjTbFrOh4eQDx1UiqBRmNTA==} dependencies: '@jest/reporters': 29.7.0 '@jest/test-result': 29.7.0 - '@nrwl/jest': 19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(nx@19.1.0)(ts-node@10.9.1)(typescript@5.4.5)(verdaccio@5.31.0) - '@nx/devkit': 19.1.0(nx@19.1.0) - '@nx/js': 19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(nx@19.1.0)(typescript@5.4.5)(verdaccio@5.31.0) + '@nrwl/jest': 19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(nx@19.1.1)(ts-node@10.9.1)(typescript@5.4.5)(verdaccio@5.31.0) + '@nx/devkit': 19.1.1(nx@19.1.1) + '@nx/js': 19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(nx@19.1.1)(typescript@5.4.5)(verdaccio@5.31.0) '@phenomnomnominal/tsquery': 5.0.1(typescript@5.4.5) chalk: 4.1.2 identity-obj-proxy: 3.0.0 @@ -2197,8 +2197,8 @@ packages: - verdaccio dev: true - /@nx/js@19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(nx@19.1.0)(typescript@5.4.5)(verdaccio@5.31.0): - resolution: {integrity: sha512-szEmGGMYMsl57LVe80V9ZAp8BIo41cQf11DGe72J2tHXVi2H7+hGN6VA0dqGWxfffbpHJyIDy/NXpB4Y0z1vPw==} + /@nx/js@19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(nx@19.1.1)(typescript@5.4.5)(verdaccio@5.31.0): + resolution: {integrity: sha512-i8jXT7u6q9McV0mlEwvgN6WAa28FDdBI+45xNF1UApag892qzGjLu81xjrfTYlmF3tcP7xG7DUfqCU5oAoEcXg==} peerDependencies: verdaccio: ^5.0.4 peerDependenciesMeta: @@ -2212,9 +2212,9 @@ packages: '@babel/preset-env': 7.24.6(@babel/core@7.24.6) '@babel/preset-typescript': 7.24.6(@babel/core@7.24.6) '@babel/runtime': 7.24.6 - '@nrwl/js': 19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(nx@19.1.0)(typescript@5.4.5)(verdaccio@5.31.0) - '@nx/devkit': 19.1.0(nx@19.1.0) - '@nx/workspace': 19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107) + '@nrwl/js': 19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(nx@19.1.1)(typescript@5.4.5)(verdaccio@5.31.0) + '@nx/devkit': 19.1.1(nx@19.1.1) + '@nx/workspace': 19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107) babel-plugin-const-enum: 1.2.0(@babel/core@7.24.6) babel-plugin-macros: 2.8.0 babel-plugin-transform-typescript-metadata: 0.3.2(@babel/core@7.24.6) @@ -2247,10 +2247,10 @@ packages: - typescript dev: true - /@nx/linter@19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(eslint@8.57.0)(nx@19.1.0)(verdaccio@5.31.0): - resolution: {integrity: sha512-se8akeKL7AHimBdE3ucVtWFi6fWwe8u0wkN6TOzS0IUDVS6JoCRwbbIhPy9yQYFtUokBxg/h/aVthwGwMMNWgw==} + /@nx/linter@19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(eslint@8.57.0)(nx@19.1.1)(verdaccio@5.31.0): + resolution: {integrity: sha512-xx8fpJTlT4EIDweaYrknD5e5V5PsAO1Vr5lNG01gfQ0oB1B/ewU8h7jMnMGOJ2QTRtv8kEb3FAR38W1oLG2Q2g==} dependencies: - '@nx/eslint': 19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(eslint@8.57.0)(nx@19.1.0)(verdaccio@5.31.0) + '@nx/eslint': 19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(eslint@8.57.0)(nx@19.1.1)(verdaccio@5.31.0) transitivePeerDependencies: - '@babel/traverse' - '@swc-node/register' @@ -2265,94 +2265,94 @@ packages: - verdaccio dev: true - /@nx/nx-darwin-arm64@19.1.0: - resolution: {integrity: sha512-qUPZmVusnYrgqwhIYKBbabB1RpVQZiTcKfBdW1XiBTk+dXOuIVyWVCsg2ohoBJpHJiENYjtCprxR3RWPaxFs5Q==} + /@nx/nx-darwin-arm64@19.1.1: + resolution: {integrity: sha512-5CcgmNhUg5N62zCuzNZfRRPvaLRZNhLk0OkpMa085atEshM8RUAMbN80ffINaBssYtKu6znJ9LhUK+q7C3KiFQ==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] requiresBuild: true optional: true - /@nx/nx-darwin-x64@19.1.0: - resolution: {integrity: sha512-0Gf45EQTq8Q9/inGDzX5SqNY4jXDtqqVsz6wAJ07M9CeyjwDIXOzPe36uoMUhcvXQMbMp3QUH2E/X9poxOOubg==} + /@nx/nx-darwin-x64@19.1.1: + resolution: {integrity: sha512-vDM9vZow3YLA3+7GKTqhtguNcbQPifMTbqm8Aevd/suqCChQsLyD1Hh1Z+o03RNolNTRacNb6GPvoKFY4BJ2tA==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] requiresBuild: true optional: true - /@nx/nx-freebsd-x64@19.1.0: - resolution: {integrity: sha512-bw3sKpXy1R17OTStOkeRUE4EkPsvXjAEp26qmKX3G7a7bCVjH7cn+UXdgF8jsEyyiqb8WY1LG63abIlbyfecIA==} + /@nx/nx-freebsd-x64@19.1.1: + resolution: {integrity: sha512-FfOBrc1vndWYXSZVgbB9nWRp8/jo7f9b3g3ZfqaVwsGpcYcwz7dxiPV7HQKysTR0WNVv1aTi2Dg1CF+F94qlPw==} engines: {node: '>= 10'} cpu: [x64] os: [freebsd] requiresBuild: true optional: true - /@nx/nx-linux-arm-gnueabihf@19.1.0: - resolution: {integrity: sha512-jJzkPWptqFnl7Q7clTMGvI6OT1x8Jw7JHLCi6JgKBqb2ieF4vUCUsLHkrfS/95l9hCUeIHeBrfHJxEXLZIhOgQ==} + /@nx/nx-linux-arm-gnueabihf@19.1.1: + resolution: {integrity: sha512-Bb94MmoOsPnTI4n1mrILSwGmx9I50LEkEOgksoiOEYdykWKjbz6z4ZnFCJHTeF0bca1OmF5iCjFWU42KlLUsRQ==} engines: {node: '>= 10'} cpu: [arm] os: [linux] requiresBuild: true optional: true - /@nx/nx-linux-arm64-gnu@19.1.0: - resolution: {integrity: sha512-zycD7+PbVStbjlPsxE3G+bdwFDzXE7LKWtQOrGLvBxG99pXbTr+Oq1GtqL68p2Jp4MEYjIO5qdxWdNt9bBsSwA==} + /@nx/nx-linux-arm64-gnu@19.1.1: + resolution: {integrity: sha512-mqiRi95LOUTWldtif3f2aJOFLxg/2jnM1UYj85vUlaLZJmQK64OhQslCAAZCmEWkHAYqEooHaYqj30YmDb92jw==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] requiresBuild: true optional: true - /@nx/nx-linux-arm64-musl@19.1.0: - resolution: {integrity: sha512-NBUUbj/3NXHrqgkoLdMTnd8e9qduRVcSoGqpYDha0HBFc+Fspacw5+U26LjnmIuk/BT4yMtMrgFKU29Rq1a56w==} + /@nx/nx-linux-arm64-musl@19.1.1: + resolution: {integrity: sha512-lhyVsuT19Ez4ynhen6dT+Zdq2cABXcphYSkVSASvZGvka/65AS+0D1hX0TFDPJvbTdsHwVszJQZzIqGmYUkhLA==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] requiresBuild: true optional: true - /@nx/nx-linux-x64-gnu@19.1.0: - resolution: {integrity: sha512-jaPrd1VIdz/dqcjEKUJ5BnU+ONSZmG1G/g1HrNb+SIl3Ztputrwz8yJ7CwpUryRo+xSwWhZXIiNJ5r7z09kaKw==} + /@nx/nx-linux-x64-gnu@19.1.1: + resolution: {integrity: sha512-zUQhMwz/gQ0up1iymwTqXbyLJca87HXOP+uAD5wfgarh0yhPDwcGaVsV8O8t2z8W/dH/yYmuppe3gAwsvd5SSg==} engines: {node: '>= 10'} cpu: [x64] os: [linux] requiresBuild: true optional: true - /@nx/nx-linux-x64-musl@19.1.0: - resolution: {integrity: sha512-gj3Bq81s1NWzjtWteyTgczbbd2yq6xmic4H3PGFZkA5THjFAD/MiYiS9b5oQVzPWONyFgtk+gsTWVbiM7dOhew==} + /@nx/nx-linux-x64-musl@19.1.1: + resolution: {integrity: sha512-3Gc2iwMbFAp50OlIqfgryTtZno/FqPW+AOP1Pijo/jJOZ8DHP3A7Zy8QoJYUgTQxCffzVbhshXW6yy403pV3OQ==} engines: {node: '>= 10'} cpu: [x64] os: [linux] requiresBuild: true optional: true - /@nx/nx-win32-arm64-msvc@19.1.0: - resolution: {integrity: sha512-PIGy+uu8dzhWodIHXC0jbPtYcpi95NdtkghD1yZ32jcoVzAcHOohM07tTMHXbl7WyLqXw+De0XkmZadMJoVNAg==} + /@nx/nx-win32-arm64-msvc@19.1.1: + resolution: {integrity: sha512-91LJG0triTdZDHnT9l1N1YuIwhmR7iCbKsEv345OdPhHJeQ6GAuJCD0SqDk6aZ13xr7LoRlS8c6bnfctXeslQQ==} engines: {node: '>= 10'} cpu: [arm64] os: [win32] requiresBuild: true optional: true - /@nx/nx-win32-x64-msvc@19.1.0: - resolution: {integrity: sha512-aTbwZLIpViWgMZqyDl+2fyO5LJjtz0J4a0+0qPpEW46BAZ/kcEuE7Xv33Yoob+KorLr27n6BpzTs+7Wg4dXXFw==} + /@nx/nx-win32-x64-msvc@19.1.1: + resolution: {integrity: sha512-rEWRqcW1osCeaZ9KPfZWARIdOHGd0WXRW6iqqRvZZEAIbGlZP/89Sj2o9Fvs5oHpng7kfrqsDbpbikmmlX7HTQ==} engines: {node: '>= 10'} cpu: [x64] os: [win32] requiresBuild: true optional: true - /@nx/plugin@19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(eslint@8.57.0)(nx@19.1.0)(ts-node@10.9.1)(typescript@5.4.5)(verdaccio@5.31.0): - resolution: {integrity: sha512-nsPEPsAAa6vg4zzhN1RFLe1ndS+lgtAexk0x3bgIscm8JBIu2vfqXhJeboYgNHisKt6FJWSWYLNbOTGgS9Gxxg==} + /@nx/plugin@19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(eslint@8.57.0)(nx@19.1.1)(ts-node@10.9.1)(typescript@5.4.5)(verdaccio@5.31.0): + resolution: {integrity: sha512-8LVAW+bqipYDZXk1kIrRjI2m9QuU6nf19u5EwrKkquDzZbEGVknFest0khYeZC0HQK1FkiWMamiW/AVGK5YqRw==} dependencies: - '@nrwl/nx-plugin': 19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(eslint@8.57.0)(nx@19.1.0)(ts-node@10.9.1)(typescript@5.4.5)(verdaccio@5.31.0) - '@nx/devkit': 19.1.0(nx@19.1.0) - '@nx/eslint': 19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(eslint@8.57.0)(nx@19.1.0)(verdaccio@5.31.0) - '@nx/jest': 19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(nx@19.1.0)(ts-node@10.9.1)(typescript@5.4.5)(verdaccio@5.31.0) - '@nx/js': 19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(nx@19.1.0)(typescript@5.4.5)(verdaccio@5.31.0) + '@nrwl/nx-plugin': 19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(eslint@8.57.0)(nx@19.1.1)(ts-node@10.9.1)(typescript@5.4.5)(verdaccio@5.31.0) + '@nx/devkit': 19.1.1(nx@19.1.1) + '@nx/eslint': 19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(eslint@8.57.0)(nx@19.1.1)(verdaccio@5.31.0) + '@nx/jest': 19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(nx@19.1.1)(ts-node@10.9.1)(typescript@5.4.5)(verdaccio@5.31.0) + '@nx/js': 19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107)(@types/node@20.12.12)(nx@19.1.1)(typescript@5.4.5)(verdaccio@5.31.0) fs-extra: 11.2.0 tslib: 2.6.2 transitivePeerDependencies: @@ -2373,14 +2373,14 @@ packages: - verdaccio dev: true - /@nx/workspace@19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107): - resolution: {integrity: sha512-1W+zwRP4Uma0Ui0Za8qcd0rAt4InaLZ3yfAN66MaqQlyIPMsJDSqLBAVKEJfn4wS7zgoeeIwmQoXi6ACLKqZZA==} + /@nx/workspace@19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107): + resolution: {integrity: sha512-aTOAGotI8tbQiYp1jx+n0+SK18fpmPeRNA95y7xH8uMZLcm7zfOZiE0r450nbAVwU62JWncCvxwdB2weBVkY4w==} dependencies: - '@nrwl/workspace': 19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107) - '@nx/devkit': 19.1.0(nx@19.1.0) + '@nrwl/workspace': 19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107) + '@nx/devkit': 19.1.1(nx@19.1.1) chalk: 4.1.2 enquirer: 2.3.6 - nx: 19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107) + nx: 19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107) tslib: 2.6.2 yargs-parser: 21.1.1 transitivePeerDependencies: @@ -3873,8 +3873,8 @@ packages: - ts-node dev: true - /create-nx-workspace@19.0.4: - resolution: {integrity: sha512-iOLS78vbsfM4jS8kqOkow+WcJi9Yz8UECpF3Ailb/554VNZeEc6q2HLWVRQunI7vXEHJBtNsqXri1h/dH1+9tQ==} + /create-nx-workspace@19.1.1: + resolution: {integrity: sha512-+/sFolCG9GXCY6upnEVDqoSoMVUYY38nrE5H0Rct5a0Dz7ySXammEcdYB+o7u2ZgNaCRoTmxQkFmoGln+e+IzA==} hasBin: true dependencies: axios: 1.7.2 @@ -6294,8 +6294,8 @@ packages: resolution: {integrity: sha512-QK0sRs7MKv0tKe1+5uZIQk/C8XGza4DAnztJG8iD+TpJIORARrCxczA738awHrZoHeTjSSoHqao2teO0dC/gFQ==} dev: true - /nx@19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107): - resolution: {integrity: sha512-ia9XIL4QWli02WNZ3tLSpWvIYJVOWcikeELJwouZOwHKT7RA9i6vCQjKsIKWSFlUs47WDwiYiLSsMxR5KTqk8Q==} + /nx@19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107): + resolution: {integrity: sha512-9NPKoAQ+I3KcoFDThAVu7YznE9fKbV/AiE5dAXPbWfye9HjRdnhLQmXN122ADlq4pA5wkXwxvAxRLw2WA7Kkgw==} hasBin: true requiresBuild: true peerDependencies: @@ -6307,7 +6307,7 @@ packages: '@swc/core': optional: true dependencies: - '@nrwl/tao': 19.1.0(@swc-node/register@1.8.0)(@swc/core@1.3.107) + '@nrwl/tao': 19.1.1(@swc-node/register@1.8.0)(@swc/core@1.3.107) '@swc-node/register': 1.8.0(@swc/core@1.3.107)(@swc/types@0.1.7)(typescript@5.4.5) '@swc/core': 1.3.107(@swc/helpers@0.5.11) '@yarnpkg/lockfile': 1.1.0 @@ -6343,16 +6343,16 @@ packages: yargs: 17.7.2 yargs-parser: 21.1.1 optionalDependencies: - '@nx/nx-darwin-arm64': 19.1.0 - '@nx/nx-darwin-x64': 19.1.0 - '@nx/nx-freebsd-x64': 19.1.0 - '@nx/nx-linux-arm-gnueabihf': 19.1.0 - '@nx/nx-linux-arm64-gnu': 19.1.0 - '@nx/nx-linux-arm64-musl': 19.1.0 - '@nx/nx-linux-x64-gnu': 19.1.0 - '@nx/nx-linux-x64-musl': 19.1.0 - '@nx/nx-win32-arm64-msvc': 19.1.0 - '@nx/nx-win32-x64-msvc': 19.1.0 + '@nx/nx-darwin-arm64': 19.1.1 + '@nx/nx-darwin-x64': 19.1.1 + '@nx/nx-freebsd-x64': 19.1.1 + '@nx/nx-linux-arm-gnueabihf': 19.1.1 + '@nx/nx-linux-arm64-gnu': 19.1.1 + '@nx/nx-linux-arm64-musl': 19.1.1 + '@nx/nx-linux-x64-gnu': 19.1.1 + '@nx/nx-linux-x64-musl': 19.1.1 + '@nx/nx-win32-arm64-msvc': 19.1.1 + '@nx/nx-win32-x64-msvc': 19.1.1 transitivePeerDependencies: - debug diff --git a/tools/scripts/create-workspace.mjs b/tools/scripts/create-workspace.mjs index d166161..7d98d44 100644 --- a/tools/scripts/create-workspace.mjs +++ b/tools/scripts/create-workspace.mjs @@ -1,6 +1,6 @@ #!/usr/bin/env node +// Usage: node tools/create-workspace.mjs [plugin-version] -import { execSync } from 'child_process'; import { createWorkspace } from 'create-nx-workspace'; async function main() { @@ -8,19 +8,9 @@ async function main() { if (!name) { throw new Error('Please provide a name for the workspace'); } - const version = process.argv[3] ?? '0.0.1-e2e'; - console.log(`Creating the workspace: ${name}`); - - // CLEAR store before install - somehow stores old package and integrity hash error occures. - try { - execSync('pnpm store prune', { - env: process.env - }); - } catch (e) { - - } + console.log(`[${new Date().toISOString()}] Creating the workspace: ${name}`); const { directory } = await createWorkspace(`@hexancore/nx@${version}`, { name, @@ -29,7 +19,7 @@ async function main() { verbose: true, }); - console.log(`Successfully created the workspace: ${directory}.`); + console.log(`[${new Date().toISOString()}] Successfully created the workspace: ${directory}.`); } main();