From a736fd43a839fefef4b4d34914177443e20eb5ef Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 3 Aug 2024 00:37:43 +0200 Subject: [PATCH 01/91] feat(create-cli): package to align with package managers init command --- packages/create-cli/.eslintrc.json | 20 ++ packages/create-cli/README.md | 25 +++ packages/create-cli/package.json | 10 + packages/create-cli/project.json | 56 ++++++ packages/create-cli/src/index.ts | 5 + packages/create-cli/src/lib/constants.ts | 12 ++ packages/create-cli/src/lib/init.ts | 47 +++++ packages/create-cli/src/lib/utils.ts | 93 +++++++++ packages/create-cli/tsconfig.json | 16 ++ packages/create-cli/tsconfig.lib.json | 16 ++ packages/create-cli/tsconfig.test.json | 16 ++ .../create-cli/vite.config.integration.ts | 29 +++ packages/create-cli/vite.config.unit.ts | 33 ++++ .../nx-plugin/src/generators/init/README.md | 7 +- .../init/generator.integration.test.ts | 9 +- .../src/generators/init/generator.ts | 5 +- .../nx-plugin/src/generators/init/schema.d.ts | 1 + .../nx-plugin/src/generators/init/schema.json | 4 + packages/nx-plugin/src/index.ts | 7 +- .../nx-plugin/src/internal/execute-process.ts | 177 ++++++++++++++++++ .../src/internal/execute-process.unit.test.ts | 92 +++++++++ 21 files changed, 673 insertions(+), 7 deletions(-) create mode 100644 packages/create-cli/.eslintrc.json create mode 100644 packages/create-cli/README.md create mode 100644 packages/create-cli/package.json create mode 100644 packages/create-cli/project.json create mode 100755 packages/create-cli/src/index.ts create mode 100644 packages/create-cli/src/lib/constants.ts create mode 100644 packages/create-cli/src/lib/init.ts create mode 100644 packages/create-cli/src/lib/utils.ts create mode 100644 packages/create-cli/tsconfig.json create mode 100644 packages/create-cli/tsconfig.lib.json create mode 100644 packages/create-cli/tsconfig.test.json create mode 100644 packages/create-cli/vite.config.integration.ts create mode 100644 packages/create-cli/vite.config.unit.ts create mode 100644 packages/nx-plugin/src/internal/execute-process.ts create mode 100644 packages/nx-plugin/src/internal/execute-process.unit.test.ts diff --git a/packages/create-cli/.eslintrc.json b/packages/create-cli/.eslintrc.json new file mode 100644 index 000000000..fce4ee64f --- /dev/null +++ b/packages/create-cli/.eslintrc.json @@ -0,0 +1,20 @@ +{ + "extends": ["../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx"], + "parserOptions": { + "project": ["packages/create-cli/tsconfig.*?.json"] + }, + "rules": {} + }, + { + "files": ["*.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": ["error"] + } + } + ] +} diff --git a/packages/create-cli/README.md b/packages/create-cli/README.md new file mode 100644 index 000000000..00d645948 --- /dev/null +++ b/packages/create-cli/README.md @@ -0,0 +1,25 @@ +# @code-pushup/create-cli + +[![npm](https://img.shields.io/npm/v/%40code-pushup%2Fcreate-cli.svg)](https://www.npmjs.com/package/@code-pushup/create-cli) +[![downloads](https://img.shields.io/npm/dm/%40code-pushup%2Fcreate-cli)](https://npmtrends.com/@code-pushup/create-cli) +[![dependencies](https://img.shields.io/librariesio/release/npm/%40code-pushup/create-cli)](https://www.npmjs.com/package/@code-pushup/create-cli?activeTab=dependencies) + +A CLI tool to set up CodePushup in your repository. + +## Usage + +To set uo CodePushup run the following command: + +```bash +npx init @code-pushup/cli +``` + +It should generate the following output: + +```bash +> <↗> Generating @code-pushup/nx-plugin:init + +> <↗> Generating @code-pushup/nx-plugin:configuration + +CREATE code-pushup.config.ts +``` diff --git a/packages/create-cli/package.json b/packages/create-cli/package.json new file mode 100644 index 000000000..21ecb1fbe --- /dev/null +++ b/packages/create-cli/package.json @@ -0,0 +1,10 @@ +{ + "name": "@code-pushup/create-cli", + "version": "0.0.0", + "license": "MIT", + "bin": "src/index.js", + "dependencies": { + "@code-pushup/nx-plugin": "^0.48.0", + "tslib": "^2.6.2" + } +} diff --git a/packages/create-cli/project.json b/packages/create-cli/project.json new file mode 100644 index 000000000..2f888f2b8 --- /dev/null +++ b/packages/create-cli/project.json @@ -0,0 +1,56 @@ +{ + "name": "create-cli", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "packages/create-cli/src", + "projectType": "application", + "implicitDependencies": ["nx-plugin"], + "targets": { + "build": { + "dependsOn": ["^build"], + "executor": "@nx/js:tsc", + "outputs": ["{options.outputPath}"], + "options": { + "outputPath": "dist/packages/create-cli", + "main": "packages/create-cli/src/index.ts", + "tsConfig": "packages/create-cli/tsconfig.lib.json" + } + }, + "publish": { + "command": "node tools/scripts/publish.mjs create-cli {args.ver} {args.tag}", + "dependsOn": ["build"] + }, + "lint": { + "executor": "@nx/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": [ + "packages/create-cli/**/*.ts", + "packages/create-cli/package.json" + ] + } + }, + "unit-test": { + "executor": "@nx/vite:test", + "options": { + "configFile": "packages/create-cli/vite.config.unit.ts" + } + }, + "integration-test": { + "executor": "@nx/vite:test", + "options": { + "configFile": "packages/create-cli/vite.config.integration.ts" + } + }, + "exec-node": { + "dependsOn": ["build"], + "command": "node ./dist/packages/create-cli/src/index.js", + "options": {} + }, + "exec-npm": { + "dependsOn": ["^build"], + "command": "npm exec ./dist/packages/create-cli", + "options": {} + } + }, + "tags": ["scope:core", "type:app"] +} diff --git a/packages/create-cli/src/index.ts b/packages/create-cli/src/index.ts new file mode 100755 index 000000000..09efe0a95 --- /dev/null +++ b/packages/create-cli/src/index.ts @@ -0,0 +1,5 @@ +#! /usr/bin/env node +import { initCodePushup } from './lib/init'; + +// eslint-disable-next-line unicorn/prefer-top-level-await +initCodePushup().catch(console.error); diff --git a/packages/create-cli/src/lib/constants.ts b/packages/create-cli/src/lib/constants.ts new file mode 100644 index 000000000..764b88f5a --- /dev/null +++ b/packages/create-cli/src/lib/constants.ts @@ -0,0 +1,12 @@ +export const NX_JSON_FILENAME = 'nx.json'; +export const NX_JSON_CONTENT = JSON.stringify({ + $schema: './node_modules/nx/schemas/nx-schema.json', + releaseTagPattern: 'v{version}', + targetDefaults: {}, +}); +export const PROJECT_NAME = 'source-root'; +export const PROJECT_JSON_FILENAME = 'project.json'; +export const PROJECT_JSON_CONTENT = JSON.stringify({ + $schema: 'node_modules/nx/schemas/project-schema.json', + name: PROJECT_NAME, +}); diff --git a/packages/create-cli/src/lib/init.ts b/packages/create-cli/src/lib/init.ts new file mode 100644 index 000000000..ca76d0da7 --- /dev/null +++ b/packages/create-cli/src/lib/init.ts @@ -0,0 +1,47 @@ +// eslint-disable-next-line @nx/enforce-module-boundaries +import { + ProcessConfig, + executeProcess, + objectToCliArgs, +} from '@code-pushup/nx-plugin'; +import { + parseNxProcessOutput, + setupNxContext, + teardownNxContext, +} from './utils'; + +function nxPluginGenerator( + generator: 'init' | 'configuration', + opt: Record = {}, +): ProcessConfig { + return { + command: 'npx', + args: objectToCliArgs({ + _: ['nx', 'g', `@code-pushup/nx-plugin:${generator}`], + ...opt, + }), + }; +} + +export async function initCodePushup() { + const setupResult = await setupNxContext(); + + const { stdout: initStdout, stderr: initStderr } = await executeProcess( + nxPluginGenerator('init', { + skipNxJson: true, + }), + ); + console.info(parseNxProcessOutput(initStdout)); + console.warn(parseNxProcessOutput(initStderr)); + + const { stdout: configStdout, stderr: configStderr } = await executeProcess( + nxPluginGenerator('configuration', { + skipTarget: true, + project: setupResult.projectName, + }), + ); + console.info(parseNxProcessOutput(configStdout)); + console.warn(parseNxProcessOutput(configStderr)); + + await teardownNxContext(setupResult); +} diff --git a/packages/create-cli/src/lib/utils.ts b/packages/create-cli/src/lib/utils.ts new file mode 100644 index 000000000..b54265aae --- /dev/null +++ b/packages/create-cli/src/lib/utils.ts @@ -0,0 +1,93 @@ +import { readFile, rm, stat, writeFile } from 'node:fs/promises'; +import { + NX_JSON_CONTENT, + NX_JSON_FILENAME, + PROJECT_JSON_CONTENT, + PROJECT_JSON_FILENAME, + PROJECT_NAME, +} from './constants'; + +export type SetupResult = { + filename: string; + teardown: boolean; +}; + +export async function setupFile( + filename: string, + content = '', +): Promise { + const setupResult: SetupResult = { + filename, + teardown: false, + }; + + try { + const stats = await stat(filename); + if (!stats.isFile()) { + await writeFile(filename, content); + } + } catch (error) { + if ((error as Error).message.includes('no such file or directory')) { + await writeFile(filename, content); + return { + ...setupResult, + teardown: true, + }; + } else { + console.error((error as Error).toString()); + } + } + + return setupResult; +} + +export function parseNxProcessOutput(output: string) { + return output.trim().replace('NX', '<↗>'); +} + +export async function setupNxContext(): Promise<{ + nxJsonTeardown: boolean; + projectJsonTeardown: boolean; + projectName: string; +}> { + const { teardown: nxJsonTeardown } = await setupFile( + NX_JSON_FILENAME, + NX_JSON_CONTENT, + ); + const { teardown: projectJsonTeardown } = await setupFile( + PROJECT_JSON_FILENAME, + PROJECT_JSON_CONTENT, + ); + + const projectJsonContent = ( + await readFile(PROJECT_JSON_FILENAME, 'utf8') + ).toString(); + const { name = PROJECT_NAME } = JSON.parse(projectJsonContent) as { + name: string; + }; + + return { + nxJsonTeardown, + projectJsonTeardown, + projectName: name, + }; +} + +export async function teardownNxContext({ + nxJsonTeardown, + projectJsonTeardown, +}: { + nxJsonTeardown: boolean; + projectJsonTeardown: boolean; +}) { + const toDelete: Promise[] = []; + if (nxJsonTeardown) { + // eslint-disable-next-line functional/immutable-data + toDelete.push(rm(NX_JSON_FILENAME)); + } + if (projectJsonTeardown) { + // eslint-disable-next-line functional/immutable-data + toDelete.push(rm(PROJECT_JSON_FILENAME)); + } + await Promise.all(toDelete); +} diff --git a/packages/create-cli/tsconfig.json b/packages/create-cli/tsconfig.json new file mode 100644 index 000000000..a43ef3119 --- /dev/null +++ b/packages/create-cli/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "module": "CommonJS" + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.test.json" + } + ] +} diff --git a/packages/create-cli/tsconfig.lib.json b/packages/create-cli/tsconfig.lib.json new file mode 100644 index 000000000..213c049dc --- /dev/null +++ b/packages/create-cli/tsconfig.lib.json @@ -0,0 +1,16 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "module": "CommonJS", + "declaration": true, + "types": ["node"] + }, + "include": ["src/**/*.ts"], + "exclude": [ + "vite.config.unit.ts", + "vite.config.integration.ts", + "src/**/*.test.ts", + "test/**/*.ts" + ] +} diff --git a/packages/create-cli/tsconfig.test.json b/packages/create-cli/tsconfig.test.json new file mode 100644 index 000000000..2ac7baa82 --- /dev/null +++ b/packages/create-cli/tsconfig.test.json @@ -0,0 +1,16 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "types": ["vitest/globals", "vitest/importMeta", "vite/client", "node"] + }, + "include": [ + "vite.config.unit.ts", + "vite.config.integration.ts", + "src/**/*.test.ts", + "src/**/*.test.tsx", + "src/**/*.test.js", + "src/**/*.test.jsx", + "src/**/*.d.ts" + ] +} diff --git a/packages/create-cli/vite.config.integration.ts b/packages/create-cli/vite.config.integration.ts new file mode 100644 index 000000000..a33d66f8d --- /dev/null +++ b/packages/create-cli/vite.config.integration.ts @@ -0,0 +1,29 @@ +/// +import { defineConfig } from 'vite'; +import { tsconfigPathAliases } from '../../tools/vitest-tsconfig-path-aliases'; + +export default defineConfig({ + cacheDir: '../../node_modules/.vite/create-cli', + test: { + reporters: ['basic'], + globals: true, + cache: { + dir: '../../node_modules/.vitest', + }, + alias: tsconfigPathAliases(), + pool: 'threads', + poolOptions: { threads: { singleThread: true } }, + coverage: { + reporter: ['text', 'lcov'], + reportsDirectory: '../../coverage/create-cli/integration-tests', + exclude: ['mocks/**', '**/types.ts'], + }, + environment: 'node', + include: ['src/**/*.integration.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], + globalSetup: ['../../global-setup.ts'], + setupFiles: [ + '../../testing/test-setup/src/lib/console.mock.ts', + '../../testing/test-setup/src/lib/reset.mocks.ts', + ], + }, +}); diff --git a/packages/create-cli/vite.config.unit.ts b/packages/create-cli/vite.config.unit.ts new file mode 100644 index 000000000..7e75cc0b8 --- /dev/null +++ b/packages/create-cli/vite.config.unit.ts @@ -0,0 +1,33 @@ +/// +import { defineConfig } from 'vite'; +import { tsconfigPathAliases } from '../../tools/vitest-tsconfig-path-aliases'; + +export default defineConfig({ + cacheDir: '../../node_modules/.vite/create-cli', + test: { + reporters: ['basic'], + globals: true, + cache: { + dir: '../../node_modules/.vitest', + }, + alias: tsconfigPathAliases(), + pool: 'threads', + poolOptions: { threads: { singleThread: true } }, + coverage: { + reporter: ['text', 'lcov'], + reportsDirectory: '../../coverage/create-cli/unit-tests', + exclude: ['mocks/**', '**/types.ts'], + }, + environment: 'node', + include: ['src/**/*.unit.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], + globalSetup: ['../../global-setup.ts'], + setupFiles: [ + '../../testing/test-setup/src/lib/create-cliui.mock.ts', + '../../testing/test-setup/src/lib/fs.mock.ts', + '../../testing/test-setup/src/lib/git.mock.ts', + '../../testing/test-setup/src/lib/console.mock.ts', + '../../testing/test-setup/src/lib/portal-create-client.mock.ts', + '../../testing/test-setup/src/lib/reset.mocks.ts', + ], + }, +}); diff --git a/packages/nx-plugin/src/generators/init/README.md b/packages/nx-plugin/src/generators/init/README.md index 53e36abf2..c367aab7c 100644 --- a/packages/nx-plugin/src/generators/init/README.md +++ b/packages/nx-plugin/src/generators/init/README.md @@ -18,6 +18,7 @@ Show what will be generated without writing to disk: ## Options -| Name | type | description | -| --------------------- | --------------------------- | ---------------------------------------- | -| **--skipPackageJson** | `boolean` (DEFAULT `false`) | Skip adding `package.json` dependencies. | +| Name | type | description | +| --------------------- | --------------------------- | ------------------------------------------- | +| **--skipPackageJson** | `boolean` (DEFAULT `false`) | Skip adding `package.json` dependencies. | +| **--skipNxJson** | `boolean` (DEFAULT `false`) | Skip updating `nx.json` with configuration. | diff --git a/packages/nx-plugin/src/generators/init/generator.integration.test.ts b/packages/nx-plugin/src/generators/init/generator.integration.test.ts index 0e273bdfd..31c8ea78b 100644 --- a/packages/nx-plugin/src/generators/init/generator.integration.test.ts +++ b/packages/nx-plugin/src/generators/init/generator.integration.test.ts @@ -43,7 +43,7 @@ describe('init generator', () => { ).toHaveLength(devDependencyNames.length); }); - it('should skip packageJson', () => { + it('should skip package.json', () => { initGenerator(tree, { ...options, skipPackageJson: true }); // nx.json const targetDefaults = readNxJson(tree)!.targetDefaults!; @@ -60,4 +60,11 @@ describe('init generator', () => { ), ).toHaveLength(0); }); + + it('should skip nx.Json', () => { + initGenerator(tree, { ...options, skipNxJson: true }); + // nx.json + const targetDefaults = readNxJson(tree)!.targetDefaults!; + expect(targetDefaults).not.toHaveProperty(cpTargetName); + }); }); diff --git a/packages/nx-plugin/src/generators/init/generator.ts b/packages/nx-plugin/src/generators/init/generator.ts index d61c3dac2..9dede5c8c 100644 --- a/packages/nx-plugin/src/generators/init/generator.ts +++ b/packages/nx-plugin/src/generators/init/generator.ts @@ -79,7 +79,10 @@ export function initGenerator(tree: Tree, schema: InitGeneratorSchema) { if (!schema.skipPackageJson) { moveToDevDependencies(tree); } - updateNxJsonConfig(tree); + + if (!schema.skipNxJson) { + updateNxJsonConfig(tree); + } const tasks = []; if (!schema.skipPackageJson) { diff --git a/packages/nx-plugin/src/generators/init/schema.d.ts b/packages/nx-plugin/src/generators/init/schema.d.ts index a5122b21a..ef806a220 100644 --- a/packages/nx-plugin/src/generators/init/schema.d.ts +++ b/packages/nx-plugin/src/generators/init/schema.d.ts @@ -1,3 +1,4 @@ export type InitGeneratorSchema = { skipPackageJson: boolean; + skipNxJson: boolean; }; diff --git a/packages/nx-plugin/src/generators/init/schema.json b/packages/nx-plugin/src/generators/init/schema.json index cd1d2e116..8d08fb993 100644 --- a/packages/nx-plugin/src/generators/init/schema.json +++ b/packages/nx-plugin/src/generators/init/schema.json @@ -9,6 +9,10 @@ "type": "boolean", "description": "Skip adding package.json dependencies", "x-priority": "internal" + }, + "skipNxJson": { + "type": "boolean", + "description": "Skip updating nx.json with configuration" } } } diff --git a/packages/nx-plugin/src/index.ts b/packages/nx-plugin/src/index.ts index 2bfa26690..912425d5e 100644 --- a/packages/nx-plugin/src/index.ts +++ b/packages/nx-plugin/src/index.ts @@ -1,4 +1,7 @@ -export { InitGeneratorSchema } from './generators/init/schema'; -export { initGenerator } from './generators/init/generator'; +export * from './internal/versions'; +export { type InitGeneratorSchema } from './generators/init/schema'; +export { initGenerator, initSchematic } from './generators/init/generator'; export { ConfigurationGeneratorOptions } from './generators/configuration/schema'; export { configurationGenerator } from './generators/configuration/generator'; +export { executeProcess, ProcessConfig } from './internal/execute-process'; +export { objectToCliArgs } from './executors/internal/cli'; diff --git a/packages/nx-plugin/src/internal/execute-process.ts b/packages/nx-plugin/src/internal/execute-process.ts new file mode 100644 index 000000000..cedc3fdbc --- /dev/null +++ b/packages/nx-plugin/src/internal/execute-process.ts @@ -0,0 +1,177 @@ +import { spawn } from 'node:child_process'; + +export function calcDuration(start: number, stop?: number): number { + return Math.round((stop ?? performance.now()) - start); +} + +/** + * Represents the process result. + * @category Types + * @public + * @property {string} stdout - The stdout of the process. + * @property {string} stderr - The stderr of the process. + * @property {number | null} code - The exit code of the process. + */ +export type ProcessResult = { + stdout: string; + stderr: string; + code: number | null; + date: string; + duration: number; +}; + +/** + * Error class for process errors. + * Contains additional information about the process result. + * @category Error + * @public + * @class + * @extends Error + * @example + * const result = await executeProcess({}) + * .catch((error) => { + * if (error instanceof ProcessError) { + * console.error(error.code); + * console.error(error.stderr); + * console.error(error.stdout); + * } + * }); + * + */ +export class ProcessError extends Error { + code: number | null; + stderr: string; + stdout: string; + + constructor(result: ProcessResult) { + super(result.stderr); + this.code = result.code; + this.stderr = result.stderr; + this.stdout = result.stdout; + } +} + +/** + * Process config object. Contains the command, args and observer. + * @param cfg - process config object with command, args and observer (optional) + * @category Types + * @public + * @property {string} command - The command to execute. + * @property {string[]} args - The arguments for the command. + * @property {ProcessObserver} observer - The observer for the process. + * + * @example + * + * // bash command + * const cfg = { + * command: 'bash', + * args: ['-c', 'echo "hello world"'] + * }; + * + * // node command + * const cfg = { + * command: 'node', + * args: ['--version'] + * }; + * + * // npx command + * const cfg = { + * command: 'npx', + * args: ['--version'] + * + */ +export type ProcessConfig = { + command: string; + args?: string[]; + cwd?: string; + observer?: ProcessObserver; + ignoreExitCode?: boolean; +}; + +/** + * Process observer object. Contains the onStdout, error and complete function. + * @category Types + * @public + * @property {function} onStdout - The onStdout function of the observer (optional). + * @property {function} onError - The error function of the observer (optional). + * @property {function} onComplete - The complete function of the observer (optional). + * + * @example + * const observer = { + * onStdout: (stdout) => console.info(stdout) + * } + */ +export type ProcessObserver = { + onStdout?: (stdout: string) => void; + onError?: (error: ProcessError) => void; + onComplete?: () => void; +}; + +/** + * Executes a process and returns a promise with the result as `ProcessResult`. + * + * @example + * + * // sync process execution + * const result = await executeProcess({ + * command: 'node', + * args: ['--version'] + * }); + * + * console.info(result); + * + * // async process execution + * const result = await executeProcess({ + * command: 'node', + * args: ['download-data.js'], + * observer: { + * onStdout: updateProgress, + * error: handleError, + * complete: cleanLogs, + * } + * }); + * + * console.info(result); + * + * @param cfg - see {@link ProcessConfig} + */ +export function executeProcess(cfg: ProcessConfig): Promise { + const { observer, cwd, command, args, ignoreExitCode = false } = cfg; + const { onStdout, onError, onComplete } = observer ?? {}; + const date = new Date().toISOString(); + const start = performance.now(); + + return new Promise((resolve, reject) => { + // shell:true tells Windows to use shell command for spawning a child process + const process = spawn(command, args, { cwd, shell: true }); + // eslint-disable-next-line functional/no-let + let stdout = ''; + // eslint-disable-next-line functional/no-let + let stderr = ''; + + process.stdout.on('data', data => { + stdout += String(data); + onStdout?.(String(data)); + }); + + process.stderr.on('data', data => { + stderr += String(data); + }); + + process.on('error', err => { + stderr += err.toString(); + }); + + process.on('close', code => { + const timings = { date, duration: calcDuration(start) }; + if (code === 0 || ignoreExitCode) { + onComplete?.(); + resolve({ code, stdout, stderr, ...timings }); + } else { + const errorMsg = new ProcessError({ code, stdout, stderr, ...timings }); + onError?.(errorMsg); + reject(errorMsg); + } + }); + }); +} diff --git a/packages/nx-plugin/src/internal/execute-process.unit.test.ts b/packages/nx-plugin/src/internal/execute-process.unit.test.ts new file mode 100644 index 000000000..753675206 --- /dev/null +++ b/packages/nx-plugin/src/internal/execute-process.unit.test.ts @@ -0,0 +1,92 @@ +import { describe, expect, it, vi } from 'vitest'; +import { getAsyncProcessRunnerConfig } from '@code-pushup/test-utils'; +import { ProcessObserver, executeProcess } from './execute-process'; + +describe('executeProcess', () => { + const spyObserver: ProcessObserver = { + onStdout: vi.fn(), + onError: vi.fn(), + onComplete: vi.fn(), + }; + const errorSpy = vi.fn(); + + beforeEach(() => { + vi.clearAllMocks(); + }); + + it('should work with node command `node -v`', async () => { + const processResult = await executeProcess({ + command: `node`, + args: ['-v'], + observer: spyObserver, + }); + + // Note: called once or twice depending on environment (2nd time for a new line) + expect(spyObserver.onStdout).toHaveBeenCalled(); + expect(spyObserver.onComplete).toHaveBeenCalledOnce(); + expect(spyObserver.onError).not.toHaveBeenCalled(); + expect(processResult.stdout).toMatch(/v\d{1,2}(\.\d{1,2}){0,2}/); + }); + + it('should work with npx command `npx --help`', async () => { + const processResult = await executeProcess({ + command: `npx`, + args: ['--help'], + observer: spyObserver, + }); + expect(spyObserver.onStdout).toHaveBeenCalledOnce(); + expect(spyObserver.onComplete).toHaveBeenCalledOnce(); + expect(spyObserver.onError).not.toHaveBeenCalled(); + expect(processResult.stdout).toContain('npm exec'); + }); + + it('should work with script `node custom-script.js`', async () => { + const processResult = await executeProcess({ + ...getAsyncProcessRunnerConfig({ interval: 10, runs: 4 }), + observer: spyObserver, + }).catch(errorSpy); + + expect(errorSpy).not.toHaveBeenCalled(); + expect(processResult.stdout).toContain('process:complete'); + expect(spyObserver.onStdout).toHaveBeenCalledTimes(6); // intro + 4 runs + complete + expect(spyObserver.onError).not.toHaveBeenCalled(); + expect(spyObserver.onComplete).toHaveBeenCalledOnce(); + }); + + it('should work with async script `node custom-script.js` that throws an error', async () => { + const processResult = await executeProcess({ + ...getAsyncProcessRunnerConfig({ + interval: 10, + runs: 1, + throwError: true, + }), + observer: spyObserver, + }).catch(errorSpy); + + expect(errorSpy).toHaveBeenCalledOnce(); + expect(processResult).toBeUndefined(); + expect(spyObserver.onStdout).toHaveBeenCalledTimes(2); // intro + 1 run before error + expect(spyObserver.onError).toHaveBeenCalledOnce(); + expect(spyObserver.onComplete).not.toHaveBeenCalled(); + }); + + it('should successfully exit process after an error is thrown when ignoreExitCode is set', async () => { + const processResult = await executeProcess({ + ...getAsyncProcessRunnerConfig({ + interval: 10, + runs: 1, + throwError: true, + }), + observer: spyObserver, + ignoreExitCode: true, + }).catch(errorSpy); + + expect(errorSpy).not.toHaveBeenCalled(); + expect(processResult.code).toBe(1); + expect(processResult.stdout).toContain('process:update'); + expect(processResult.stderr).toContain('dummy-error'); + expect(spyObserver.onStdout).toHaveBeenCalledTimes(2); // intro + 1 run before error + expect(spyObserver.onError).not.toHaveBeenCalled(); + expect(spyObserver.onComplete).toHaveBeenCalledOnce(); + }); +}); From 5575872faa033bc3923defda63f81b0cdd9df497 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 3 Aug 2024 01:30:22 +0200 Subject: [PATCH 02/91] feat(create-cli): cleanup test setup --- packages/create-cli/vite.config.unit.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/create-cli/vite.config.unit.ts b/packages/create-cli/vite.config.unit.ts index 7e75cc0b8..6ceede6ef 100644 --- a/packages/create-cli/vite.config.unit.ts +++ b/packages/create-cli/vite.config.unit.ts @@ -22,11 +22,8 @@ export default defineConfig({ include: ['src/**/*.unit.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], globalSetup: ['../../global-setup.ts'], setupFiles: [ - '../../testing/test-setup/src/lib/create-cliui.mock.ts', '../../testing/test-setup/src/lib/fs.mock.ts', - '../../testing/test-setup/src/lib/git.mock.ts', '../../testing/test-setup/src/lib/console.mock.ts', - '../../testing/test-setup/src/lib/portal-create-client.mock.ts', '../../testing/test-setup/src/lib/reset.mocks.ts', ], }, From 76eeabdceff0e6f08ddabd6c3f17455bca9aca28 Mon Sep 17 00:00:00 2001 From: Michael Hladky <10064416+BioPhoton@users.noreply.github.com> Date: Mon, 5 Aug 2024 12:58:44 +0200 Subject: [PATCH 03/91] Update packages/create-cli/README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Matěj Chalk <34691111+matejchalk@users.noreply.github.com> --- packages/create-cli/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/create-cli/README.md b/packages/create-cli/README.md index 00d645948..14b33c0da 100644 --- a/packages/create-cli/README.md +++ b/packages/create-cli/README.md @@ -4,11 +4,11 @@ [![downloads](https://img.shields.io/npm/dm/%40code-pushup%2Fcreate-cli)](https://npmtrends.com/@code-pushup/create-cli) [![dependencies](https://img.shields.io/librariesio/release/npm/%40code-pushup/create-cli)](https://www.npmjs.com/package/@code-pushup/create-cli?activeTab=dependencies) -A CLI tool to set up CodePushup in your repository. +A CLI tool to set up Code PushUp in your repository. ## Usage -To set uo CodePushup run the following command: +To set up Code PushUp, run the following command: ```bash npx init @code-pushup/cli From 680aaf619e3c2aea8bf6bdd033863225d142c4de Mon Sep 17 00:00:00 2001 From: Michael Hladky <10064416+BioPhoton@users.noreply.github.com> Date: Mon, 5 Aug 2024 12:59:22 +0200 Subject: [PATCH 04/91] Update packages/create-cli/src/lib/utils.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Matěj Chalk <34691111+matejchalk@users.noreply.github.com> --- packages/create-cli/src/lib/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/create-cli/src/lib/utils.ts b/packages/create-cli/src/lib/utils.ts index b54265aae..307472925 100644 --- a/packages/create-cli/src/lib/utils.ts +++ b/packages/create-cli/src/lib/utils.ts @@ -27,7 +27,7 @@ export async function setupFile( await writeFile(filename, content); } } catch (error) { - if ((error as Error).message.includes('no such file or directory')) { + if (error instanceof Error && error.message.includes('no such file or directory')) { await writeFile(filename, content); return { ...setupResult, From 893fbb2757503098145573192b579fa55f21c4fd Mon Sep 17 00:00:00 2001 From: Michael Hladky <10064416+BioPhoton@users.noreply.github.com> Date: Mon, 5 Aug 2024 13:00:00 +0200 Subject: [PATCH 05/91] Update packages/create-cli/src/lib/utils.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Matěj Chalk <34691111+matejchalk@users.noreply.github.com> --- packages/create-cli/src/lib/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/create-cli/src/lib/utils.ts b/packages/create-cli/src/lib/utils.ts index 307472925..0c860e661 100644 --- a/packages/create-cli/src/lib/utils.ts +++ b/packages/create-cli/src/lib/utils.ts @@ -34,7 +34,7 @@ export async function setupFile( teardown: true, }; } else { - console.error((error as Error).toString()); + console.error(error); } } From 0053841927e87d6e268a865297b104d6991afab2 Mon Sep 17 00:00:00 2001 From: Michael Hladky <10064416+BioPhoton@users.noreply.github.com> Date: Mon, 5 Aug 2024 13:00:10 +0200 Subject: [PATCH 06/91] Update packages/nx-plugin/src/generators/init/generator.integration.test.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Matěj Chalk <34691111+matejchalk@users.noreply.github.com> --- .../nx-plugin/src/generators/init/generator.integration.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nx-plugin/src/generators/init/generator.integration.test.ts b/packages/nx-plugin/src/generators/init/generator.integration.test.ts index 31c8ea78b..1620f3af8 100644 --- a/packages/nx-plugin/src/generators/init/generator.integration.test.ts +++ b/packages/nx-plugin/src/generators/init/generator.integration.test.ts @@ -61,7 +61,7 @@ describe('init generator', () => { ).toHaveLength(0); }); - it('should skip nx.Json', () => { + it('should skip nx.json', () => { initGenerator(tree, { ...options, skipNxJson: true }); // nx.json const targetDefaults = readNxJson(tree)!.targetDefaults!; From da000801a9379e8890c06859025fea6f58859ca8 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 5 Aug 2024 15:02:21 +0200 Subject: [PATCH 07/91] wip --- packages/create-cli/src/index.ts | 3 +- packages/create-cli/src/lib/init.ts | 28 ++++-- packages/create-cli/src/lib/init.unit.test.ts | 92 +++++++++++++++++++ packages/create-cli/tsconfig.lib.json | 2 +- 4 files changed, 112 insertions(+), 13 deletions(-) create mode 100644 packages/create-cli/src/lib/init.unit.test.ts diff --git a/packages/create-cli/src/index.ts b/packages/create-cli/src/index.ts index 09efe0a95..456b4421d 100755 --- a/packages/create-cli/src/index.ts +++ b/packages/create-cli/src/index.ts @@ -1,5 +1,4 @@ #! /usr/bin/env node import { initCodePushup } from './lib/init'; -// eslint-disable-next-line unicorn/prefer-top-level-await -initCodePushup().catch(console.error); +await initCodePushup(); diff --git a/packages/create-cli/src/lib/init.ts b/packages/create-cli/src/lib/init.ts index ca76d0da7..7e72917b3 100644 --- a/packages/create-cli/src/lib/init.ts +++ b/packages/create-cli/src/lib/init.ts @@ -1,16 +1,16 @@ -// eslint-disable-next-line @nx/enforce-module-boundaries import { ProcessConfig, executeProcess, objectToCliArgs, -} from '@code-pushup/nx-plugin'; +} from '@code-pushup/utils'; + import { parseNxProcessOutput, setupNxContext, teardownNxContext, } from './utils'; -function nxPluginGenerator( +export function nxPluginGenerator( generator: 'init' | 'configuration', opt: Record = {}, ): ProcessConfig { @@ -26,15 +26,23 @@ function nxPluginGenerator( export async function initCodePushup() { const setupResult = await setupNxContext(); - const { stdout: initStdout, stderr: initStderr } = await executeProcess( - nxPluginGenerator('init', { - skipNxJson: true, - }), + await executeProcess( + { + ...nxPluginGenerator('init', { + skipNxJson: true, + }), + observer: { + onStdout: (data) => { + console.info(parseNxProcessOutput(data.toString())); + }, + onError: (error) => { + console.error(parseNxProcessOutput(error.message.toString())); + } + } + } ); - console.info(parseNxProcessOutput(initStdout)); - console.warn(parseNxProcessOutput(initStderr)); - const { stdout: configStdout, stderr: configStderr } = await executeProcess( + const {stdout: configStdout, stderr: configStderr} = await executeProcess( nxPluginGenerator('configuration', { skipTarget: true, project: setupResult.projectName, diff --git a/packages/create-cli/src/lib/init.unit.test.ts b/packages/create-cli/src/lib/init.unit.test.ts new file mode 100644 index 000000000..93ada3919 --- /dev/null +++ b/packages/create-cli/src/lib/init.unit.test.ts @@ -0,0 +1,92 @@ +import {beforeEach, describe, expect} from "vitest"; +import {nxPluginGenerator, initCodePushup} from "./init"; +import * as utils from "@code-pushup/utils"; +import {ProcessResult} from "@code-pushup/utils"; +import {vol} from "memfs"; +import {MEMFS_VOLUME} from "@code-pushup/test-utils"; +import * as createUtils from "./utils"; + +describe("nxPluginGenerator", () => { + it("should create valid command", () => { + expect(nxPluginGenerator("init", {skipNxJson: true})).toStrictEqual({ + command: "npx", + args: ["nx", "g", "@code-pushup/nx-plugin:init", "--skipNxJson"], + }); + }) +}); + + +describe("initCodePushup", () => { + const spyExecuteProcess = vi.spyOn(utils, "executeProcess"); + const spyParseNxProcessOutput = vi.spyOn(createUtils, "parseNxProcessOutput"); + const spySetupNxContext= vi.spyOn(createUtils, "setupNxContext"); + const spyTeardownNxContext = vi.spyOn(createUtils, "teardownNxContext"); + + beforeEach(() => { + // needed to get test folder set up + vol.fromJSON({ + "random-file": '', + }, MEMFS_VOLUME); + vol.rm('random-file', () => void 0); + }) + + it("should add packages and create config file", async () => { + const projectJson= {name: 'my-lib'}; + + vol.fromJSON({ + "nx.json": "{}", + "project.json": JSON.stringify(projectJson), + }, MEMFS_VOLUME) + + spyExecuteProcess.mockResolvedValue({stdout: "stdout-mock", stderr: ""} as ProcessResult); + + await initCodePushup(); + + expect(spySetupNxContext).toHaveBeenCalledTimes(1); + + expect(spyExecuteProcess).toHaveBeenNthCalledWith(1, { + command: "npx", + args: ["nx", "g", "@code-pushup/nx-plugin:init", "--skipNxJson"], + observer: expect.any(Object) + }); + expect(spyParseNxProcessOutput).toHaveBeenNthCalledWith(1, "stdout-mock"); + expect(spyExecuteProcess).toHaveBeenNthCalledWith(2, { + command: "npx", + args: ["nx", "g", "@code-pushup/nx-plugin:configuration", "--skipTarget", `--project="${projectJson.name}"`] + }); + expect(spyParseNxProcessOutput).toHaveBeenNthCalledWith(1, "stdout-mock"); + expect(spyParseNxProcessOutput).toHaveBeenCalledTimes(2); + expect(spyExecuteProcess).toHaveBeenCalledTimes(2); + expect(spyTeardownNxContext).toHaveBeenCalledTimes(1); + expect(spyTeardownNxContext).toHaveBeenNthCalledWith(1, {projectName: projectJson.name, nxJsonTeardown: false, projectJsonTeardown: false}); + }); + + it("should teardown nx.json if set up", async () => { + const projectJson= {name: 'my-lib'}; + vol.fromJSON({ + "project.json": JSON.stringify(projectJson), + }, MEMFS_VOLUME) + + spyExecuteProcess.mockResolvedValue({stdout: "stdout-mock", stderr: ""} as ProcessResult); + + await initCodePushup(); + + expect(spySetupNxContext).toHaveBeenCalledTimes(1); + expect(spyTeardownNxContext).toHaveBeenCalledTimes(1); + expect(spyTeardownNxContext).toHaveBeenNthCalledWith(1, {projectName: projectJson.name, nxJsonTeardown: true, projectJsonTeardown: false}); + }); + + it("should teardown project.json if set up", async () => { + vol.fromJSON({ + "nx.json": "{}", + }, MEMFS_VOLUME) + + spyExecuteProcess.mockResolvedValue({stdout: "stdout-mock", stderr: ""} as ProcessResult); + + await initCodePushup(); + + expect(spySetupNxContext).toHaveBeenCalledTimes(1); + expect(spyTeardownNxContext).toHaveBeenCalledTimes(1); + expect(spyTeardownNxContext).toHaveBeenNthCalledWith(1, {projectName: 'source-root', nxJsonTeardown: false, projectJsonTeardown: true}); + }); +}); diff --git a/packages/create-cli/tsconfig.lib.json b/packages/create-cli/tsconfig.lib.json index 213c049dc..46f3c1d03 100644 --- a/packages/create-cli/tsconfig.lib.json +++ b/packages/create-cli/tsconfig.lib.json @@ -2,7 +2,7 @@ "extends": "./tsconfig.json", "compilerOptions": { "outDir": "../../dist/out-tsc", - "module": "CommonJS", + "module": "ESNext", "declaration": true, "types": ["node"] }, From 2ec8a5cd2025ddbce866415481e01b4d1daf5308 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 5 Aug 2024 16:06:41 +0200 Subject: [PATCH 08/91] test(create-cli): add tests, switch to e2m --- packages/create-cli/project.json | 2 +- packages/create-cli/src/lib/init.ts | 31 ++-- packages/create-cli/src/lib/init.unit.test.ts | 142 +++++++++++------- packages/create-cli/src/lib/utils.ts | 5 +- .../create-cli/src/lib/utils.unit.test.ts | 98 ++++++++++++ 5 files changed, 207 insertions(+), 71 deletions(-) create mode 100644 packages/create-cli/src/lib/utils.unit.test.ts diff --git a/packages/create-cli/project.json b/packages/create-cli/project.json index 2f888f2b8..d4002cfa7 100644 --- a/packages/create-cli/project.json +++ b/packages/create-cli/project.json @@ -52,5 +52,5 @@ "options": {} } }, - "tags": ["scope:core", "type:app"] + "tags": ["scope:tooling", "type:app"] } diff --git a/packages/create-cli/src/lib/init.ts b/packages/create-cli/src/lib/init.ts index 7e72917b3..21a4d1a32 100644 --- a/packages/create-cli/src/lib/init.ts +++ b/packages/create-cli/src/lib/init.ts @@ -3,7 +3,6 @@ import { executeProcess, objectToCliArgs, } from '@code-pushup/utils'; - import { parseNxProcessOutput, setupNxContext, @@ -26,23 +25,21 @@ export function nxPluginGenerator( export async function initCodePushup() { const setupResult = await setupNxContext(); - await executeProcess( - { - ...nxPluginGenerator('init', { - skipNxJson: true, - }), - observer: { - onStdout: (data) => { - console.info(parseNxProcessOutput(data.toString())); - }, - onError: (error) => { - console.error(parseNxProcessOutput(error.message.toString())); - } - } - } - ); + await executeProcess({ + ...nxPluginGenerator('init', { + skipNxJson: true, + }), + observer: { + onStdout: data => { + console.info(parseNxProcessOutput(data.toString())); + }, + onError: error => { + console.error(parseNxProcessOutput(error.message.toString())); + }, + }, + }); - const {stdout: configStdout, stderr: configStderr} = await executeProcess( + const { stdout: configStdout, stderr: configStderr } = await executeProcess( nxPluginGenerator('configuration', { skipTarget: true, project: setupResult.projectName, diff --git a/packages/create-cli/src/lib/init.unit.test.ts b/packages/create-cli/src/lib/init.unit.test.ts index 93ada3919..8ee6f998c 100644 --- a/packages/create-cli/src/lib/init.unit.test.ts +++ b/packages/create-cli/src/lib/init.unit.test.ts @@ -1,92 +1,130 @@ -import {beforeEach, describe, expect} from "vitest"; -import {nxPluginGenerator, initCodePushup} from "./init"; -import * as utils from "@code-pushup/utils"; -import {ProcessResult} from "@code-pushup/utils"; -import {vol} from "memfs"; -import {MEMFS_VOLUME} from "@code-pushup/test-utils"; -import * as createUtils from "./utils"; - -describe("nxPluginGenerator", () => { - it("should create valid command", () => { - expect(nxPluginGenerator("init", {skipNxJson: true})).toStrictEqual({ - command: "npx", - args: ["nx", "g", "@code-pushup/nx-plugin:init", "--skipNxJson"], +import { vol } from 'memfs'; +import { beforeEach, describe, expect } from 'vitest'; +import { MEMFS_VOLUME } from '@code-pushup/test-utils'; +import * as utils from '@code-pushup/utils'; +import { ProcessResult } from '@code-pushup/utils'; +import { initCodePushup, nxPluginGenerator } from './init'; +import * as createUtils from './utils'; + +describe('nxPluginGenerator', () => { + it('should create valid command', () => { + expect(nxPluginGenerator('init', { skipNxJson: true })).toStrictEqual({ + command: 'npx', + args: ['nx', 'g', '@code-pushup/nx-plugin:init', '--skipNxJson'], }); - }) + }); }); - -describe("initCodePushup", () => { - const spyExecuteProcess = vi.spyOn(utils, "executeProcess"); - const spyParseNxProcessOutput = vi.spyOn(createUtils, "parseNxProcessOutput"); - const spySetupNxContext= vi.spyOn(createUtils, "setupNxContext"); - const spyTeardownNxContext = vi.spyOn(createUtils, "teardownNxContext"); +describe('initCodePushup', () => { + const spyExecuteProcess = vi.spyOn(utils, 'executeProcess'); + const spyParseNxProcessOutput = vi.spyOn(createUtils, 'parseNxProcessOutput'); + const spySetupNxContext = vi.spyOn(createUtils, 'setupNxContext'); + const spyTeardownNxContext = vi.spyOn(createUtils, 'teardownNxContext'); beforeEach(() => { // needed to get test folder set up - vol.fromJSON({ - "random-file": '', - }, MEMFS_VOLUME); + vol.fromJSON( + { + 'random-file': '', + }, + MEMFS_VOLUME, + ); vol.rm('random-file', () => void 0); - }) + }); - it("should add packages and create config file", async () => { - const projectJson= {name: 'my-lib'}; + it('should add packages and create config file', async () => { + const projectJson = { name: 'my-lib' }; - vol.fromJSON({ - "nx.json": "{}", - "project.json": JSON.stringify(projectJson), - }, MEMFS_VOLUME) + vol.fromJSON( + { + 'nx.json': '{}', + 'project.json': JSON.stringify(projectJson), + }, + MEMFS_VOLUME, + ); - spyExecuteProcess.mockResolvedValue({stdout: "stdout-mock", stderr: ""} as ProcessResult); + spyExecuteProcess.mockResolvedValue({ + stdout: 'stdout-mock', + stderr: '', + } as ProcessResult); await initCodePushup(); expect(spySetupNxContext).toHaveBeenCalledTimes(1); expect(spyExecuteProcess).toHaveBeenNthCalledWith(1, { - command: "npx", - args: ["nx", "g", "@code-pushup/nx-plugin:init", "--skipNxJson"], - observer: expect.any(Object) + command: 'npx', + args: ['nx', 'g', '@code-pushup/nx-plugin:init', '--skipNxJson'], + observer: expect.any(Object), }); - expect(spyParseNxProcessOutput).toHaveBeenNthCalledWith(1, "stdout-mock"); + expect(spyParseNxProcessOutput).toHaveBeenNthCalledWith(1, 'stdout-mock'); expect(spyExecuteProcess).toHaveBeenNthCalledWith(2, { - command: "npx", - args: ["nx", "g", "@code-pushup/nx-plugin:configuration", "--skipTarget", `--project="${projectJson.name}"`] + command: 'npx', + args: [ + 'nx', + 'g', + '@code-pushup/nx-plugin:configuration', + '--skipTarget', + `--project="${projectJson.name}"`, + ], }); - expect(spyParseNxProcessOutput).toHaveBeenNthCalledWith(1, "stdout-mock"); + expect(spyParseNxProcessOutput).toHaveBeenNthCalledWith(1, 'stdout-mock'); expect(spyParseNxProcessOutput).toHaveBeenCalledTimes(2); expect(spyExecuteProcess).toHaveBeenCalledTimes(2); expect(spyTeardownNxContext).toHaveBeenCalledTimes(1); - expect(spyTeardownNxContext).toHaveBeenNthCalledWith(1, {projectName: projectJson.name, nxJsonTeardown: false, projectJsonTeardown: false}); + expect(spyTeardownNxContext).toHaveBeenNthCalledWith(1, { + projectName: projectJson.name, + nxJsonTeardown: false, + projectJsonTeardown: false, + }); }); - it("should teardown nx.json if set up", async () => { - const projectJson= {name: 'my-lib'}; - vol.fromJSON({ - "project.json": JSON.stringify(projectJson), - }, MEMFS_VOLUME) + it('should teardown nx.json if set up', async () => { + const projectJson = { name: 'my-lib' }; + vol.fromJSON( + { + 'project.json': JSON.stringify(projectJson), + }, + MEMFS_VOLUME, + ); - spyExecuteProcess.mockResolvedValue({stdout: "stdout-mock", stderr: ""} as ProcessResult); + spyExecuteProcess.mockResolvedValue({ + stdout: 'stdout-mock', + stderr: '', + } as ProcessResult); await initCodePushup(); expect(spySetupNxContext).toHaveBeenCalledTimes(1); expect(spyTeardownNxContext).toHaveBeenCalledTimes(1); - expect(spyTeardownNxContext).toHaveBeenNthCalledWith(1, {projectName: projectJson.name, nxJsonTeardown: true, projectJsonTeardown: false}); + expect(spyTeardownNxContext).toHaveBeenNthCalledWith(1, { + projectName: projectJson.name, + nxJsonTeardown: true, + projectJsonTeardown: false, + }); }); - it("should teardown project.json if set up", async () => { - vol.fromJSON({ - "nx.json": "{}", - }, MEMFS_VOLUME) + it('should teardown project.json if set up', async () => { + vol.fromJSON( + { + 'nx.json': '{}', + }, + MEMFS_VOLUME, + ); - spyExecuteProcess.mockResolvedValue({stdout: "stdout-mock", stderr: ""} as ProcessResult); + spyExecuteProcess.mockResolvedValue({ + stdout: 'stdout-mock', + stderr: '', + } as ProcessResult); await initCodePushup(); expect(spySetupNxContext).toHaveBeenCalledTimes(1); expect(spyTeardownNxContext).toHaveBeenCalledTimes(1); - expect(spyTeardownNxContext).toHaveBeenNthCalledWith(1, {projectName: 'source-root', nxJsonTeardown: false, projectJsonTeardown: true}); + expect(spyTeardownNxContext).toHaveBeenNthCalledWith(1, { + projectName: 'source-root', + nxJsonTeardown: false, + projectJsonTeardown: true, + }); }); }); diff --git a/packages/create-cli/src/lib/utils.ts b/packages/create-cli/src/lib/utils.ts index 0c860e661..876f0d9c7 100644 --- a/packages/create-cli/src/lib/utils.ts +++ b/packages/create-cli/src/lib/utils.ts @@ -27,7 +27,10 @@ export async function setupFile( await writeFile(filename, content); } } catch (error) { - if (error instanceof Error && error.message.includes('no such file or directory')) { + if ( + error instanceof Error && + error.message.includes('no such file or directory') + ) { await writeFile(filename, content); return { ...setupResult, diff --git a/packages/create-cli/src/lib/utils.unit.test.ts b/packages/create-cli/src/lib/utils.unit.test.ts new file mode 100644 index 000000000..7e7db1135 --- /dev/null +++ b/packages/create-cli/src/lib/utils.unit.test.ts @@ -0,0 +1,98 @@ +import { vol } from 'memfs'; +import { rm } from 'node:fs/promises'; +import { beforeEach, describe, expect } from 'vitest'; +import { + parseNxProcessOutput, + setupNxContext, + teardownNxContext, +} from './utils'; + +describe('parseNxProcessOutput', () => { + it('should replace NX with <↗>', () => { + expect(parseNxProcessOutput('NX some message')).toBe('<↗> some message'); + }); +}); + +describe('setupNxContext', () => { + beforeEach(async () => { + vol.reset(); + // to have the test folder set up we need to recreate it + vol.fromJSON({ + '.': '', + }); + await rm('.'); + }); + + it('should setup nx.json', async () => { + vol.fromJSON({ + 'project.json': '{"name": "my-lib"}', + }); + await expect(setupNxContext()).resolves.toStrictEqual({ + nxJsonTeardown: true, + projectJsonTeardown: false, + projectName: 'my-lib', + }); + expect(vol.toJSON()).toStrictEqual({ + '/test/nx.json': + '{"$schema":"./node_modules/nx/schemas/nx-schema.json","releaseTagPattern":"v{version}","targetDefaults":{}}', + '/test/project.json': '{"name": "my-lib"}', + }); + }); + + it('should setup project.json', async () => { + vol.fromJSON({ + 'nx.json': '{}', + }); + await expect(setupNxContext()).resolves.toStrictEqual({ + nxJsonTeardown: false, + projectJsonTeardown: true, + projectName: 'source-root', + }); + expect(vol.toJSON()).toStrictEqual({ + '/test/nx.json': '{}', + '/test/project.json': + '{"$schema":"node_modules/nx/schemas/project-schema.json","name":"source-root"}', + }); + }); +}); + +describe('teardownNxContext', () => { + beforeEach(async () => { + vol.reset(); + // to have the test folder set up we need to recreate it + vol.fromJSON({ + '.': '', + }); + await rm('.'); + }); + + it('should delete nx.json', async () => { + vol.fromJSON({ + 'nx.json': '{}', + }); + await expect( + teardownNxContext({ + nxJsonTeardown: true, + projectJsonTeardown: false, + }), + ).resolves.toBeUndefined(); + expect(vol.toJSON()).toStrictEqual({ + '/test': null, + }); + }); + + it('should delete project.json', async () => { + vol.fromJSON({ + 'project.json': '{}', + }); + await expect( + teardownNxContext({ + nxJsonTeardown: false, + projectJsonTeardown: true, + }), + ).resolves.toBeUndefined(); + expect(vol.toJSON()).toStrictEqual({ + '/test': null, + }); + }); +}); From a448431abeed403c61bab6dbfc20fee018598584 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 5 Aug 2024 18:24:48 +0200 Subject: [PATCH 09/91] test(create-cli): add e2e tests --- e2e/create-cli-e2e/.eslintrc.json | 12 ++++ .../mocks/create-npm-workshpace.ts | 14 ++++ e2e/create-cli-e2e/project.json | 23 +++++++ e2e/create-cli-e2e/tests/init.e2e.test.ts | 65 +++++++++++++++++++ e2e/create-cli-e2e/tsconfig.json | 20 ++++++ e2e/create-cli-e2e/tsconfig.test.json | 13 ++++ e2e/create-cli-e2e/vite.config.e2e.ts | 22 +++++++ global-setup.e2e.ts | 2 + packages/create-cli/package.json | 2 +- packages/create-cli/src/index.ts | 2 +- packages/create-cli/src/lib/init.ts | 2 +- packages/create-cli/tsconfig.lib.json | 2 +- 12 files changed, 175 insertions(+), 4 deletions(-) create mode 100644 e2e/create-cli-e2e/.eslintrc.json create mode 100644 e2e/create-cli-e2e/mocks/create-npm-workshpace.ts create mode 100644 e2e/create-cli-e2e/project.json create mode 100644 e2e/create-cli-e2e/tests/init.e2e.test.ts create mode 100644 e2e/create-cli-e2e/tsconfig.json create mode 100644 e2e/create-cli-e2e/tsconfig.test.json create mode 100644 e2e/create-cli-e2e/vite.config.e2e.ts diff --git a/e2e/create-cli-e2e/.eslintrc.json b/e2e/create-cli-e2e/.eslintrc.json new file mode 100644 index 000000000..8cc915b39 --- /dev/null +++ b/e2e/create-cli-e2e/.eslintrc.json @@ -0,0 +1,12 @@ +{ + "extends": ["../../.eslintrc.json"], + "ignorePatterns": ["!**/*", "code-pushup.config*.ts"], + "overrides": [ + { + "files": ["*.ts", "*.tsx"], + "parserOptions": { + "project": ["e2e/create-cli-e2e/tsconfig.*?.json"] + } + } + ] +} diff --git a/e2e/create-cli-e2e/mocks/create-npm-workshpace.ts b/e2e/create-cli-e2e/mocks/create-npm-workshpace.ts new file mode 100644 index 000000000..69c9f76db --- /dev/null +++ b/e2e/create-cli-e2e/mocks/create-npm-workshpace.ts @@ -0,0 +1,14 @@ +import {mkdir, writeFile} from "node:fs/promises"; +import {join} from "node:path"; + +export async function createNpmWorkspace(cwd: string) { + await mkdir(cwd, {recursive: true}); + await writeFile(join(cwd, 'package.json'), JSON.stringify({ + name: 'create-npm-workspace', + version: '0.0.1', + scripts: { + test: 'echo "Error: no test specified" && exit 1', + }, + keywords: [], + }, null, 2)); +} diff --git a/e2e/create-cli-e2e/project.json b/e2e/create-cli-e2e/project.json new file mode 100644 index 000000000..ecb0d138f --- /dev/null +++ b/e2e/create-cli-e2e/project.json @@ -0,0 +1,23 @@ +{ + "name": "create-cli-e2e", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "examples/create-cli-e2e/src", + "projectType": "application", + "targets": { + "lint": { + "executor": "@nx/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["e2e/create-cli-e2e/**/*.ts"] + } + }, + "e2e": { + "executor": "@nx/vite:test", + "options": { + "configFile": "e2e/create-cli-e2e/vite.config.e2e.ts" + } + } + }, + "implicitDependencies": ["create-cli"], + "tags": ["scope:tooling", "type:e2e"] +} diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts new file mode 100644 index 000000000..fd659315a --- /dev/null +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -0,0 +1,65 @@ +import {afterEach, expect} from 'vitest'; +import {removeColorCodes} from '@code-pushup/test-utils'; +import {executeProcess} from '@code-pushup/utils'; +import {join, relative} from "node:path"; +import {createNpmWorkspace} from "../mocks/create-npm-workshpace"; +import {rm} from "node:fs/promises"; + +describe('create-cli-node', () => { + const baseDir = join('tmp','create-cli-e2e'); + const promptTitle = '<↗> Generating @code-pushup/nx-plugin:configuration'; + const bin = 'dist/packages/create-cli' + const binPath = (cwd?: string) => cwd ? relative(join( process.cwd(), cwd), join( process.cwd(), bin)) : bin; + + afterEach(async () => { + await rm(baseDir, {recursive: true}) + }) + + it('should execute index.js correctly over node', async () => { + const cwd = join(baseDir, 'node'); + await createNpmWorkspace(cwd); + // If we use ESM the following error is thrown + // Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'dist/packages/create-cli/src/lib/init' imported from dist/packages/create-cli/src/index.js + const { code, stdout } = await executeProcess({ + command: 'node', + args: [join(binPath(cwd), 'src/index.js')], + cwd, + observer: { onStdout: console.info }, + }); + + expect(code).toBe(0); + const cleanedStdout = removeColorCodes(stdout); + expect(cleanedStdout).toContain(promptTitle); + }); + + it.skip('should execute index.js correctly over npm exec', async () => { + const cwd = join(baseDir, 'exec') + await createNpmWorkspace(cwd); + // Error: sh: /Users//.npm/_npx/9876543/node_modules/.bin/create-cli: Permission denied + const { code, stdout } = await executeProcess({ + command: 'npm', + args: ['exec', '@code-pushup/create-cli'], + cwd, + observer: { onStdout: console.info }, + }); + + expect(code).toBe(0); + const cleanedStdout = removeColorCodes(stdout); + expect(cleanedStdout).toContain(promptTitle); }); + + it.skip('should execute index.js correctly over npx init', async () => { + const cwd = join(baseDir, 'init') + await createNpmWorkspace(cwd); + // Error: npm ERR! could not determine executable to run + const { code, stdout } = await executeProcess({ + command: 'npx', + args: ['init', '@code-pushup/create-cli'], + cwd, + observer: { onStdout: console.info }, + }); + + expect(code).toBe(0); + const cleanedStdout = removeColorCodes(stdout); + expect(cleanedStdout).toContain(promptTitle); + }); +}); diff --git a/e2e/create-cli-e2e/tsconfig.json b/e2e/create-cli-e2e/tsconfig.json new file mode 100644 index 000000000..f5a2f890a --- /dev/null +++ b/e2e/create-cli-e2e/tsconfig.json @@ -0,0 +1,20 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "module": "ESNext", + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "types": ["vitest"] + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.test.json" + } + ] +} diff --git a/e2e/create-cli-e2e/tsconfig.test.json b/e2e/create-cli-e2e/tsconfig.test.json new file mode 100644 index 000000000..cc6383cf6 --- /dev/null +++ b/e2e/create-cli-e2e/tsconfig.test.json @@ -0,0 +1,13 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "types": ["vitest/globals", "vitest/importMeta", "vite/client", "node"] + }, + "include": [ + "vite.config.e2e.ts", + "tests/**/*.e2e.test.ts", + "tests/**/*.d.ts", + "mocks/**/*.ts" + ] +} diff --git a/e2e/create-cli-e2e/vite.config.e2e.ts b/e2e/create-cli-e2e/vite.config.e2e.ts new file mode 100644 index 000000000..6000c97cf --- /dev/null +++ b/e2e/create-cli-e2e/vite.config.e2e.ts @@ -0,0 +1,22 @@ +/// +import { defineConfig } from 'vite'; +import { tsconfigPathAliases } from '../../tools/vitest-tsconfig-path-aliases'; + +export default defineConfig({ + cacheDir: '../../node_modules/.vite/create-cli-e2e', + test: { + reporters: ['basic'], + testTimeout: 60_000, + globals: true, + alias: tsconfigPathAliases(), + pool: 'threads', + poolOptions: { threads: { singleThread: true } }, + cache: { + dir: '../../node_modules/.vitest', + }, + environment: 'node', + include: ['tests/**/*.e2e.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], + globalSetup: ['../../global-setup.e2e.ts'], + setupFiles: ['../../testing/test-setup/src/lib/reset.mocks.ts'], + }, +}); diff --git a/global-setup.e2e.ts b/global-setup.e2e.ts index c0a2ecbf4..43501f47c 100644 --- a/global-setup.e2e.ts +++ b/global-setup.e2e.ts @@ -8,6 +8,7 @@ export async function setup() { await globalSetup(); await startLocalRegistry(); execSync('npm install -D @code-pushup/cli@e2e'); + execSync('npm install -D @code-pushup/create-cli@e2e'); execSync('npm install -D @code-pushup/nx-plugin@e2e'); execSync('npm install -D @code-pushup/eslint-plugin@e2e'); execSync('npm install -D @code-pushup/coverage-plugin@e2e'); @@ -17,6 +18,7 @@ export async function setup() { export async function teardown() { stopLocalRegistry(); execSync('npm uninstall @code-pushup/cli'); + execSync('npm uninstall @code-pushup/create-cli'); execSync('npm uninstall @code-pushup/nx-plugin'); execSync('npm uninstall @code-pushup/eslint-plugin'); execSync('npm uninstall @code-pushup/coverage-plugin'); diff --git a/packages/create-cli/package.json b/packages/create-cli/package.json index 21ecb1fbe..96482f96c 100644 --- a/packages/create-cli/package.json +++ b/packages/create-cli/package.json @@ -4,7 +4,7 @@ "license": "MIT", "bin": "src/index.js", "dependencies": { - "@code-pushup/nx-plugin": "^0.48.0", + "@code-pushup/nx-plugin": "*", "tslib": "^2.6.2" } } diff --git a/packages/create-cli/src/index.ts b/packages/create-cli/src/index.ts index 456b4421d..4dedd141d 100755 --- a/packages/create-cli/src/index.ts +++ b/packages/create-cli/src/index.ts @@ -1,4 +1,4 @@ #! /usr/bin/env node import { initCodePushup } from './lib/init'; -await initCodePushup(); +initCodePushup().catch(console.error); diff --git a/packages/create-cli/src/lib/init.ts b/packages/create-cli/src/lib/init.ts index 21a4d1a32..de1708af5 100644 --- a/packages/create-cli/src/lib/init.ts +++ b/packages/create-cli/src/lib/init.ts @@ -2,7 +2,7 @@ import { ProcessConfig, executeProcess, objectToCliArgs, -} from '@code-pushup/utils'; +} from '@code-pushup/nx-plugin'; import { parseNxProcessOutput, setupNxContext, diff --git a/packages/create-cli/tsconfig.lib.json b/packages/create-cli/tsconfig.lib.json index 46f3c1d03..213c049dc 100644 --- a/packages/create-cli/tsconfig.lib.json +++ b/packages/create-cli/tsconfig.lib.json @@ -2,7 +2,7 @@ "extends": "./tsconfig.json", "compilerOptions": { "outDir": "../../dist/out-tsc", - "module": "ESNext", + "module": "CommonJS", "declaration": true, "types": ["node"] }, From 6689820f626b2c43d7a3fe639d6ad5e55f8884ae Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 5 Aug 2024 19:07:43 +0200 Subject: [PATCH 10/91] wip --- .eslintrc.json | 2 +- e2e/create-cli-e2e/tests/init.e2e.test.ts | 33 ++++++++++--------- packages/create-cli/src/index.ts | 1 + packages/create-cli/src/lib/init.unit.test.ts | 25 +++++++------- 4 files changed, 32 insertions(+), 29 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 06bca06ee..c23edc7d0 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -26,7 +26,7 @@ }, { "sourceTag": "scope:tooling", - "onlyDependOnLibsWithTags": ["scope:shared"] + "onlyDependOnLibsWithTags": ["scope:tooling", "scope:shared"] }, { "sourceTag": "type:e2e", diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index fd659315a..b24d5044f 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -1,19 +1,20 @@ -import {afterEach, expect} from 'vitest'; -import {removeColorCodes} from '@code-pushup/test-utils'; -import {executeProcess} from '@code-pushup/utils'; -import {join, relative} from "node:path"; -import {createNpmWorkspace} from "../mocks/create-npm-workshpace"; -import {rm} from "node:fs/promises"; +import { rm } from 'node:fs/promises'; +import { join, relative } from 'node:path'; +import { afterEach, expect } from 'vitest'; +import { removeColorCodes } from '@code-pushup/test-utils'; +import { executeProcess } from '@code-pushup/utils'; +import { createNpmWorkspace } from '../mocks/create-npm-workshpace'; describe('create-cli-node', () => { - const baseDir = join('tmp','create-cli-e2e'); + const baseDir = join('tmp', 'create-cli-e2e'); const promptTitle = '<↗> Generating @code-pushup/nx-plugin:configuration'; - const bin = 'dist/packages/create-cli' - const binPath = (cwd?: string) => cwd ? relative(join( process.cwd(), cwd), join( process.cwd(), bin)) : bin; + const bin = 'dist/packages/create-cli'; + const binPath = (cwd?: string) => + cwd ? relative(join(process.cwd(), cwd), join(process.cwd(), bin)) : bin; afterEach(async () => { - await rm(baseDir, {recursive: true}) - }) + await rm(baseDir, { recursive: true }); + }); it('should execute index.js correctly over node', async () => { const cwd = join(baseDir, 'node'); @@ -24,7 +25,6 @@ describe('create-cli-node', () => { command: 'node', args: [join(binPath(cwd), 'src/index.js')], cwd, - observer: { onStdout: console.info }, }); expect(code).toBe(0); @@ -32,8 +32,9 @@ describe('create-cli-node', () => { expect(cleanedStdout).toContain(promptTitle); }); + // eslint-disable-next-line vitest/no-disabled-tests it.skip('should execute index.js correctly over npm exec', async () => { - const cwd = join(baseDir, 'exec') + const cwd = join(baseDir, 'exec'); await createNpmWorkspace(cwd); // Error: sh: /Users//.npm/_npx/9876543/node_modules/.bin/create-cli: Permission denied const { code, stdout } = await executeProcess({ @@ -45,10 +46,12 @@ describe('create-cli-node', () => { expect(code).toBe(0); const cleanedStdout = removeColorCodes(stdout); - expect(cleanedStdout).toContain(promptTitle); }); + expect(cleanedStdout).toContain(promptTitle); + }); + // eslint-disable-next-line vitest/no-disabled-tests it.skip('should execute index.js correctly over npx init', async () => { - const cwd = join(baseDir, 'init') + const cwd = join(baseDir, 'init'); await createNpmWorkspace(cwd); // Error: npm ERR! could not determine executable to run const { code, stdout } = await executeProcess({ diff --git a/packages/create-cli/src/index.ts b/packages/create-cli/src/index.ts index 4dedd141d..09efe0a95 100755 --- a/packages/create-cli/src/index.ts +++ b/packages/create-cli/src/index.ts @@ -1,4 +1,5 @@ #! /usr/bin/env node import { initCodePushup } from './lib/init'; +// eslint-disable-next-line unicorn/prefer-top-level-await initCodePushup().catch(console.error); diff --git a/packages/create-cli/src/lib/init.unit.test.ts b/packages/create-cli/src/lib/init.unit.test.ts index 8ee6f998c..d035efd2f 100644 --- a/packages/create-cli/src/lib/init.unit.test.ts +++ b/packages/create-cli/src/lib/init.unit.test.ts @@ -1,8 +1,8 @@ import { vol } from 'memfs'; -import { beforeEach, describe, expect } from 'vitest'; +import { afterEach, beforeEach, describe, expect } from 'vitest'; +import * as utils from '@code-pushup/nx-plugin'; import { MEMFS_VOLUME } from '@code-pushup/test-utils'; -import * as utils from '@code-pushup/utils'; -import { ProcessResult } from '@code-pushup/utils'; +import type { ProcessResult } from '@code-pushup/utils'; import { initCodePushup, nxPluginGenerator } from './init'; import * as createUtils from './utils'; @@ -30,6 +30,15 @@ describe('initCodePushup', () => { MEMFS_VOLUME, ); vol.rm('random-file', () => void 0); + + spyExecuteProcess.mockResolvedValue({ + stdout: 'stdout-mock', + stderr: '', + } as ProcessResult); + }); + + afterEach(() => { + spyExecuteProcess.mockReset(); }); it('should add packages and create config file', async () => { @@ -43,11 +52,6 @@ describe('initCodePushup', () => { MEMFS_VOLUME, ); - spyExecuteProcess.mockResolvedValue({ - stdout: 'stdout-mock', - stderr: '', - } as ProcessResult); - await initCodePushup(); expect(spySetupNxContext).toHaveBeenCalledTimes(1); @@ -88,11 +92,6 @@ describe('initCodePushup', () => { MEMFS_VOLUME, ); - spyExecuteProcess.mockResolvedValue({ - stdout: 'stdout-mock', - stderr: '', - } as ProcessResult); - await initCodePushup(); expect(spySetupNxContext).toHaveBeenCalledTimes(1); From b6fc94b71fba5e6dd0c4b04215651ea2850ff08a Mon Sep 17 00:00:00 2001 From: Michael Hladky <10064416+BioPhoton@users.noreply.github.com> Date: Mon, 5 Aug 2024 21:18:08 +0200 Subject: [PATCH 11/91] Update packages/create-cli/project.json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Matěj Chalk <34691111+matejchalk@users.noreply.github.com> --- packages/create-cli/project.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/create-cli/project.json b/packages/create-cli/project.json index d4002cfa7..bef969fc4 100644 --- a/packages/create-cli/project.json +++ b/packages/create-cli/project.json @@ -3,7 +3,6 @@ "$schema": "../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/create-cli/src", "projectType": "application", - "implicitDependencies": ["nx-plugin"], "targets": { "build": { "dependsOn": ["^build"], From 1e72a72227ca57191a7d8f45d07d0751065ca6ff Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 5 Aug 2024 21:20:30 +0200 Subject: [PATCH 12/91] fix --- packages/create-cli/src/lib/constants.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/create-cli/src/lib/constants.ts b/packages/create-cli/src/lib/constants.ts index 764b88f5a..bffac6c15 100644 --- a/packages/create-cli/src/lib/constants.ts +++ b/packages/create-cli/src/lib/constants.ts @@ -1,7 +1,6 @@ export const NX_JSON_FILENAME = 'nx.json'; export const NX_JSON_CONTENT = JSON.stringify({ $schema: './node_modules/nx/schemas/nx-schema.json', - releaseTagPattern: 'v{version}', targetDefaults: {}, }); export const PROJECT_NAME = 'source-root'; From ce691649c8cf6934989f2645fde34404e2cadc11 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 13 Aug 2024 13:41:47 +0200 Subject: [PATCH 13/91] fix publish script --- packages/create-cli/project.json | 2 +- .../src/generators/init/generator.integration.test.ts | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/create-cli/project.json b/packages/create-cli/project.json index bef969fc4..7574441d7 100644 --- a/packages/create-cli/project.json +++ b/packages/create-cli/project.json @@ -15,7 +15,7 @@ } }, "publish": { - "command": "node tools/scripts/publish.mjs create-cli {args.ver} {args.tag}", + "command": "node tools/scripts/publish.mjs --name='create-cli' --ver='{args.ver}' --tag='{args.tag}'", "dependsOn": ["build"] }, "lint": { diff --git a/packages/nx-plugin/src/generators/init/generator.integration.test.ts b/packages/nx-plugin/src/generators/init/generator.integration.test.ts index 4f621bc2b..6f559b43e 100644 --- a/packages/nx-plugin/src/generators/init/generator.integration.test.ts +++ b/packages/nx-plugin/src/generators/init/generator.integration.test.ts @@ -2,7 +2,6 @@ import { Tree, logger, readJson, readNxJson } from '@nx/devkit'; import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'; import { describe, expect, it, vi } from 'vitest'; import { initGenerator } from './generator'; -import { InitGeneratorSchema } from './schema'; type PackageJson = { devDependencies: Record; @@ -20,7 +19,6 @@ const devDependencyNames = [ describe('init generator', () => { let tree: Tree; const loggerInfoSpy = vi.spyOn(logger, 'info'); - const options: InitGeneratorSchema = { skipPackageJson: false }; beforeEach(() => { tree = createTreeWithEmptyWorkspace(); @@ -45,7 +43,7 @@ describe('init generator', () => { }); it('should skip package.json', () => { - initGenerator(tree, { ...options, skipPackageJson: true }); + initGenerator(tree, { skipPackageJson: true }); // nx.json const targetDefaults = readNxJson(tree)!.targetDefaults!; expect(targetDefaults).toHaveProperty(cpTargetName); @@ -83,7 +81,7 @@ describe('init generator', () => { }); it('should skip nx.json', () => { - initGenerator(tree, { ...options, skipNxJson: true }); + initGenerator(tree, { skipNxJson: true }); // nx.json const targetDefaults = readNxJson(tree)!.targetDefaults!; expect(targetDefaults).not.toHaveProperty(cpTargetName); From 87c76cf0a700042f9386c8d7aea57c5f86072c7f Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 13 Aug 2024 13:44:02 +0200 Subject: [PATCH 14/91] fix lint --- .../nx-plugin/src/executors/internal/config.unit.test.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/nx-plugin/src/executors/internal/config.unit.test.ts b/packages/nx-plugin/src/executors/internal/config.unit.test.ts index b6791a2e8..2f9a0aeb3 100644 --- a/packages/nx-plugin/src/executors/internal/config.unit.test.ts +++ b/packages/nx-plugin/src/executors/internal/config.unit.test.ts @@ -75,7 +75,7 @@ describe('globalConfig', () => { }, }, ); - expect(osAgnosticPath(config)).toStrictEqual( + expect(osAgnosticPath(String(config))).toStrictEqual( expect.stringContaining( osAgnosticPath('project-root/code-pushup.config.ts'), ), @@ -173,7 +173,7 @@ describe('persistConfig', () => { }, }, ); - expect(osAgnosticPath(outputDir)).toBe( + expect(osAgnosticPath(String(outputDir))).toBe( osAgnosticPath(`/test/root/workspace-root/.code-pushup/${projectName}`), ); }); @@ -192,7 +192,7 @@ describe('persistConfig', () => { }, }, ); - expect(osAgnosticPath(resultingOutDir)).toEqual( + expect(osAgnosticPath(String(resultingOutDir))).toEqual( expect.stringContaining(osAgnosticPath('../dist/packages/test-folder')), ); }); @@ -205,7 +205,7 @@ describe('persistConfig', () => { }, ); - expect(osAgnosticPath(outputDir)).toEqual( + expect(osAgnosticPath(String(outputDir))).toEqual( expect.stringContaining(osAgnosticPath('.code-pushup')), ); }); From aa12d3d0db078ca248f6aa6a8c7f5e9884400e53 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 13 Aug 2024 13:50:20 +0200 Subject: [PATCH 15/91] refactor tests --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index b24d5044f..a79cc95f0 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -7,7 +7,6 @@ import { createNpmWorkspace } from '../mocks/create-npm-workshpace'; describe('create-cli-node', () => { const baseDir = join('tmp', 'create-cli-e2e'); - const promptTitle = '<↗> Generating @code-pushup/nx-plugin:configuration'; const bin = 'dist/packages/create-cli'; const binPath = (cwd?: string) => cwd ? relative(join(process.cwd(), cwd), join(process.cwd(), bin)) : bin; @@ -29,7 +28,9 @@ describe('create-cli-node', () => { expect(code).toBe(0); const cleanedStdout = removeColorCodes(stdout); - expect(cleanedStdout).toContain(promptTitle); + expect(cleanedStdout).toContain( + '<↗> Generating @code-pushup/nx-plugin:configuration', + ); }); // eslint-disable-next-line vitest/no-disabled-tests @@ -46,7 +47,9 @@ describe('create-cli-node', () => { expect(code).toBe(0); const cleanedStdout = removeColorCodes(stdout); - expect(cleanedStdout).toContain(promptTitle); + expect(cleanedStdout).toContain( + '<↗> Generating @code-pushup/nx-plugin:configuration', + ); }); // eslint-disable-next-line vitest/no-disabled-tests @@ -63,6 +66,8 @@ describe('create-cli-node', () => { expect(code).toBe(0); const cleanedStdout = removeColorCodes(stdout); - expect(cleanedStdout).toContain(promptTitle); + expect(cleanedStdout).toContain( + '<↗> Generating @code-pushup/nx-plugin:configuration', + ); }); }); From 43ef1f1a35236d37a026240a36d634f5cd1a6536 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Chalk?= Date: Wed, 14 Aug 2024 10:42:48 +0200 Subject: [PATCH 16/91] build(create-cli): convert to esm --- .github/workflows/ci.yml | 2 +- e2e/create-cli-e2e/tests/init.e2e.test.ts | 16 +++++----------- packages/create-cli/.eslintrc.json | 7 ++++++- packages/create-cli/package.json | 4 ++-- packages/create-cli/project.json | 9 +++++---- packages/create-cli/src/lib/init.ts | 2 +- packages/create-cli/src/lib/init.unit.test.ts | 2 +- packages/create-cli/tsconfig.json | 2 +- packages/create-cli/tsconfig.lib.json | 1 - 9 files changed, 22 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a9dba2f14..86f40a40a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -133,7 +133,7 @@ jobs: - name: Install dependencies run: npm ci - name: E2E test affected projects - run: npx nx affected:e2e --parallel=3 + run: npx nx affected:e2e --parallel=1 build: runs-on: ubuntu-latest diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index a79cc95f0..33ded285c 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -18,11 +18,9 @@ describe('create-cli-node', () => { it('should execute index.js correctly over node', async () => { const cwd = join(baseDir, 'node'); await createNpmWorkspace(cwd); - // If we use ESM the following error is thrown - // Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'dist/packages/create-cli/src/lib/init' imported from dist/packages/create-cli/src/index.js const { code, stdout } = await executeProcess({ command: 'node', - args: [join(binPath(cwd), 'src/index.js')], + args: [join(binPath(cwd), 'index.js')], cwd, }); @@ -33,11 +31,9 @@ describe('create-cli-node', () => { ); }); - // eslint-disable-next-line vitest/no-disabled-tests - it.skip('should execute index.js correctly over npm exec', async () => { + it('should execute package correctly over npm exec', async () => { const cwd = join(baseDir, 'exec'); await createNpmWorkspace(cwd); - // Error: sh: /Users//.npm/_npx/9876543/node_modules/.bin/create-cli: Permission denied const { code, stdout } = await executeProcess({ command: 'npm', args: ['exec', '@code-pushup/create-cli'], @@ -52,14 +48,12 @@ describe('create-cli-node', () => { ); }); - // eslint-disable-next-line vitest/no-disabled-tests - it.skip('should execute index.js correctly over npx init', async () => { + it('should execute package correctly over npm init', async () => { const cwd = join(baseDir, 'init'); await createNpmWorkspace(cwd); - // Error: npm ERR! could not determine executable to run const { code, stdout } = await executeProcess({ - command: 'npx', - args: ['init', '@code-pushup/create-cli'], + command: 'npm', + args: ['init', '@code-pushup/cli'], cwd, observer: { onStdout: console.info }, }); diff --git a/packages/create-cli/.eslintrc.json b/packages/create-cli/.eslintrc.json index fce4ee64f..3da6a1047 100644 --- a/packages/create-cli/.eslintrc.json +++ b/packages/create-cli/.eslintrc.json @@ -13,7 +13,12 @@ "files": ["*.json"], "parser": "jsonc-eslint-parser", "rules": { - "@nx/dependency-checks": ["error"] + "@nx/dependency-checks": [ + "error", + { + "ignoredDependencies": ["@code-pushup/nx-plugin"] // nx-plugin is run via CLI + } + ] } } ] diff --git a/packages/create-cli/package.json b/packages/create-cli/package.json index 96482f96c..35c6ce234 100644 --- a/packages/create-cli/package.json +++ b/packages/create-cli/package.json @@ -2,9 +2,9 @@ "name": "@code-pushup/create-cli", "version": "0.0.0", "license": "MIT", - "bin": "src/index.js", + "bin": "index.js", "dependencies": { "@code-pushup/nx-plugin": "*", - "tslib": "^2.6.2" + "@code-pushup/utils": "*" } } diff --git a/packages/create-cli/project.json b/packages/create-cli/project.json index 7574441d7..76574b9d6 100644 --- a/packages/create-cli/project.json +++ b/packages/create-cli/project.json @@ -5,13 +5,14 @@ "projectType": "application", "targets": { "build": { - "dependsOn": ["^build"], - "executor": "@nx/js:tsc", + "executor": "@nx/esbuild:esbuild", "outputs": ["{options.outputPath}"], "options": { "outputPath": "dist/packages/create-cli", "main": "packages/create-cli/src/index.ts", - "tsConfig": "packages/create-cli/tsconfig.lib.json" + "tsConfig": "packages/create-cli/tsconfig.lib.json", + "assets": ["packages/create-cli/*.md"], + "esbuildConfig": "esbuild.config.js" } }, "publish": { @@ -42,7 +43,7 @@ }, "exec-node": { "dependsOn": ["build"], - "command": "node ./dist/packages/create-cli/src/index.js", + "command": "node ./dist/packages/create-cli/index.js", "options": {} }, "exec-npm": { diff --git a/packages/create-cli/src/lib/init.ts b/packages/create-cli/src/lib/init.ts index de1708af5..21a4d1a32 100644 --- a/packages/create-cli/src/lib/init.ts +++ b/packages/create-cli/src/lib/init.ts @@ -2,7 +2,7 @@ import { ProcessConfig, executeProcess, objectToCliArgs, -} from '@code-pushup/nx-plugin'; +} from '@code-pushup/utils'; import { parseNxProcessOutput, setupNxContext, diff --git a/packages/create-cli/src/lib/init.unit.test.ts b/packages/create-cli/src/lib/init.unit.test.ts index d035efd2f..09073d610 100644 --- a/packages/create-cli/src/lib/init.unit.test.ts +++ b/packages/create-cli/src/lib/init.unit.test.ts @@ -1,8 +1,8 @@ import { vol } from 'memfs'; import { afterEach, beforeEach, describe, expect } from 'vitest'; -import * as utils from '@code-pushup/nx-plugin'; import { MEMFS_VOLUME } from '@code-pushup/test-utils'; import type { ProcessResult } from '@code-pushup/utils'; +import * as utils from '@code-pushup/utils'; import { initCodePushup, nxPluginGenerator } from './init'; import * as createUtils from './utils'; diff --git a/packages/create-cli/tsconfig.json b/packages/create-cli/tsconfig.json index a43ef3119..088e7dc47 100644 --- a/packages/create-cli/tsconfig.json +++ b/packages/create-cli/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "module": "CommonJS" + "module": "ESNext" }, "files": [], "include": [], diff --git a/packages/create-cli/tsconfig.lib.json b/packages/create-cli/tsconfig.lib.json index 213c049dc..e1bbb7dde 100644 --- a/packages/create-cli/tsconfig.lib.json +++ b/packages/create-cli/tsconfig.lib.json @@ -2,7 +2,6 @@ "extends": "./tsconfig.json", "compilerOptions": { "outDir": "../../dist/out-tsc", - "module": "CommonJS", "declaration": true, "types": ["node"] }, From f594b1028bb212d42d1a9f216d1037bc1a4a2b36 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 14 Aug 2024 16:47:22 +0200 Subject: [PATCH 17/91] add docs --- packages/create-cli/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/create-cli/README.md b/packages/create-cli/README.md index 14b33c0da..006fc9391 100644 --- a/packages/create-cli/README.md +++ b/packages/create-cli/README.md @@ -14,6 +14,13 @@ To set up Code PushUp, run the following command: npx init @code-pushup/cli ``` +alternatives: + +```bash +npx @code-pushup/create-cli +npm exec @code-pushup/create-cli +``` + It should generate the following output: ```bash From 888f2d567ddcb1ed2d9afee63a0efc7de5e4548a Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 14 Aug 2024 16:51:25 +0200 Subject: [PATCH 18/91] format --- packages/create-cli/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/create-cli/README.md b/packages/create-cli/README.md index 006fc9391..2f54a8d1c 100644 --- a/packages/create-cli/README.md +++ b/packages/create-cli/README.md @@ -16,7 +16,7 @@ npx init @code-pushup/cli alternatives: -```bash +```bash npx @code-pushup/create-cli npm exec @code-pushup/create-cli ``` From 6ce122d2a61da733622e5b68e702a8fd8f8f3eff Mon Sep 17 00:00:00 2001 From: Michael Hladky <10064416+BioPhoton@users.noreply.github.com> Date: Wed, 14 Aug 2024 18:02:37 +0200 Subject: [PATCH 19/91] Update e2e/create-cli-e2e/mocks/create-npm-workshpace.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Matěj Chalk <34691111+matejchalk@users.noreply.github.com> --- e2e/create-cli-e2e/mocks/create-npm-workshpace.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e/create-cli-e2e/mocks/create-npm-workshpace.ts b/e2e/create-cli-e2e/mocks/create-npm-workshpace.ts index 69c9f76db..62b6942b5 100644 --- a/e2e/create-cli-e2e/mocks/create-npm-workshpace.ts +++ b/e2e/create-cli-e2e/mocks/create-npm-workshpace.ts @@ -1,8 +1,8 @@ -import {mkdir, writeFile} from "node:fs/promises"; -import {join} from "node:path"; +import { mkdir, writeFile } from "node:fs/promises"; +import { join } from "node:path"; export async function createNpmWorkspace(cwd: string) { - await mkdir(cwd, {recursive: true}); + await mkdir(cwd, { recursive: true }); await writeFile(join(cwd, 'package.json'), JSON.stringify({ name: 'create-npm-workspace', version: '0.0.1', From b1f9b90308377b8a81a99bbb31ae324f879d2713 Mon Sep 17 00:00:00 2001 From: Michael Hladky <10064416+BioPhoton@users.noreply.github.com> Date: Wed, 14 Aug 2024 18:02:51 +0200 Subject: [PATCH 20/91] Update packages/create-cli/src/index.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Matěj Chalk <34691111+matejchalk@users.noreply.github.com> --- packages/create-cli/src/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/create-cli/src/index.ts b/packages/create-cli/src/index.ts index 09efe0a95..456b4421d 100755 --- a/packages/create-cli/src/index.ts +++ b/packages/create-cli/src/index.ts @@ -1,5 +1,4 @@ #! /usr/bin/env node import { initCodePushup } from './lib/init'; -// eslint-disable-next-line unicorn/prefer-top-level-await -initCodePushup().catch(console.error); +await initCodePushup(); From 8f60d0fdc6184c77c64cd63602e3664ad34324c9 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 15 Aug 2024 18:59:36 +0200 Subject: [PATCH 21/91] wip --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 015ce8660..4b8cb386f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,11 +25,11 @@ This table provides a quick overview of the environmental setup, with detailed e **❗️** Test Inclusion Logic - `INCLUDE_SLOW_TESTS='false'` skips long tests. -- without `INCLUDE_SLOW_TESTS`, tests run if `CI` is set. +- Without `INCLUDE_SLOW_TESTS`, tests run if `CI` is set. **❗️❗️** Windows specific path set only in CI -- some setups also require this setting locally +- Some setups also require this setting locally. ## Development From 1026cd61e2c8c0e046c78868b2af191083b67706 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 15 Aug 2024 19:09:05 +0200 Subject: [PATCH 22/91] wip --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index 33ded285c..e86bc9d83 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -46,7 +46,7 @@ describe('create-cli-node', () => { expect(cleanedStdout).toContain( '<↗> Generating @code-pushup/nx-plugin:configuration', ); - }); + }, 70_000); it('should execute package correctly over npm init', async () => { const cwd = join(baseDir, 'init'); From ca08853fe75a60cc40647df74db03e95f23f00b0 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 15 Aug 2024 19:10:05 +0200 Subject: [PATCH 23/91] wip --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index e86bc9d83..597bdc9fd 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -16,7 +16,7 @@ describe('create-cli-node', () => { }); it('should execute index.js correctly over node', async () => { - const cwd = join(baseDir, 'node'); + const cwd = join(baseDir, 'node-index.js'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ command: 'node', @@ -32,7 +32,7 @@ describe('create-cli-node', () => { }); it('should execute package correctly over npm exec', async () => { - const cwd = join(baseDir, 'exec'); + const cwd = join(baseDir, 'npm-exec'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ command: 'npm', @@ -49,7 +49,7 @@ describe('create-cli-node', () => { }, 70_000); it('should execute package correctly over npm init', async () => { - const cwd = join(baseDir, 'init'); + const cwd = join(baseDir, 'npm-init'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ command: 'npm', From 3f7f7fbfd0a94f64efe1c620c4c7b94f7264af75 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 15 Aug 2024 19:21:16 +0200 Subject: [PATCH 24/91] wip --- e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts b/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts index dd02aa1d5..17d7e8075 100644 --- a/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts +++ b/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts @@ -217,7 +217,7 @@ describe('nx-plugin', () => { expect(cleanStdout).toContain( 'NX Successfully ran target code-pushup for project my-lib', ); - }); + }, 70_000); it('should consider plugin option bin in executor target', async () => { const cwd = join(baseDir, 'configuration-option-bin'); From a2ff5e8a28885f7e9d94a75cb4bbf25d7387d079 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Aug 2024 13:25:15 +0200 Subject: [PATCH 25/91] fix --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index 597bdc9fd..1d5b55cd3 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -12,7 +12,7 @@ describe('create-cli-node', () => { cwd ? relative(join(process.cwd(), cwd), join(process.cwd(), bin)) : bin; afterEach(async () => { - await rm(baseDir, { recursive: true }); + await rm(baseDir, { recursive: true, force: true }); }); it('should execute index.js correctly over node', async () => { From d013d923fcbb7ea9350d94d3ec48a8d40e2e9210 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Aug 2024 13:36:47 +0200 Subject: [PATCH 26/91] fix --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index 1d5b55cd3..0a01c9d63 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -46,7 +46,7 @@ describe('create-cli-node', () => { expect(cleanedStdout).toContain( '<↗> Generating @code-pushup/nx-plugin:configuration', ); - }, 70_000); + }); it('should execute package correctly over npm init', async () => { const cwd = join(baseDir, 'npm-init'); From 33eac1f8f9b4d771076086cb335e82db9446b80a Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Aug 2024 13:41:22 +0200 Subject: [PATCH 27/91] fix --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index 0a01c9d63..67adf04ac 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -15,7 +15,8 @@ describe('create-cli-node', () => { await rm(baseDir, { recursive: true, force: true }); }); - it('should execute index.js correctly over node', async () => { + // eslint-disable-next-line vitest/no-disabled-tests + it.skip('should execute index.js correctly over node', async () => { const cwd = join(baseDir, 'node-index.js'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ @@ -31,7 +32,8 @@ describe('create-cli-node', () => { ); }); - it('should execute package correctly over npm exec', async () => { + // eslint-disable-next-line vitest/no-disabled-tests + it.skip('should execute package correctly over npm exec', async () => { const cwd = join(baseDir, 'npm-exec'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ From dd991b756a904f4453e4798cf49edbd44eb34e59 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Aug 2024 15:36:42 +0200 Subject: [PATCH 28/91] fix --- tools/scripts/publish.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/scripts/publish.mjs b/tools/scripts/publish.mjs index d3180f49f..2fa5fd808 100644 --- a/tools/scripts/publish.mjs +++ b/tools/scripts/publish.mjs @@ -25,7 +25,7 @@ function invariant(condition, message) { const validVersion = /^\d+\.\d+\.\d+(-\w+\.\d+)?/; // Executing publish script: node path/to/publish.mjs {name} --version {version} --tag {tag} -// Default "tag" to "next" so we won't publish the "latest" tag by accident. +// Default "tag" to "next" so we won't publish the "latest" tag by accident const { name, ver: version, From eb4b4a2c66c83d50bd9605e7473dd6847efb2017 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Aug 2024 15:45:30 +0200 Subject: [PATCH 29/91] test CI stability --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index 67adf04ac..2ea7d95db 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -32,7 +32,7 @@ describe('create-cli-node', () => { ); }); - // eslint-disable-next-line vitest/no-disabled-tests + // eslint-disable-next-line vitest/no-disabled-tests. it.skip('should execute package correctly over npm exec', async () => { const cwd = join(baseDir, 'npm-exec'); await createNpmWorkspace(cwd); From 9cb2284300a912be68fcd441d0f0cc146016bc26 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Aug 2024 15:52:16 +0200 Subject: [PATCH 30/91] test CI stability --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index 2ea7d95db..c17a1eee9 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -32,8 +32,7 @@ describe('create-cli-node', () => { ); }); - // eslint-disable-next-line vitest/no-disabled-tests. - it.skip('should execute package correctly over npm exec', async () => { + it('should execute package correctly over npm exec', async () => { const cwd = join(baseDir, 'npm-exec'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ From 35768f8b72d4af691723053ede44718b1e6dc3b8 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Aug 2024 16:03:28 +0200 Subject: [PATCH 31/91] test CI stability --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index c17a1eee9..0a01c9d63 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -15,8 +15,7 @@ describe('create-cli-node', () => { await rm(baseDir, { recursive: true, force: true }); }); - // eslint-disable-next-line vitest/no-disabled-tests - it.skip('should execute index.js correctly over node', async () => { + it('should execute index.js correctly over node', async () => { const cwd = join(baseDir, 'node-index.js'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ From b1e31db2fe12db6cf5148f02ab5ace127d9cc69d Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Aug 2024 16:14:42 +0200 Subject: [PATCH 32/91] test CI stability --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 2 +- e2e/nx-plugin-e2e/tests/init.e2e.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index 0a01c9d63..e5a1b927e 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -16,7 +16,7 @@ describe('create-cli-node', () => { }); it('should execute index.js correctly over node', async () => { - const cwd = join(baseDir, 'node-index.js'); + const cwd = join(baseDir, 'node-index-js'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ command: 'node', diff --git a/e2e/nx-plugin-e2e/tests/init.e2e.test.ts b/e2e/nx-plugin-e2e/tests/init.e2e.test.ts index d88a0ec48..3e61b2725 100644 --- a/e2e/nx-plugin-e2e/tests/init.e2e.test.ts +++ b/e2e/nx-plugin-e2e/tests/init.e2e.test.ts @@ -109,7 +109,7 @@ describe('nx-plugin g init', () => { args: [ 'nx', 'g', - `${relativePathToDist(cwd)}:init `, + `${relativePathToDist(cwd)}:init`, project, '--skipInstall', '--skipPackageJson', From 65a7987655559879ea4d50fc4a5912ec979766a6 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Aug 2024 16:22:53 +0200 Subject: [PATCH 33/91] test CI stability 1 e2e --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index e5a1b927e..7585a9773 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -16,7 +16,7 @@ describe('create-cli-node', () => { }); it('should execute index.js correctly over node', async () => { - const cwd = join(baseDir, 'node-index-js'); + const cwd = join(baseDir, 'node-index'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ command: 'node', From 050f32ad04bed7cec194bfb15e81e3634763798e Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Aug 2024 16:23:06 +0200 Subject: [PATCH 34/91] test CI stability 1 e2e --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index 7585a9773..e5a1b927e 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -16,7 +16,7 @@ describe('create-cli-node', () => { }); it('should execute index.js correctly over node', async () => { - const cwd = join(baseDir, 'node-index'); + const cwd = join(baseDir, 'node-index-js'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ command: 'node', From 045c8c5752399e3916e6f630ec59cf8bb6a618a9 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Aug 2024 16:23:26 +0200 Subject: [PATCH 35/91] test CI stability 1 e2e --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index e5a1b927e..7585a9773 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -16,7 +16,7 @@ describe('create-cli-node', () => { }); it('should execute index.js correctly over node', async () => { - const cwd = join(baseDir, 'node-index-js'); + const cwd = join(baseDir, 'node-index'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ command: 'node', From d682bc47719f9157a7458ef610aeab5337d8f519 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Aug 2024 16:23:36 +0200 Subject: [PATCH 36/91] test CI stability 1 e2e --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index 7585a9773..e5a1b927e 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -16,7 +16,7 @@ describe('create-cli-node', () => { }); it('should execute index.js correctly over node', async () => { - const cwd = join(baseDir, 'node-index'); + const cwd = join(baseDir, 'node-index-js'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ command: 'node', From 0536feeb736d989e730e1a5ed569834a29cf0481 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Aug 2024 16:27:01 +0200 Subject: [PATCH 37/91] test CI stability 2 e2e --- e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts b/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts index 17d7e8075..3d7d9f75e 100644 --- a/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts +++ b/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts @@ -242,7 +242,7 @@ describe('nx-plugin', () => { }); }); - it('should NOT add targets dynamically if plugin is not registered', async () => { + it('should NOT add targets dynamically if plugin is NOT registered', async () => { const cwd = join(baseDir, 'plugin-not-registered'); await materializeTree(tree, cwd); From 86c155e96862f529e32dc4d08d1f0e3d253cbec0 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Aug 2024 16:27:10 +0200 Subject: [PATCH 38/91] test CI stability 2 e2e --- e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts b/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts index 3d7d9f75e..17d7e8075 100644 --- a/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts +++ b/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts @@ -242,7 +242,7 @@ describe('nx-plugin', () => { }); }); - it('should NOT add targets dynamically if plugin is NOT registered', async () => { + it('should NOT add targets dynamically if plugin is not registered', async () => { const cwd = join(baseDir, 'plugin-not-registered'); await materializeTree(tree, cwd); From 5eeb402f8933a30c326c238087fd02a55ce11037 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Aug 2024 16:27:22 +0200 Subject: [PATCH 39/91] test CI stability 2 e2e --- e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts b/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts index 17d7e8075..dd02aa1d5 100644 --- a/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts +++ b/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts @@ -217,7 +217,7 @@ describe('nx-plugin', () => { expect(cleanStdout).toContain( 'NX Successfully ran target code-pushup for project my-lib', ); - }, 70_000); + }); it('should consider plugin option bin in executor target', async () => { const cwd = join(baseDir, 'configuration-option-bin'); From bb792c31b87ea33b3202f521c0def348d6bcba66 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Aug 2024 16:27:38 +0200 Subject: [PATCH 40/91] test CI stability 2 e2e --- e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts b/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts index dd02aa1d5..3bf6973c3 100644 --- a/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts +++ b/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts @@ -242,7 +242,7 @@ describe('nx-plugin', () => { }); }); - it('should NOT add targets dynamically if plugin is not registered', async () => { + it('should NOT add targets dynamically if plugin is NOT registered', async () => { const cwd = join(baseDir, 'plugin-not-registered'); await materializeTree(tree, cwd); From a2cf726c61512caa5d990c98c14c342bfdbbba69 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Aug 2024 16:27:49 +0200 Subject: [PATCH 41/91] test CI stability 2 e2e --- e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts b/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts index 3bf6973c3..dd02aa1d5 100644 --- a/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts +++ b/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts @@ -242,7 +242,7 @@ describe('nx-plugin', () => { }); }); - it('should NOT add targets dynamically if plugin is NOT registered', async () => { + it('should NOT add targets dynamically if plugin is not registered', async () => { const cwd = join(baseDir, 'plugin-not-registered'); await materializeTree(tree, cwd); From a5ddfafaf25ee9148bd47914328b4aa52bb04e5c Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Aug 2024 16:27:59 +0200 Subject: [PATCH 42/91] test CI stability 2 e2e --- e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts b/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts index dd02aa1d5..3bf6973c3 100644 --- a/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts +++ b/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts @@ -242,7 +242,7 @@ describe('nx-plugin', () => { }); }); - it('should NOT add targets dynamically if plugin is not registered', async () => { + it('should NOT add targets dynamically if plugin is NOT registered', async () => { const cwd = join(baseDir, 'plugin-not-registered'); await materializeTree(tree, cwd); From 138b6204c44d3b19b75c8627cd1a2d9cbb05a1b3 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Aug 2024 17:32:22 +0200 Subject: [PATCH 43/91] no cleanup --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 2 +- global-setup.e2e.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index e5a1b927e..7585a9773 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -16,7 +16,7 @@ describe('create-cli-node', () => { }); it('should execute index.js correctly over node', async () => { - const cwd = join(baseDir, 'node-index-js'); + const cwd = join(baseDir, 'node-index'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ command: 'node', diff --git a/global-setup.e2e.ts b/global-setup.e2e.ts index 43501f47c..df8226775 100644 --- a/global-setup.e2e.ts +++ b/global-setup.e2e.ts @@ -22,6 +22,5 @@ export async function teardown() { execSync('npm uninstall @code-pushup/nx-plugin'); execSync('npm uninstall @code-pushup/eslint-plugin'); execSync('npm uninstall @code-pushup/coverage-plugin'); - await teardownTestFolder('tmp/e2e'); await teardownTestFolder('tmp/local-registry'); } From b6b6a4f6bec004c4523c6dec9b7818a44f0732fa Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Aug 2024 18:00:38 +0200 Subject: [PATCH 44/91] wip --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index 7585a9773..8b5c91bdb 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -31,7 +31,7 @@ describe('create-cli-node', () => { ); }); - it('should execute package correctly over npm exec', async () => { + it.skip('should execute package correctly over npm exec', async () => { const cwd = join(baseDir, 'npm-exec'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ From 93b4f779fbf9e9415a050f9c23b8b136fa80aee9 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Aug 2024 18:01:02 +0200 Subject: [PATCH 45/91] wip --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index 8b5c91bdb..4dc9132f7 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -31,6 +31,7 @@ describe('create-cli-node', () => { ); }); + // eslint-disable-next-line vitest/no-disabled-tests it.skip('should execute package correctly over npm exec', async () => { const cwd = join(baseDir, 'npm-exec'); await createNpmWorkspace(cwd); From d28e8c5dba7e1d5727fef55d7617cc5a61fbfe98 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Aug 2024 18:01:59 +0200 Subject: [PATCH 46/91] wip --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index 4dc9132f7..cb7577739 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -49,7 +49,8 @@ describe('create-cli-node', () => { ); }); - it('should execute package correctly over npm init', async () => { + // eslint-disable-next-line vitest/no-disabled-tests + it.skip('should execute package correctly over npm init', async () => { const cwd = join(baseDir, 'npm-init'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ From e9856aa6970fe728ca6150c99936f2b194d842e6 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Aug 2024 18:12:51 +0200 Subject: [PATCH 47/91] wip --- global-setup.e2e.ts | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/global-setup.e2e.ts b/global-setup.e2e.ts index df8226775..055dcb451 100644 --- a/global-setup.e2e.ts +++ b/global-setup.e2e.ts @@ -1,26 +1,36 @@ -import { execSync } from 'child_process'; +import { execFileSync, execSync } from 'child_process'; import { setup as globalSetup } from './global-setup'; import { setupTestFolder, teardownTestFolder } from './testing/test-setup/src'; import startLocalRegistry from './tools/scripts/start-local-registry'; import stopLocalRegistry from './tools/scripts/stop-local-registry'; +const localRegistryNxTarget = '@code-pushup/cli-source:local-registry'; + export async function setup() { await globalSetup(); - await startLocalRegistry(); - execSync('npm install -D @code-pushup/cli@e2e'); - execSync('npm install -D @code-pushup/create-cli@e2e'); - execSync('npm install -D @code-pushup/nx-plugin@e2e'); - execSync('npm install -D @code-pushup/eslint-plugin@e2e'); - execSync('npm install -D @code-pushup/coverage-plugin@e2e'); - await setupTestFolder('tmp/e2e'); + try { + await setupTestFolder('tmp/local-registry'); + await startLocalRegistry({ localRegistryTarget: localRegistryNxTarget }); + console.info('Installing packages'); + execFileSync( + 'npx', + ['nx', 'run-many', '--targets=npm-install', '--parallel=1'], + { env: process.env, stdio: 'inherit', shell: true }, + ); + await setupTestFolder('tmp/e2e'); + } catch (error) { + console.info('setup error: ' + error.message); + } } export async function teardown() { stopLocalRegistry(); - execSync('npm uninstall @code-pushup/cli'); - execSync('npm uninstall @code-pushup/create-cli'); - execSync('npm uninstall @code-pushup/nx-plugin'); - execSync('npm uninstall @code-pushup/eslint-plugin'); - execSync('npm uninstall @code-pushup/coverage-plugin'); + console.info('Uninstalling packages'); + execFileSync( + 'npx', + ['nx', 'run-many', '--targets=npm-uninstall', '--parallel=1'], + { env: process.env, stdio: 'inherit', shell: true }, + ); + await teardownTestFolder('tmp/e2e'); await teardownTestFolder('tmp/local-registry'); } From d988c35db3eb656750573fdad2913c3310a5ab24 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Aug 2024 18:16:42 +0200 Subject: [PATCH 48/91] wip --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index cb7577739..fcf7ec667 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -15,7 +15,8 @@ describe('create-cli-node', () => { await rm(baseDir, { recursive: true, force: true }); }); - it('should execute index.js correctly over node', async () => { + // eslint-disable-next-line vitest/no-disabled-tests + it.skip('should execute index.js correctly over node', async () => { const cwd = join(baseDir, 'node-index'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ @@ -49,8 +50,7 @@ describe('create-cli-node', () => { ); }); - // eslint-disable-next-line vitest/no-disabled-tests - it.skip('should execute package correctly over npm init', async () => { + it.('should execute package correctly over npm init', async () => { const cwd = join(baseDir, 'npm-init'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ From 704e1f75bde4bc7ea1728a871d61ab8cc9f9688e Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Aug 2024 18:16:52 +0200 Subject: [PATCH 49/91] wip --- tsconfig.base.json | 50 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/tsconfig.base.json b/tsconfig.base.json index 37287d514..ffc448860 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -12,30 +12,56 @@ "importHelpers": true, "target": "es2022", "module": "esnext", - "lib": ["es2020", "dom"], + "lib": [ + "es2020", + "dom" + ], "skipLibCheck": true, "skipDefaultLibCheck": true, "baseUrl": ".", "resolveJsonModule": true, "allowSyntheticDefaultImports": true, "paths": { - "@code-pushup/cli": ["packages/cli/src/index.ts"], - "@code-pushup/core": ["packages/core/src/index.ts"], - "@code-pushup/coverage-plugin": ["packages/plugin-coverage/src/index.ts"], - "@code-pushup/eslint-plugin": ["packages/plugin-eslint/src/index.ts"], + "@code-pushup/cli": [ + "packages/cli/src/index.ts" + ], + "@code-pushup/core": [ + "packages/core/src/index.ts" + ], + "@code-pushup/coverage-plugin": [ + "packages/plugin-coverage/src/index.ts" + ], + "@code-pushup/eslint-plugin": [ + "packages/plugin-eslint/src/index.ts" + ], "@code-pushup/js-packages-plugin": [ "packages/plugin-js-packages/src/index.ts" ], "@code-pushup/lighthouse-plugin": [ "packages/plugin-lighthouse/src/index.ts" ], - "@code-pushup/models": ["packages/models/src/index.ts"], - "@code-pushup/nx-plugin": ["packages/nx-plugin/src/index.ts"], - "@code-pushup/test-nx-utils": ["testing/test-nx-utils/src/index.ts"], - "@code-pushup/test-setup": ["testing/test-setup/src/index.ts"], - "@code-pushup/test-utils": ["testing/test-utils/src/index.ts"], - "@code-pushup/utils": ["packages/utils/src/index.ts"] + "@code-pushup/models": [ + "packages/models/src/index.ts" + ], + "@code-pushup/nx-plugin": [ + "packages/nx-plugin/src/index.ts" + ], + "@code-pushup/test-nx-utils": [ + "testing/test-nx-utils/src/index.ts" + ], + "@code-pushup/test-setup": [ + "testing/test-setup/src/index.ts" + ], + "@code-pushup/test-utils": [ + "testing/test-utils/src/index.ts" + ], + "@code-pushup/utils": [ + "packages/utils/src/index.ts" + ] } }, - "exclude": ["node_modules", "tmp"] + "exclude": [ + "node_modules", + "tmp" + ] } From 925a4f5f0b466e3bbf474c718fe097aa3ffecc2a Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Aug 2024 18:19:42 +0200 Subject: [PATCH 50/91] wip --- tsconfig.base.json | 50 +++++++++++----------------------------------- 1 file changed, 12 insertions(+), 38 deletions(-) diff --git a/tsconfig.base.json b/tsconfig.base.json index ffc448860..37287d514 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -12,56 +12,30 @@ "importHelpers": true, "target": "es2022", "module": "esnext", - "lib": [ - "es2020", - "dom" - ], + "lib": ["es2020", "dom"], "skipLibCheck": true, "skipDefaultLibCheck": true, "baseUrl": ".", "resolveJsonModule": true, "allowSyntheticDefaultImports": true, "paths": { - "@code-pushup/cli": [ - "packages/cli/src/index.ts" - ], - "@code-pushup/core": [ - "packages/core/src/index.ts" - ], - "@code-pushup/coverage-plugin": [ - "packages/plugin-coverage/src/index.ts" - ], - "@code-pushup/eslint-plugin": [ - "packages/plugin-eslint/src/index.ts" - ], + "@code-pushup/cli": ["packages/cli/src/index.ts"], + "@code-pushup/core": ["packages/core/src/index.ts"], + "@code-pushup/coverage-plugin": ["packages/plugin-coverage/src/index.ts"], + "@code-pushup/eslint-plugin": ["packages/plugin-eslint/src/index.ts"], "@code-pushup/js-packages-plugin": [ "packages/plugin-js-packages/src/index.ts" ], "@code-pushup/lighthouse-plugin": [ "packages/plugin-lighthouse/src/index.ts" ], - "@code-pushup/models": [ - "packages/models/src/index.ts" - ], - "@code-pushup/nx-plugin": [ - "packages/nx-plugin/src/index.ts" - ], - "@code-pushup/test-nx-utils": [ - "testing/test-nx-utils/src/index.ts" - ], - "@code-pushup/test-setup": [ - "testing/test-setup/src/index.ts" - ], - "@code-pushup/test-utils": [ - "testing/test-utils/src/index.ts" - ], - "@code-pushup/utils": [ - "packages/utils/src/index.ts" - ] + "@code-pushup/models": ["packages/models/src/index.ts"], + "@code-pushup/nx-plugin": ["packages/nx-plugin/src/index.ts"], + "@code-pushup/test-nx-utils": ["testing/test-nx-utils/src/index.ts"], + "@code-pushup/test-setup": ["testing/test-setup/src/index.ts"], + "@code-pushup/test-utils": ["testing/test-utils/src/index.ts"], + "@code-pushup/utils": ["packages/utils/src/index.ts"] } }, - "exclude": [ - "node_modules", - "tmp" - ] + "exclude": ["node_modules", "tmp"] } From cff4bd9a8612788b4c6a0abe1beae2f1e8a6e14a Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Aug 2024 18:20:13 +0200 Subject: [PATCH 51/91] wip --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index fcf7ec667..ed043d92e 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -50,7 +50,7 @@ describe('create-cli-node', () => { ); }); - it.('should execute package correctly over npm init', async () => { + it('should execute package correctly over npm init', async () => { const cwd = join(baseDir, 'npm-init'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ From ecf6e4d69ed354e80a836fe939645baa9c03403a Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Aug 2024 18:55:31 +0200 Subject: [PATCH 52/91] wip --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index ed043d92e..dd4c58dfa 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -15,9 +15,9 @@ describe('create-cli-node', () => { await rm(baseDir, { recursive: true, force: true }); }); - // eslint-disable-next-line vitest/no-disabled-tests - it.skip('should execute index.js correctly over node', async () => { - const cwd = join(baseDir, 'node-index'); + + it('should execute index.js correctly over node', async () => { + const cwd = join(baseDir, 'node-index.js'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ command: 'node', @@ -50,7 +50,8 @@ describe('create-cli-node', () => { ); }); - it('should execute package correctly over npm init', async () => { + // eslint-disable-next-line vitest/no-disabled-tests + it.skip('should execute package correctly over npm init', async () => { const cwd = join(baseDir, 'npm-init'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ From 6ba0882201d0c538d5fc12905a9b41023880b53c Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 18 Aug 2024 21:37:19 +0200 Subject: [PATCH 53/91] adjust publish process --- tools/scripts/publish.mjs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/scripts/publish.mjs b/tools/scripts/publish.mjs index 2fa5fd808..380c52e22 100644 --- a/tools/scripts/publish.mjs +++ b/tools/scripts/publish.mjs @@ -58,6 +58,7 @@ invariant( `Could not find "build.options.outputPath" of project "${name}". Is project.json configured correctly?`, ); +const cwd = process.cwd(); process.chdir(outputPath); // Updating the version in "package.json" before publishing @@ -71,3 +72,6 @@ try { // Execute "npm publish" to publish execSync(`npm publish --access public --tag ${tag}`); + +process.chdir(cwd); +process.exit(0); From 3bbee4061df9b22a9a8c738dbb6f69bf07b4e402 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 18 Aug 2024 21:38:02 +0200 Subject: [PATCH 54/91] adjust publish process --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index dd4c58dfa..ba2f23408 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -15,7 +15,6 @@ describe('create-cli-node', () => { await rm(baseDir, { recursive: true, force: true }); }); - it('should execute index.js correctly over node', async () => { const cwd = join(baseDir, 'node-index.js'); await createNpmWorkspace(cwd); From 2aea007497c2c0e37630f7b4c3e935695a028b11 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 18 Aug 2024 21:48:09 +0200 Subject: [PATCH 55/91] remove snapshot to avoid OS path problems --- .../__snapshots__/nx-plugin.e2e.test.ts.snap | 91 ------------------- e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts | 1 - 2 files changed, 92 deletions(-) delete mode 100644 e2e/nx-plugin-e2e/tests/__snapshots__/nx-plugin.e2e.test.ts.snap diff --git a/e2e/nx-plugin-e2e/tests/__snapshots__/nx-plugin.e2e.test.ts.snap b/e2e/nx-plugin-e2e/tests/__snapshots__/nx-plugin.e2e.test.ts.snap deleted file mode 100644 index 0315a42f6..000000000 --- a/e2e/nx-plugin-e2e/tests/__snapshots__/nx-plugin.e2e.test.ts.snap +++ /dev/null @@ -1,91 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`nx-plugin > should NOT add config targets dynamically if the project is configured 1`] = ` -{ - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "implicitDependencies": [], - "name": "my-lib", - "projectType": "library", - "root": "libs/my-lib", - "sourceRoot": "libs/my-lib/src", - "tags": [ - "scope:plugin", - ], - "targets": { - "code-pushup": { - "configurations": {}, - "executor": "@code-pushup/nx-plugin:autorun", - "options": {}, - }, - }, -} -`; - -exports[`nx-plugin > should NOT add targets dynamically if plugin is not registered 1`] = ` -{ - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "implicitDependencies": [], - "name": "my-lib", - "projectType": "library", - "root": "libs/my-lib", - "sourceRoot": "libs/my-lib/src", - "tags": [ - "scope:plugin", - ], - "targets": {}, -} -`; - -exports[`nx-plugin > should add configuration target dynamically 1`] = ` -{ - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "implicitDependencies": [], - "name": "my-lib", - "projectType": "library", - "root": "libs/my-lib", - "sourceRoot": "libs/my-lib/src", - "tags": [ - "scope:plugin", - ], - "targets": { - "code-pushup--configuration": { - "configurations": {}, - "executor": "nx:run-commands", - "options": { - "command": "nx g @code-pushup/nx-plugin:configuration --skipTarget --targetName="code-pushup" --project="my-lib"", - }, - }, - }, -} -`; - -exports[`nx-plugin > should add executor target dynamically if the project is configured 1`] = ` -{ - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "implicitDependencies": [], - "name": "my-lib", - "projectType": "library", - "root": "libs/my-lib", - "sourceRoot": "libs/my-lib/src", - "tags": [ - "scope:plugin", - ], - "targets": { - "code-pushup": { - "configurations": {}, - "executor": "@code-pushup/nx-plugin:autorun", - "options": {}, - }, - }, -} -`; - -exports[`nx-plugin > should execute dynamic configuration target 1`] = ` -"import type { CoreConfig } from '@code-pushup/models'; - -// see: https://github.com/code-pushup/cli/blob/main/packages/models/docs/models-reference.md#coreconfig -export default { - plugins: [], -} satisfies CoreConfig; -" -`; diff --git a/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts b/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts index 3bf6973c3..abc300db2 100644 --- a/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts +++ b/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts @@ -251,6 +251,5 @@ describe('nx-plugin', () => { expect(code).toBe(0); expect(projectJson.targets).toStrictEqual({}); - expect(projectJson).toMatchSnapshot(); }); }); From c7e5179dc53a5367d9a3d60c2a12a1c7fb22f6de Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 18 Aug 2024 21:49:19 +0200 Subject: [PATCH 56/91] snapshot --- .../__snapshots__/nx-plugin.e2e.test.ts.snap | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 e2e/nx-plugin-e2e/tests/__snapshots__/nx-plugin.e2e.test.ts.snap diff --git a/e2e/nx-plugin-e2e/tests/__snapshots__/nx-plugin.e2e.test.ts.snap b/e2e/nx-plugin-e2e/tests/__snapshots__/nx-plugin.e2e.test.ts.snap new file mode 100644 index 000000000..4de0a61b4 --- /dev/null +++ b/e2e/nx-plugin-e2e/tests/__snapshots__/nx-plugin.e2e.test.ts.snap @@ -0,0 +1,76 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`nx-plugin > should NOT add config targets dynamically if the project is configured 1`] = ` +{ + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "implicitDependencies": [], + "name": "my-lib", + "projectType": "library", + "root": "libs/my-lib", + "sourceRoot": "libs/my-lib/src", + "tags": [ + "scope:plugin", + ], + "targets": { + "code-pushup": { + "configurations": {}, + "executor": "@code-pushup/nx-plugin:autorun", + "options": {}, + }, + }, +} +`; + +exports[`nx-plugin > should add configuration target dynamically 1`] = ` +{ + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "implicitDependencies": [], + "name": "my-lib", + "projectType": "library", + "root": "libs/my-lib", + "sourceRoot": "libs/my-lib/src", + "tags": [ + "scope:plugin", + ], + "targets": { + "code-pushup--configuration": { + "configurations": {}, + "executor": "nx:run-commands", + "options": { + "command": "nx g @code-pushup/nx-plugin:configuration --skipTarget --targetName="code-pushup" --project="my-lib"", + }, + }, + }, +} +`; + +exports[`nx-plugin > should add executor target dynamically if the project is configured 1`] = ` +{ + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "implicitDependencies": [], + "name": "my-lib", + "projectType": "library", + "root": "libs/my-lib", + "sourceRoot": "libs/my-lib/src", + "tags": [ + "scope:plugin", + ], + "targets": { + "code-pushup": { + "configurations": {}, + "executor": "@code-pushup/nx-plugin:autorun", + "options": {}, + }, + }, +} +`; + +exports[`nx-plugin > should execute dynamic configuration target 1`] = ` +"import type { CoreConfig } from '@code-pushup/models'; + +// see: https://github.com/code-pushup/cli/blob/main/packages/models/docs/models-reference.md#coreconfig +export default { + plugins: [], +} satisfies CoreConfig; +" +`; From 75a0d6c2c0023643cbaa23091813c5cf0f67ff5d Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 18 Aug 2024 21:54:44 +0200 Subject: [PATCH 57/91] CI stability - nx-plugin --- e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts b/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts index abc300db2..4507b0d0c 100644 --- a/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts +++ b/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts @@ -224,7 +224,7 @@ describe('nx-plugin', () => { registerPluginInWorkspace(tree, { plugin: join(relativePathToCwd(cwd), 'dist/packages/nx-plugin'), options: { - bin: 'XYZ', + bin: 'WXYZ', }, }); const { root } = readProjectConfiguration(tree, project); @@ -237,7 +237,7 @@ describe('nx-plugin', () => { expect(projectJson.targets).toStrictEqual({ ['code-pushup']: expect.objectContaining({ - executor: 'XYZ:autorun', + executor: 'WXYZ:autorun', }), }); }); From 74faf75fde465235df5d1342bddf6507fbe096bc Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 18 Aug 2024 21:54:56 +0200 Subject: [PATCH 58/91] CI stability - nx-plugin --- e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts b/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts index 4507b0d0c..abc300db2 100644 --- a/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts +++ b/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts @@ -224,7 +224,7 @@ describe('nx-plugin', () => { registerPluginInWorkspace(tree, { plugin: join(relativePathToCwd(cwd), 'dist/packages/nx-plugin'), options: { - bin: 'WXYZ', + bin: 'XYZ', }, }); const { root } = readProjectConfiguration(tree, project); @@ -237,7 +237,7 @@ describe('nx-plugin', () => { expect(projectJson.targets).toStrictEqual({ ['code-pushup']: expect.objectContaining({ - executor: 'WXYZ:autorun', + executor: 'XYZ:autorun', }), }); }); From 08f3bf5b4fd5521921f5f7bfb6241f8a7b46d537 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 18 Aug 2024 21:55:20 +0200 Subject: [PATCH 59/91] CI stability - nx-plugin --- e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts b/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts index abc300db2..7037d5aab 100644 --- a/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts +++ b/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts @@ -224,7 +224,7 @@ describe('nx-plugin', () => { registerPluginInWorkspace(tree, { plugin: join(relativePathToCwd(cwd), 'dist/packages/nx-plugin'), options: { - bin: 'XYZ', + bin: 'XYZA', }, }); const { root } = readProjectConfiguration(tree, project); @@ -237,7 +237,7 @@ describe('nx-plugin', () => { expect(projectJson.targets).toStrictEqual({ ['code-pushup']: expect.objectContaining({ - executor: 'XYZ:autorun', + executor: 'XYZA:autorun', }), }); }); From 4ec04085c1cb9ec3c345641749a18d78d97f111a Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 18 Aug 2024 21:55:36 +0200 Subject: [PATCH 60/91] CI stability - nx-plugin --- e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts b/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts index 7037d5aab..abc300db2 100644 --- a/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts +++ b/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts @@ -224,7 +224,7 @@ describe('nx-plugin', () => { registerPluginInWorkspace(tree, { plugin: join(relativePathToCwd(cwd), 'dist/packages/nx-plugin'), options: { - bin: 'XYZA', + bin: 'XYZ', }, }); const { root } = readProjectConfiguration(tree, project); @@ -237,7 +237,7 @@ describe('nx-plugin', () => { expect(projectJson.targets).toStrictEqual({ ['code-pushup']: expect.objectContaining({ - executor: 'XYZA:autorun', + executor: 'XYZ:autorun', }), }); }); From 68d3805d272c6109f5f79f8c6d5aacb551e98b2e Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 18 Aug 2024 21:55:54 +0200 Subject: [PATCH 61/91] CI stability - nx-plugin --- e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts b/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts index abc300db2..4507b0d0c 100644 --- a/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts +++ b/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts @@ -224,7 +224,7 @@ describe('nx-plugin', () => { registerPluginInWorkspace(tree, { plugin: join(relativePathToCwd(cwd), 'dist/packages/nx-plugin'), options: { - bin: 'XYZ', + bin: 'WXYZ', }, }); const { root } = readProjectConfiguration(tree, project); @@ -237,7 +237,7 @@ describe('nx-plugin', () => { expect(projectJson.targets).toStrictEqual({ ['code-pushup']: expect.objectContaining({ - executor: 'XYZ:autorun', + executor: 'WXYZ:autorun', }), }); }); From 951c83b37a0d59d635b2f32040bfd36676255ed6 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 18 Aug 2024 21:56:08 +0200 Subject: [PATCH 62/91] CI stability - nx-plugin --- e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts b/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts index 4507b0d0c..abc300db2 100644 --- a/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts +++ b/e2e/nx-plugin-e2e/tests/nx-plugin.e2e.test.ts @@ -224,7 +224,7 @@ describe('nx-plugin', () => { registerPluginInWorkspace(tree, { plugin: join(relativePathToCwd(cwd), 'dist/packages/nx-plugin'), options: { - bin: 'WXYZ', + bin: 'XYZ', }, }); const { root } = readProjectConfiguration(tree, project); @@ -237,7 +237,7 @@ describe('nx-plugin', () => { expect(projectJson.targets).toStrictEqual({ ['code-pushup']: expect.objectContaining({ - executor: 'WXYZ:autorun', + executor: 'XYZ:autorun', }), }); }); From 4e43a73b6c672dc1719ddb529f8eea028506dddb Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 18 Aug 2024 21:57:00 +0200 Subject: [PATCH 63/91] CI stability - create-cli --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index ba2f23408..f7a08748e 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -50,7 +50,7 @@ describe('create-cli-node', () => { }); // eslint-disable-next-line vitest/no-disabled-tests - it.skip('should execute package correctly over npm init', async () => { + it.skip('should execute package correctly overr npm init', async () => { const cwd = join(baseDir, 'npm-init'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ From ca8755e6c8070362ae5bbbf1f7132c46af4f153d Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 18 Aug 2024 21:57:11 +0200 Subject: [PATCH 64/91] CI stability - create-cli --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index f7a08748e..ba2f23408 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -50,7 +50,7 @@ describe('create-cli-node', () => { }); // eslint-disable-next-line vitest/no-disabled-tests - it.skip('should execute package correctly overr npm init', async () => { + it.skip('should execute package correctly over npm init', async () => { const cwd = join(baseDir, 'npm-init'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ From 81d73ba6a0c40240c51c834b665bb53a7b2b15c1 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 18 Aug 2024 21:57:21 +0200 Subject: [PATCH 65/91] CI stability - create-cli --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index ba2f23408..f7a08748e 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -50,7 +50,7 @@ describe('create-cli-node', () => { }); // eslint-disable-next-line vitest/no-disabled-tests - it.skip('should execute package correctly over npm init', async () => { + it.skip('should execute package correctly overr npm init', async () => { const cwd = join(baseDir, 'npm-init'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ From 08afc586d33e0b6ab8c2e05d6f0a5f8377e6e608 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 18 Aug 2024 21:57:35 +0200 Subject: [PATCH 66/91] CI stability - create-cli --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index f7a08748e..ba2f23408 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -50,7 +50,7 @@ describe('create-cli-node', () => { }); // eslint-disable-next-line vitest/no-disabled-tests - it.skip('should execute package correctly overr npm init', async () => { + it.skip('should execute package correctly over npm init', async () => { const cwd = join(baseDir, 'npm-init'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ From d48a9ce3a907d84f4ec32efe877373f1a0c2a820 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 18 Aug 2024 21:57:49 +0200 Subject: [PATCH 67/91] CI stability - create-cli --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index ba2f23408..f7a08748e 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -50,7 +50,7 @@ describe('create-cli-node', () => { }); // eslint-disable-next-line vitest/no-disabled-tests - it.skip('should execute package correctly over npm init', async () => { + it.skip('should execute package correctly overr npm init', async () => { const cwd = join(baseDir, 'npm-init'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ From ab725cb886cc5b3115629da5ed4de53616c733ee Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 18 Aug 2024 21:57:57 +0200 Subject: [PATCH 68/91] CI stability - create-cli --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index f7a08748e..ba2f23408 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -50,7 +50,7 @@ describe('create-cli-node', () => { }); // eslint-disable-next-line vitest/no-disabled-tests - it.skip('should execute package correctly overr npm init', async () => { + it.skip('should execute package correctly over npm init', async () => { const cwd = join(baseDir, 'npm-init'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ From 557cf22904239f25789f87c55442d1b3e17d025f Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 18 Aug 2024 22:22:17 +0200 Subject: [PATCH 69/91] CI stability - create-cli all tests --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index ba2f23408..0a01c9d63 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -31,8 +31,7 @@ describe('create-cli-node', () => { ); }); - // eslint-disable-next-line vitest/no-disabled-tests - it.skip('should execute package correctly over npm exec', async () => { + it('should execute package correctly over npm exec', async () => { const cwd = join(baseDir, 'npm-exec'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ @@ -49,8 +48,7 @@ describe('create-cli-node', () => { ); }); - // eslint-disable-next-line vitest/no-disabled-tests - it.skip('should execute package correctly over npm init', async () => { + it('should execute package correctly over npm init', async () => { const cwd = join(baseDir, 'npm-init'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ From bb940f8451520539af6528f053c962944f105007 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 18 Aug 2024 22:43:11 +0200 Subject: [PATCH 70/91] CI stability - create-cli, exec --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index 0a01c9d63..ce0b497e1 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -15,7 +15,7 @@ describe('create-cli-node', () => { await rm(baseDir, { recursive: true, force: true }); }); - it('should execute index.js correctly over node', async () => { + it.skip('should execute index.js correctly over node', async () => { const cwd = join(baseDir, 'node-index.js'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ @@ -31,7 +31,7 @@ describe('create-cli-node', () => { ); }); - it('should execute package correctly over npm exec', async () => { + it.skip('should execute package correctly over npm exec', async () => { const cwd = join(baseDir, 'npm-exec'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ From 6eaf8b74a0f702c8429343a413d0656a13a5cdbb Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 18 Aug 2024 22:43:44 +0200 Subject: [PATCH 71/91] CI stability - create-cli, exec real --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index ce0b497e1..a145ffc0e 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -31,7 +31,7 @@ describe('create-cli-node', () => { ); }); - it.skip('should execute package correctly over npm exec', async () => { + it('should execute package correctly over npm exec', async () => { const cwd = join(baseDir, 'npm-exec'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ @@ -48,7 +48,7 @@ describe('create-cli-node', () => { ); }); - it('should execute package correctly over npm init', async () => { + it.skip('should execute package correctly over npm init', async () => { const cwd = join(baseDir, 'npm-init'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ From 5d5d898350d05e1639f3cf16924c7b02e4819668 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 18 Aug 2024 22:44:03 +0200 Subject: [PATCH 72/91] CI stability - create-cli, node --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index a145ffc0e..be57cd0a8 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -15,7 +15,7 @@ describe('create-cli-node', () => { await rm(baseDir, { recursive: true, force: true }); }); - it.skip('should execute index.js correctly over node', async () => { + it('should execute index.js correctly over node', async () => { const cwd = join(baseDir, 'node-index.js'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ @@ -31,7 +31,7 @@ describe('create-cli-node', () => { ); }); - it('should execute package correctly over npm exec', async () => { + it.skip('should execute package correctly over npm exec', async () => { const cwd = join(baseDir, 'npm-exec'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ From 4b3a32b47f7d0b41dd8d704b308569fdd9c20d5f Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 18 Aug 2024 22:46:03 +0200 Subject: [PATCH 73/91] CI stability - create-cli, init --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index be57cd0a8..431b1b6db 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -15,7 +15,8 @@ describe('create-cli-node', () => { await rm(baseDir, { recursive: true, force: true }); }); - it('should execute index.js correctly over node', async () => { + // eslint-disable-next-line vitest/no-disabled-tests + it.skip('should execute index.js correctly over node', async () => { const cwd = join(baseDir, 'node-index.js'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ @@ -31,6 +32,7 @@ describe('create-cli-node', () => { ); }); + // eslint-disable-next-line vitest/no-disabled-tests it.skip('should execute package correctly over npm exec', async () => { const cwd = join(baseDir, 'npm-exec'); await createNpmWorkspace(cwd); @@ -48,7 +50,8 @@ describe('create-cli-node', () => { ); }); - it.skip('should execute package correctly over npm init', async () => { + + it('should execute package correctly over npm init', async () => { const cwd = join(baseDir, 'npm-init'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ From 26a1201ccc712f262495e041efb0e52de9ed20c7 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 18 Aug 2024 22:46:49 +0200 Subject: [PATCH 74/91] CI stability - create-cli, exec --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index 431b1b6db..acf7e32d6 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -32,8 +32,8 @@ describe('create-cli-node', () => { ); }); - // eslint-disable-next-line vitest/no-disabled-tests - it.skip('should execute package correctly over npm exec', async () => { + + it('should execute package correctly over npm exec', async () => { const cwd = join(baseDir, 'npm-exec'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ @@ -50,8 +50,8 @@ describe('create-cli-node', () => { ); }); - - it('should execute package correctly over npm init', async () => { +// eslint-disable-next-line vitest/no-disabled-tests + it.skip('should execute package correctly over npm init', async () => { const cwd = join(baseDir, 'npm-init'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ From 62377f3e5aa7bdba289560164bd98949581481d8 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 18 Aug 2024 22:47:11 +0200 Subject: [PATCH 75/91] CI stability - create-cli, node+exec --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index acf7e32d6..4140b2839 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -15,8 +15,8 @@ describe('create-cli-node', () => { await rm(baseDir, { recursive: true, force: true }); }); - // eslint-disable-next-line vitest/no-disabled-tests - it.skip('should execute index.js correctly over node', async () => { + + it('should execute index.js correctly over node', async () => { const cwd = join(baseDir, 'node-index.js'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ From e813e9dc135cde4c6ddd3b8f780a800235248392 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 18 Aug 2024 22:47:47 +0200 Subject: [PATCH 76/91] CI stability - create-cli, init --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index 4140b2839..ba2f23408 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -15,7 +15,6 @@ describe('create-cli-node', () => { await rm(baseDir, { recursive: true, force: true }); }); - it('should execute index.js correctly over node', async () => { const cwd = join(baseDir, 'node-index.js'); await createNpmWorkspace(cwd); @@ -32,8 +31,8 @@ describe('create-cli-node', () => { ); }); - - it('should execute package correctly over npm exec', async () => { + // eslint-disable-next-line vitest/no-disabled-tests + it.skip('should execute package correctly over npm exec', async () => { const cwd = join(baseDir, 'npm-exec'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ @@ -50,7 +49,7 @@ describe('create-cli-node', () => { ); }); -// eslint-disable-next-line vitest/no-disabled-tests + // eslint-disable-next-line vitest/no-disabled-tests it.skip('should execute package correctly over npm init', async () => { const cwd = join(baseDir, 'npm-init'); await createNpmWorkspace(cwd); From 6de4b682041c310c3556c1daf0cb87defa22d505 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 18 Aug 2024 23:14:13 +0200 Subject: [PATCH 77/91] exec --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index ba2f23408..298ac9d19 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -15,7 +15,9 @@ describe('create-cli-node', () => { await rm(baseDir, { recursive: true, force: true }); }); - it('should execute index.js correctly over node', async () => { + + // eslint-disable-next-line vitest/no-disabled-tests + it.skip('should execute index.js correctly over node', async () => { const cwd = join(baseDir, 'node-index.js'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ @@ -32,7 +34,7 @@ describe('create-cli-node', () => { }); // eslint-disable-next-line vitest/no-disabled-tests - it.skip('should execute package correctly over npm exec', async () => { + it('should execute package correctly over npm exec', async () => { const cwd = join(baseDir, 'npm-exec'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ From 727e0e85d1e590dbef6db2f90f31fd9a142dfcbd Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 18 Aug 2024 23:14:38 +0200 Subject: [PATCH 78/91] node --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index 298ac9d19..ba2f23408 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -15,9 +15,7 @@ describe('create-cli-node', () => { await rm(baseDir, { recursive: true, force: true }); }); - - // eslint-disable-next-line vitest/no-disabled-tests - it.skip('should execute index.js correctly over node', async () => { + it('should execute index.js correctly over node', async () => { const cwd = join(baseDir, 'node-index.js'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ @@ -34,7 +32,7 @@ describe('create-cli-node', () => { }); // eslint-disable-next-line vitest/no-disabled-tests - it('should execute package correctly over npm exec', async () => { + it.skip('should execute package correctly over npm exec', async () => { const cwd = join(baseDir, 'npm-exec'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ From 32b9e07fa876472a149aca6ffc98281f7b8fa029 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 19 Aug 2024 03:05:19 +0200 Subject: [PATCH 79/91] CI stability --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index ba2f23408..906a80ebf 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -16,7 +16,7 @@ describe('create-cli-node', () => { }); it('should execute index.js correctly over node', async () => { - const cwd = join(baseDir, 'node-index.js'); + const cwd = join(baseDir, 'node-index-js'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ command: 'node', From e8cef2b309481ba3bb10e90deaeb08a998311a18 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 19 Aug 2024 03:05:27 +0200 Subject: [PATCH 80/91] CI stability --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index 906a80ebf..ba2f23408 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -16,7 +16,7 @@ describe('create-cli-node', () => { }); it('should execute index.js correctly over node', async () => { - const cwd = join(baseDir, 'node-index-js'); + const cwd = join(baseDir, 'node-index.js'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ command: 'node', From c961345778d68d654b9c3e6ace440ad3f93b44e0 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 19 Aug 2024 03:05:37 +0200 Subject: [PATCH 81/91] CI stability --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index ba2f23408..906a80ebf 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -16,7 +16,7 @@ describe('create-cli-node', () => { }); it('should execute index.js correctly over node', async () => { - const cwd = join(baseDir, 'node-index.js'); + const cwd = join(baseDir, 'node-index-js'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ command: 'node', From dc63b4f96291756c27ea195ce37a4e8a40e3de47 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 19 Aug 2024 13:52:33 +0200 Subject: [PATCH 82/91] run init tests only --- e2e/create-cli-e2e/tests/init.e2e.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e/create-cli-e2e/tests/init.e2e.test.ts b/e2e/create-cli-e2e/tests/init.e2e.test.ts index 906a80ebf..5d83a2c62 100644 --- a/e2e/create-cli-e2e/tests/init.e2e.test.ts +++ b/e2e/create-cli-e2e/tests/init.e2e.test.ts @@ -15,7 +15,8 @@ describe('create-cli-node', () => { await rm(baseDir, { recursive: true, force: true }); }); - it('should execute index.js correctly over node', async () => { + // eslint-disable-next-line vitest/no-disabled-tests + it.skip('should execute index.js correctly over node', async () => { const cwd = join(baseDir, 'node-index-js'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ @@ -49,8 +50,7 @@ describe('create-cli-node', () => { ); }); - // eslint-disable-next-line vitest/no-disabled-tests - it.skip('should execute package correctly over npm init', async () => { + it('should execute package correctly over npm init', async () => { const cwd = join(baseDir, 'npm-init'); await createNpmWorkspace(cwd); const { code, stdout } = await executeProcess({ From ba2e5c89b066916dbc703bd0bec6ceda38065631 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 19 Aug 2024 13:55:50 +0200 Subject: [PATCH 83/91] add error handling in global-setup.e2e.ts --- global-setup.e2e.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/global-setup.e2e.ts b/global-setup.e2e.ts index 055dcb451..051850782 100644 --- a/global-setup.e2e.ts +++ b/global-setup.e2e.ts @@ -8,18 +8,28 @@ const localRegistryNxTarget = '@code-pushup/cli-source:local-registry'; export async function setup() { await globalSetup(); + await setupTestFolder('tmp/local-registry'); + await setupTestFolder('tmp/e2e'); + try { - await setupTestFolder('tmp/local-registry'); await startLocalRegistry({ localRegistryTarget: localRegistryNxTarget }); + } catch (error) { + console.error( + 'Error starting local verdaccio registry: \nr: ' + error.message, + ); + throw error; + } + + try { console.info('Installing packages'); execFileSync( 'npx', ['nx', 'run-many', '--targets=npm-install', '--parallel=1'], { env: process.env, stdio: 'inherit', shell: true }, ); - await setupTestFolder('tmp/e2e'); } catch (error) { - console.info('setup error: ' + error.message); + console.error('Error installing packages: \n' + error.message); + throw error; } } From 50242e9af4d68193aa0c91c8c2a95ec928127068 Mon Sep 17 00:00:00 2001 From: Michael Hladky <10064416+BioPhoton@users.noreply.github.com> Date: Mon, 19 Aug 2024 13:56:14 +0200 Subject: [PATCH 84/91] Update tools/scripts/publish.mjs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Matěj Chalk <34691111+matejchalk@users.noreply.github.com> --- tools/scripts/publish.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/scripts/publish.mjs b/tools/scripts/publish.mjs index 380c52e22..c82a5e545 100644 --- a/tools/scripts/publish.mjs +++ b/tools/scripts/publish.mjs @@ -55,7 +55,7 @@ invariant( const outputPath = project.data?.targets?.build?.options?.outputPath; invariant( outputPath, - `Could not find "build.options.outputPath" of project "${name}". Is project.json configured correctly?`, + `Could not find "build.options.outputPath" of project "${name}". Is project.json configured correctly?`, ); const cwd = process.cwd(); From 4a3535ac558509a8c21c6c9d11f9f1e8332140fe Mon Sep 17 00:00:00 2001 From: Michael Hladky <10064416+BioPhoton@users.noreply.github.com> Date: Mon, 19 Aug 2024 14:08:25 +0200 Subject: [PATCH 85/91] Update global-setup.e2e.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Matěj Chalk <34691111+matejchalk@users.noreply.github.com> --- global-setup.e2e.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global-setup.e2e.ts b/global-setup.e2e.ts index 051850782..2402e643b 100644 --- a/global-setup.e2e.ts +++ b/global-setup.e2e.ts @@ -15,7 +15,7 @@ export async function setup() { await startLocalRegistry({ localRegistryTarget: localRegistryNxTarget }); } catch (error) { console.error( - 'Error starting local verdaccio registry: \nr: ' + error.message, + 'Error starting local verdaccio registry:\n' + error.message, ); throw error; } From 4ced496b852dfd0c743e9c89aca6c5dd7bd4f483 Mon Sep 17 00:00:00 2001 From: Michael Hladky <10064416+BioPhoton@users.noreply.github.com> Date: Mon, 19 Aug 2024 14:08:33 +0200 Subject: [PATCH 86/91] Update global-setup.e2e.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Matěj Chalk <34691111+matejchalk@users.noreply.github.com> --- global-setup.e2e.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global-setup.e2e.ts b/global-setup.e2e.ts index 2402e643b..057fb1696 100644 --- a/global-setup.e2e.ts +++ b/global-setup.e2e.ts @@ -28,7 +28,7 @@ export async function setup() { { env: process.env, stdio: 'inherit', shell: true }, ); } catch (error) { - console.error('Error installing packages: \n' + error.message); + console.error('Error installing packages:\n' + error.message); throw error; } } From 30c21e3f0a89df1ac802cf8a16f1efa695cd1179 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 19 Aug 2024 14:10:55 +0200 Subject: [PATCH 87/91] format --- global-setup.e2e.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/global-setup.e2e.ts b/global-setup.e2e.ts index 057fb1696..9c12227fd 100644 --- a/global-setup.e2e.ts +++ b/global-setup.e2e.ts @@ -14,9 +14,7 @@ export async function setup() { try { await startLocalRegistry({ localRegistryTarget: localRegistryNxTarget }); } catch (error) { - console.error( - 'Error starting local verdaccio registry:\n' + error.message, - ); + console.error('Error starting local verdaccio registry:\n' + error.message); throw error; } From 93de4688f7671f4f068ae71bdeb27b37154d703c Mon Sep 17 00:00:00 2001 From: Michael Hladky <10064416+BioPhoton@users.noreply.github.com> Date: Mon, 19 Aug 2024 14:11:37 +0200 Subject: [PATCH 88/91] Update packages/create-cli/src/lib/utils.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Matěj Chalk <34691111+matejchalk@users.noreply.github.com> --- packages/create-cli/src/lib/utils.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/create-cli/src/lib/utils.ts b/packages/create-cli/src/lib/utils.ts index 876f0d9c7..abca37bfb 100644 --- a/packages/create-cli/src/lib/utils.ts +++ b/packages/create-cli/src/lib/utils.ts @@ -62,9 +62,7 @@ export async function setupNxContext(): Promise<{ PROJECT_JSON_CONTENT, ); - const projectJsonContent = ( - await readFile(PROJECT_JSON_FILENAME, 'utf8') - ).toString(); + const projectJsonContent = await readFile(PROJECT_JSON_FILENAME, 'utf8'); const { name = PROJECT_NAME } = JSON.parse(projectJsonContent) as { name: string; }; From 33db0243c865be7e3f2e9e4a3c6d0546b52e1929 Mon Sep 17 00:00:00 2001 From: Michael Hladky <10064416+BioPhoton@users.noreply.github.com> Date: Mon, 19 Aug 2024 14:12:04 +0200 Subject: [PATCH 89/91] Update packages/create-cli/src/lib/utils.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Matěj Chalk <34691111+matejchalk@users.noreply.github.com> --- packages/create-cli/src/lib/utils.ts | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/packages/create-cli/src/lib/utils.ts b/packages/create-cli/src/lib/utils.ts index abca37bfb..3cc45ff63 100644 --- a/packages/create-cli/src/lib/utils.ts +++ b/packages/create-cli/src/lib/utils.ts @@ -81,14 +81,9 @@ export async function teardownNxContext({ nxJsonTeardown: boolean; projectJsonTeardown: boolean; }) { - const toDelete: Promise[] = []; - if (nxJsonTeardown) { - // eslint-disable-next-line functional/immutable-data - toDelete.push(rm(NX_JSON_FILENAME)); - } - if (projectJsonTeardown) { - // eslint-disable-next-line functional/immutable-data - toDelete.push(rm(PROJECT_JSON_FILENAME)); - } - await Promise.all(toDelete); + const filesToDelete = [ + ...nxJsonTeardown ? [NX_JSON_FILENAME] : [], + ...projectJsonTeardown ? [PROJECT_JSON_FILENAME] : [], + ]; + await Promise.all(filesToDelete.map(rm)); } From de25646ee85aefb64a8512b7b57926de1102d60f Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 19 Aug 2024 14:12:41 +0200 Subject: [PATCH 90/91] format --- packages/create-cli/src/lib/utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/create-cli/src/lib/utils.ts b/packages/create-cli/src/lib/utils.ts index 3cc45ff63..f868d3872 100644 --- a/packages/create-cli/src/lib/utils.ts +++ b/packages/create-cli/src/lib/utils.ts @@ -82,8 +82,8 @@ export async function teardownNxContext({ projectJsonTeardown: boolean; }) { const filesToDelete = [ - ...nxJsonTeardown ? [NX_JSON_FILENAME] : [], - ...projectJsonTeardown ? [PROJECT_JSON_FILENAME] : [], + ...(nxJsonTeardown ? [NX_JSON_FILENAME] : []), + ...(projectJsonTeardown ? [PROJECT_JSON_FILENAME] : []), ]; await Promise.all(filesToDelete.map(rm)); } From 99934018f7dfdd2cf1b14d074938f76ac960977a Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 19 Aug 2024 14:19:23 +0200 Subject: [PATCH 91/91] fix unit-test --- packages/create-cli/src/lib/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/create-cli/src/lib/utils.ts b/packages/create-cli/src/lib/utils.ts index f868d3872..894eaa2fb 100644 --- a/packages/create-cli/src/lib/utils.ts +++ b/packages/create-cli/src/lib/utils.ts @@ -85,5 +85,5 @@ export async function teardownNxContext({ ...(nxJsonTeardown ? [NX_JSON_FILENAME] : []), ...(projectJsonTeardown ? [PROJECT_JSON_FILENAME] : []), ]; - await Promise.all(filesToDelete.map(rm)); + await Promise.all(filesToDelete.map(file => rm(file))); }