-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
1,107 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": ["../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*", "code-pushup.config*.ts"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"parserOptions": { | ||
"project": ["e2e/create-cli-e2e/tsconfig.*?.json"] | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
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 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, 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-js'); | ||
await createNpmWorkspace(cwd); | ||
const { code, stdout } = await executeProcess({ | ||
command: 'node', | ||
args: [join(binPath(cwd), 'index.js')], | ||
cwd, | ||
}); | ||
|
||
expect(code).toBe(0); | ||
const cleanedStdout = removeColorCodes(stdout); | ||
expect(cleanedStdout).toContain( | ||
'<↗> Generating @code-pushup/nx-plugin:configuration', | ||
); | ||
}); | ||
|
||
// 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({ | ||
command: 'npm', | ||
args: ['exec', '@code-pushup/create-cli'], | ||
cwd, | ||
observer: { onStdout: console.info }, | ||
}); | ||
|
||
expect(code).toBe(0); | ||
const cleanedStdout = removeColorCodes(stdout); | ||
expect(cleanedStdout).toContain( | ||
'<↗> Generating @code-pushup/nx-plugin:configuration', | ||
); | ||
}); | ||
|
||
it('should execute package correctly over npm init', async () => { | ||
const cwd = join(baseDir, 'npm-init'); | ||
await createNpmWorkspace(cwd); | ||
const { code, stdout } = await executeProcess({ | ||
command: 'npm', | ||
args: ['init', '@code-pushup/cli'], | ||
cwd, | ||
observer: { onStdout: console.info }, | ||
}); | ||
|
||
expect(code).toBe(0); | ||
const cleanedStdout = removeColorCodes(stdout); | ||
expect(cleanedStdout).toContain( | ||
'<↗> Generating @code-pushup/nx-plugin:configuration', | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/// <reference types="vitest" /> | ||
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'], | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"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", | ||
{ | ||
"ignoredDependencies": ["@code-pushup/nx-plugin"] // nx-plugin is run via CLI | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# @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 Code PushUp in your repository. | ||
|
||
## Usage | ||
|
||
To set up Code PushUp, run the following command: | ||
|
||
```bash | ||
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 | ||
> <↗> Generating @code-pushup/nx-plugin:init | ||
|
||
> <↗> Generating @code-pushup/nx-plugin:configuration | ||
|
||
CREATE code-pushup.config.ts | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "@code-pushup/create-cli", | ||
"version": "0.0.0", | ||
"license": "MIT", | ||
"bin": "index.js", | ||
"dependencies": { | ||
"@code-pushup/nx-plugin": "*", | ||
"@code-pushup/utils": "*" | ||
} | ||
} |
Oops, something went wrong.