mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix: ng-schematics install Windows (#11487)
This commit is contained in:
parent
7cead042c9
commit
02af7482d9
38
.github/workflows/ci.yml
vendored
38
.github/workflows/ci.yml
vendored
@ -442,6 +442,44 @@ jobs:
|
|||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: npm run test --workspace @puppeteer/ng-schematics
|
run: npm run test --workspace @puppeteer/ng-schematics
|
||||||
|
|
||||||
|
ng-schematics-smoke-tests:
|
||||||
|
name: Angular Schematics smoke tests on ${{ matrix.os }}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
needs: check-changes
|
||||||
|
if: ${{ contains(fromJSON(needs.check-changes.outputs.changes), 'ng-schematics') }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os:
|
||||||
|
- ubuntu-latest
|
||||||
|
- windows-latest
|
||||||
|
- macos-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||||
|
- name: Set up Node.js
|
||||||
|
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
|
||||||
|
with:
|
||||||
|
cache: npm
|
||||||
|
node-version: lts/*
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci
|
||||||
|
env:
|
||||||
|
PUPPETEER_SKIP_DOWNLOAD: true
|
||||||
|
- name: Run tests
|
||||||
|
run: npm run test:smoke
|
||||||
|
working-directory: ./packages/ng-schematics
|
||||||
|
|
||||||
|
ng-schematics-smoke-tests-required:
|
||||||
|
name: '[Required] Angular Schematics smoke tests'
|
||||||
|
needs: [check-changes, ng-schematics-smoke-tests]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: ${{ always() }}
|
||||||
|
steps:
|
||||||
|
- if: ${{ needs.ng-schematics-smoke-tests.result != 'success' && contains(fromJSON(needs.check-changes.outputs.changes), 'ng-schematics') }}
|
||||||
|
run: 'exit 1'
|
||||||
|
- run: 'exit 0'
|
||||||
|
|
||||||
browsers-tests:
|
browsers-tests:
|
||||||
name: Browsers tests on ${{ matrix.os }}
|
name: Browsers tests on ${{ matrix.os }}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
@ -16,6 +16,6 @@
|
|||||||
|
|
||||||
export const testChromeBuildId = '113.0.5672.0';
|
export const testChromeBuildId = '113.0.5672.0';
|
||||||
export const testChromiumBuildId = '1083080';
|
export const testChromiumBuildId = '1083080';
|
||||||
export const testFirefoxBuildId = '121.0a1';
|
export const testFirefoxBuildId = '122.0a1';
|
||||||
export const testChromeDriverBuildId = '115.0.5763.0';
|
export const testChromeDriverBuildId = '115.0.5763.0';
|
||||||
export const testChromeHeadlessShellBuildId = '118.0.5950.0';
|
export const testChromeHeadlessShellBuildId = '118.0.5950.0';
|
||||||
|
@ -32,8 +32,8 @@ ng e2e
|
|||||||
When adding schematics to your project you can to provide following options:
|
When adding schematics to your project you can to provide following options:
|
||||||
|
|
||||||
| Option | Description | Value | Required |
|
| Option | Description | Value | Required |
|
||||||
| -------------- | ------------------------------------------------------ | ------------------------------------------ | -------- |
|
| --------------- | ------------------------------------------------------ | ------------------------------------------ | -------- |
|
||||||
| `--testRunner` | The testing framework to install along side Puppeteer. | `"jasmine"`, `"jest"`, `"mocha"`, `"node"` | `true` |
|
| `--test-runner` | The testing framework to install along side Puppeteer. | `"jasmine"`, `"jest"`, `"mocha"`, `"node"` | `true` |
|
||||||
|
|
||||||
## Creating a single test file
|
## Creating a single test file
|
||||||
|
|
||||||
|
@ -9,7 +9,8 @@
|
|||||||
"dev": "npm run build --watch",
|
"dev": "npm run build --watch",
|
||||||
"sandbox:test": "node tools/sandbox.js --test",
|
"sandbox:test": "node tools/sandbox.js --test",
|
||||||
"sandbox": "node tools/sandbox.js",
|
"sandbox": "node tools/sandbox.js",
|
||||||
"test": "wireit"
|
"test": "wireit",
|
||||||
|
"test:smoke": "wireit"
|
||||||
},
|
},
|
||||||
"wireit": {
|
"wireit": {
|
||||||
"build": {
|
"build": {
|
||||||
@ -31,6 +32,12 @@
|
|||||||
"dependencies": [
|
"dependencies": [
|
||||||
"build"
|
"build"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"test:smoke": {
|
||||||
|
"command": "node ./tools/smoke.mjs",
|
||||||
|
"dependencies": [
|
||||||
|
"build"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import {spawn} from 'child_process';
|
import {spawn} from 'child_process';
|
||||||
|
import {normalize, join} from 'path';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
createBuilder,
|
createBuilder,
|
||||||
@ -69,7 +70,7 @@ function updateExecutablePath(command: string, root?: string) {
|
|||||||
path = `./${path}${command}`;
|
path = `./${path}${command}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return path;
|
return normalize(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function executeCommand(context: BuilderContext, command: string[]) {
|
async function executeCommand(context: BuilderContext, command: string[]) {
|
||||||
@ -84,12 +85,13 @@ async function executeCommand(context: BuilderContext, command: string[]) {
|
|||||||
const {executable, args, debugError, error} = getExecutable(command);
|
const {executable, args, debugError, error} = getExecutable(command);
|
||||||
let path = context.workspaceRoot;
|
let path = context.workspaceRoot;
|
||||||
if (context.target) {
|
if (context.target) {
|
||||||
path = `${path}/${project['root']}`;
|
path = join(path, (project['root'] as string | undefined) ?? '');
|
||||||
}
|
}
|
||||||
|
|
||||||
const child = spawn(executable, args, {
|
const child = spawn(executable, args, {
|
||||||
cwd: path,
|
cwd: path,
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
|
shell: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
child.on('error', message => {
|
child.on('error', message => {
|
||||||
|
@ -19,11 +19,6 @@ import {readFile, writeFile} from 'fs/promises';
|
|||||||
import {join} from 'path';
|
import {join} from 'path';
|
||||||
import {cwd} from 'process';
|
import {cwd} from 'process';
|
||||||
|
|
||||||
const isInit = process.argv.indexOf('--init') !== -1;
|
|
||||||
const isMulti = process.argv.indexOf('--multi') !== -1;
|
|
||||||
const isBuild = process.argv.indexOf('--build') !== -1;
|
|
||||||
const isE2E = process.argv.indexOf('--e2e') !== -1;
|
|
||||||
const isConfig = process.argv.indexOf('--config') !== -1;
|
|
||||||
const commands = {
|
const commands = {
|
||||||
build: ['npm run build'],
|
build: ['npm run build'],
|
||||||
createSandbox: ['npx ng new sandbox --defaults'],
|
createSandbox: ['npx ng new sandbox --defaults'],
|
||||||
@ -44,30 +39,55 @@ const commands = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
runSchematics: [
|
/**
|
||||||
|
* @param {Boolean} isMulti
|
||||||
|
*/
|
||||||
|
runSchematics: isMulti => {
|
||||||
|
return [
|
||||||
{
|
{
|
||||||
command: 'npm run schematics',
|
command: 'npm run schematics',
|
||||||
options: {
|
options: {
|
||||||
cwd: join(cwd(), '/sandbox/'),
|
cwd: join(cwd(), isMulti ? '/multi/' : '/sandbox/'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
];
|
||||||
runSchematicsE2E: [
|
},
|
||||||
|
/**
|
||||||
|
* @param {Boolean} isMulti
|
||||||
|
*/
|
||||||
|
runSchematicsE2E: isMulti => {
|
||||||
|
return [
|
||||||
{
|
{
|
||||||
command: 'npm run schematics:e2e',
|
command: 'npm run schematics:e2e',
|
||||||
options: {
|
options: {
|
||||||
cwd: join(cwd(), '/sandbox/'),
|
cwd: join(cwd(), isMulti ? '/multi/' : '/sandbox/'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
];
|
||||||
runSchematicsConfig: [
|
},
|
||||||
|
/**
|
||||||
|
* @param {Boolean} isMulti
|
||||||
|
*/
|
||||||
|
runSchematicsConfig: isMulti => {
|
||||||
|
return [
|
||||||
{
|
{
|
||||||
command: 'npm run schematics:config',
|
command: 'npm run schematics:config',
|
||||||
options: {
|
options: {
|
||||||
cwd: join(cwd(), '/sandbox/'),
|
cwd: join(cwd(), isMulti ? '/multi/' : '/sandbox/'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
];
|
||||||
|
},
|
||||||
|
runSchematicsSmoke: isMulti => {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
command: 'npm run schematics:smoke',
|
||||||
|
options: {
|
||||||
|
cwd: join(cwd(), isMulti ? '/multi/' : '/sandbox/'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
},
|
||||||
};
|
};
|
||||||
const scripts = {
|
const scripts = {
|
||||||
// Builds the ng-schematics before running them
|
// Builds the ng-schematics before running them
|
||||||
@ -76,12 +96,11 @@ const scripts = {
|
|||||||
'delete:file':
|
'delete:file':
|
||||||
'rm -f .puppeteerrc.cjs && rm -f tsconfig.e2e.json && rm -R -f e2e/',
|
'rm -f .puppeteerrc.cjs && rm -f tsconfig.e2e.json && rm -R -f e2e/',
|
||||||
// Runs the Puppeteer Ng-Schematics against the sandbox
|
// Runs the Puppeteer Ng-Schematics against the sandbox
|
||||||
schematics:
|
schematics: 'schematics ../:ng-add --dry-run=false',
|
||||||
'npm run delete:file && npm run build:schematics && schematics ../:ng-add --dry-run=false',
|
'schematics:e2e': 'schematics ../:e2e --dry-run=false',
|
||||||
'schematics:e2e':
|
'schematics:config': 'schematics ../:config --dry-run=false',
|
||||||
'npm run build:schematics && schematics ../:e2e --dry-run=false',
|
'schematics:smoke':
|
||||||
'schematics:config':
|
'schematics ../:ng-add --dry-run=false --test-runner="node" && ng e2e',
|
||||||
'npm run build:schematics && schematics ../:config --dry-run=false',
|
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -123,7 +142,18 @@ async function executeCommand(commands) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
/**
|
||||||
|
*
|
||||||
|
* @param {*} param0
|
||||||
|
*/
|
||||||
|
export async function runNgSchematicsSandbox({
|
||||||
|
isInit,
|
||||||
|
isMulti,
|
||||||
|
isBuild,
|
||||||
|
isE2E,
|
||||||
|
isConfig,
|
||||||
|
isSmoke,
|
||||||
|
}) {
|
||||||
if (isInit) {
|
if (isInit) {
|
||||||
if (isMulti) {
|
if (isMulti) {
|
||||||
await executeCommand(commands.createMultiWorkspace);
|
await executeCommand(commands.createMultiWorkspace);
|
||||||
@ -133,7 +163,6 @@ async function main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const directory = isMulti ? 'multi' : 'sandbox';
|
const directory = isMulti ? 'multi' : 'sandbox';
|
||||||
|
|
||||||
const packageJsonFile = join(cwd(), `/${directory}/package.json`);
|
const packageJsonFile = join(cwd(), `/${directory}/package.json`);
|
||||||
const packageJson = JSON.parse(await readFile(packageJsonFile));
|
const packageJson = JSON.parse(await readFile(packageJsonFile));
|
||||||
packageJson['scripts'] = {
|
packageJson['scripts'] = {
|
||||||
@ -146,16 +175,35 @@ async function main() {
|
|||||||
await executeCommand(commands.build);
|
await executeCommand(commands.build);
|
||||||
}
|
}
|
||||||
if (isE2E) {
|
if (isE2E) {
|
||||||
await executeCommand(commands.runSchematicsE2E);
|
await executeCommand(commands.runSchematicsE2E(isMulti));
|
||||||
} else if (isConfig) {
|
} else if (isConfig) {
|
||||||
await executeCommand(commands.runSchematicsConfig);
|
await executeCommand(commands.runSchematicsConfig(isMulti));
|
||||||
|
} else if (isSmoke) {
|
||||||
|
await executeCommand(commands.runSchematicsSmoke(isMulti));
|
||||||
} else {
|
} else {
|
||||||
await executeCommand(commands.runSchematics);
|
await executeCommand(commands.runSchematics(isMulti));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
main().catch(error => {
|
async function main() {
|
||||||
|
const options = {
|
||||||
|
isInit: process.argv.indexOf('--init') !== -1,
|
||||||
|
isMulti: process.argv.indexOf('--multi') !== -1,
|
||||||
|
isBuild: process.argv.indexOf('--build') !== -1,
|
||||||
|
isE2E: process.argv.indexOf('--e2e') !== -1,
|
||||||
|
isConfig: process.argv.indexOf('--config') !== -1,
|
||||||
|
};
|
||||||
|
const isShell = Object.values(options).some(value => {
|
||||||
|
return value;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (isShell) {
|
||||||
|
await runNgSchematicsSandbox(getOptions()).catch(error => {
|
||||||
console.log('Something went wrong');
|
console.log('Something went wrong');
|
||||||
console.error(error);
|
console.error(error);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main();
|
||||||
|
27
packages/ng-schematics/tools/smoke.mjs
Normal file
27
packages/ng-schematics/tools/smoke.mjs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import {execSync} from 'child_process';
|
||||||
|
|
||||||
|
import {runNgSchematicsSandbox} from './sandbox.mjs';
|
||||||
|
|
||||||
|
if (process.env.CI) {
|
||||||
|
execSync('npm install -g @angular/cli@latest');
|
||||||
|
execSync('npm install -g @angular-devkit/schematics-cli');
|
||||||
|
}
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
runNgSchematicsSandbox({
|
||||||
|
isInit: true,
|
||||||
|
}),
|
||||||
|
runNgSchematicsSandbox({
|
||||||
|
isInit: true,
|
||||||
|
isMulti: true,
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
|
||||||
|
await runNgSchematicsSandbox({
|
||||||
|
isSmoke: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
await runNgSchematicsSandbox({
|
||||||
|
isMulti: true,
|
||||||
|
isSmoke: true,
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user