chore(repo): use root-level scripts
This commit is contained in:
parent
bf4f6c0a76
commit
ffd40af446
@ -176,7 +176,7 @@ jobs:
|
|||||||
- run: npx nx-cloud start-ci-run --stop-agents-after="e2e"
|
- run: npx nx-cloud start-ci-run --stop-agents-after="e2e"
|
||||||
- run:
|
- run:
|
||||||
name: Check Documentation
|
name: Check Documentation
|
||||||
command: npx nx-cloud record yarn documentation
|
command: npx nx documentation --no-dte
|
||||||
no_output_timeout: 20m
|
no_output_timeout: 20m
|
||||||
- run:
|
- run:
|
||||||
name: Run Checks/Lint/Test/Build
|
name: Run Checks/Lint/Test/Build
|
||||||
@ -184,12 +184,12 @@ jobs:
|
|||||||
command: |
|
command: |
|
||||||
pids=()
|
pids=()
|
||||||
|
|
||||||
(npx nx-cloud record yarn check-imports &&
|
(npx nx check-imports --no-dte &&
|
||||||
npx nx-cloud record yarn nx format:check --base=$NX_BASE --head=$NX_HEAD &&
|
npx nx-cloud record -- nx format:check --base=$NX_BASE --head=$NX_HEAD &&
|
||||||
npx nx-cloud record yarn check-commit &&
|
npx nx check-commit --no-dte &&
|
||||||
npx nx-cloud record yarn check-lock-files &&
|
npx nx check-lock-files --no-dte &&
|
||||||
npx nx-cloud record yarn nx workspace-lint &&
|
npx nx lint --no-dte &&
|
||||||
npx nx-cloud record yarn depcheck) &
|
npx nx depcheck --no-dte ) &
|
||||||
pids+=($!)
|
pids+=($!)
|
||||||
|
|
||||||
yarn nx affected --target=lint --base=$NX_BASE --head=$NX_HEAD --parallel=3 &
|
yarn nx affected --target=lint --base=$NX_BASE --head=$NX_HEAD --parallel=3 &
|
||||||
|
|||||||
@ -14,6 +14,8 @@ packages/react/src/schematics/**/files/**/*.json
|
|||||||
packages/jest/src/schematics/**/files/**/*.json
|
packages/jest/src/schematics/**/files/**/*.json
|
||||||
packages/**/schematics/**/files/**/*.html
|
packages/**/schematics/**/files/**/*.html
|
||||||
packages/**/generators/**/files/**/*.html
|
packages/**/generators/**/files/**/*.html
|
||||||
|
nx-dev/nx-dev/.next/
|
||||||
|
docs/generated/
|
||||||
/.vscode
|
/.vscode
|
||||||
/.idea
|
/.idea
|
||||||
/.github
|
/.github
|
||||||
|
|||||||
@ -250,7 +250,7 @@ Please follow the following guidelines:
|
|||||||
- Debug with `node --inspect-brk ./node_modules/jest/bin/jest.js build/packages/angular/src/utils/ast-utils.spec.js`
|
- Debug with `node --inspect-brk ./node_modules/jest/bin/jest.js build/packages/angular/src/utils/ast-utils.spec.js`
|
||||||
- Make sure e2e tests pass (this can take a while, so you can always let CI check those) (`nx affected --target=e2e`)
|
- Make sure e2e tests pass (this can take a while, so you can always let CI check those) (`nx affected --target=e2e`)
|
||||||
- Target a specific e2e test with `nx e2e e2e-cypress`
|
- Target a specific e2e test with `nx e2e e2e-cypress`
|
||||||
- Make sure you run `yarn format`
|
- Make sure you run `nx format`
|
||||||
- Update documentation with `yarn documentation`. For documentation, check for spelling and grammatical errors.
|
- Update documentation with `yarn documentation`. For documentation, check for spelling and grammatical errors.
|
||||||
- Update your commit message to follow the guidelines below (use `yarn commit` to automate compliance)
|
- Update your commit message to follow the guidelines below (use `yarn commit` to automate compliance)
|
||||||
- `yarn check-commit` will check to make sure your commit messages are formatted correctly
|
- `yarn check-commit` will check to make sure your commit messages are formatted correctly
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -38,21 +38,22 @@ Example:
|
|||||||
mockSchematicsForTesting({
|
mockSchematicsForTesting({
|
||||||
'mycollection:myschematic': (tree, params) => {
|
'mycollection:myschematic': (tree, params) => {
|
||||||
tree.write('README.md');
|
tree.write('README.md');
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type |
|
| Name | Type |
|
||||||
| :----------- | :------- |
|
| :------ | :------ |
|
||||||
| `schematics` | `Object` |
|
| `schematics` | `Object` |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`void`
|
`void`
|
||||||
|
|
||||||
---
|
___
|
||||||
|
|
||||||
### overrideCollectionResolutionForTesting
|
### overrideCollectionResolutionForTesting
|
||||||
|
|
||||||
@ -68,26 +69,24 @@ Example:
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
overrideCollectionResolutionForTesting({
|
overrideCollectionResolutionForTesting({
|
||||||
'@nrwl/workspace': path.join(
|
'@nrwl/workspace': path.join(__dirname, '../../../../workspace/generators.json'),
|
||||||
__dirname,
|
|
||||||
'../../../../workspace/generators.json'
|
|
||||||
),
|
|
||||||
'@nrwl/angular': path.join(__dirname, '../../../../angular/generators.json'),
|
'@nrwl/angular': path.join(__dirname, '../../../../angular/generators.json'),
|
||||||
'@nrwl/linter': path.join(__dirname, '../../../../linter/generators.json'),
|
'@nrwl/linter': path.join(__dirname, '../../../../linter/generators.json')
|
||||||
});
|
});
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type |
|
| Name | Type |
|
||||||
| :------------ | :------- |
|
| :------ | :------ |
|
||||||
| `collections` | `Object` |
|
| `collections` | `Object` |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`void`
|
`void`
|
||||||
|
|
||||||
---
|
___
|
||||||
|
|
||||||
### wrapAngularDevkitSchematic
|
### wrapAngularDevkitSchematic
|
||||||
|
|
||||||
@ -96,7 +95,7 @@ overrideCollectionResolutionForTesting({
|
|||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type |
|
| Name | Type |
|
||||||
| :--------------- | :------- |
|
| :------ | :------ |
|
||||||
| `collectionName` | `string` |
|
| `collectionName` | `string` |
|
||||||
| `generatorName` | `string` |
|
| `generatorName` | `string` |
|
||||||
|
|
||||||
@ -109,7 +108,7 @@ overrideCollectionResolutionForTesting({
|
|||||||
##### Parameters
|
##### Parameters
|
||||||
|
|
||||||
| Name | Type |
|
| Name | Type |
|
||||||
| :----------------- | :-------------------------------- |
|
| :------ | :------ |
|
||||||
| `host` | [`Tree`](../../devkit/index#tree) |
|
| `host` | [`Tree`](../../devkit/index#tree) |
|
||||||
| `generatorOptions` | `Object` |
|
| `generatorOptions` | `Object` |
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
13
nx.json
13
nx.json
@ -3,7 +3,6 @@
|
|||||||
"affected": {
|
"affected": {
|
||||||
"defaultBase": "master"
|
"defaultBase": "master"
|
||||||
},
|
},
|
||||||
"npmScope": "nrwl",
|
|
||||||
"tasksRunnerOptions": {
|
"tasksRunnerOptions": {
|
||||||
"default": {
|
"default": {
|
||||||
"runner": "@nrwl/nx-cloud",
|
"runner": "@nrwl/nx-cloud",
|
||||||
@ -25,10 +24,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"workspaceLayout": {
|
|
||||||
"libsDir": "",
|
|
||||||
"appsDir": ""
|
|
||||||
},
|
|
||||||
"namedInputs": {
|
"namedInputs": {
|
||||||
"default": ["{projectRoot}/**/*", "sharedGlobals"],
|
"default": ["{projectRoot}/**/*", "sharedGlobals"],
|
||||||
"production": [
|
"production": [
|
||||||
@ -86,11 +81,5 @@
|
|||||||
"inputs": ["default", "^production", "{workspaceRoot}/.storybook/**/*"]
|
"inputs": ["default", "^production", "{workspaceRoot}/.storybook/**/*"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"generators": {
|
"defaultProject": "@nrwl/nx-source"
|
||||||
"@nrwl/react": {
|
|
||||||
"application": {
|
|
||||||
"babel": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
16
package.json
16
package.json
@ -10,11 +10,9 @@
|
|||||||
"check-format": "nx format:check --all",
|
"check-format": "nx format:check --all",
|
||||||
"check-imports": "node ./scripts/check-imports.js",
|
"check-imports": "node ./scripts/check-imports.js",
|
||||||
"check-lock-files": "node ./scripts/check-lock-files.js",
|
"check-lock-files": "node ./scripts/check-lock-files.js",
|
||||||
"check-versions": "ts-node -P ./scripts/tsconfig.scripts.json ./scripts/check-versions.ts",
|
|
||||||
"check-documentation-map": "ts-node -P ./scripts/tsconfig.scripts.json ./scripts/documentation/map-link-checker.ts",
|
"check-documentation-map": "ts-node -P ./scripts/tsconfig.scripts.json ./scripts/documentation/map-link-checker.ts",
|
||||||
"e2e-start-local-registry": "node ./scripts/e2e-start-local-registry.js",
|
"e2e-start-local-registry": "node ./scripts/e2e-start-local-registry.js",
|
||||||
"e2e-build-package-publish": "ts-node -P ./scripts/tsconfig.e2e.json ./scripts/e2e-build-package-publish.ts",
|
"e2e-build-package-publish": "ts-node -P ./scripts/tsconfig.e2e.json ./scripts/e2e-build-package-publish.ts",
|
||||||
"format": "nx format",
|
|
||||||
"nx-release": "ts-node -P ./scripts/tsconfig.scripts.json ./scripts/nx-release",
|
"nx-release": "ts-node -P ./scripts/tsconfig.scripts.json ./scripts/nx-release",
|
||||||
"prepublishOnly": "node ./scripts/update-package-group.js",
|
"prepublishOnly": "node ./scripts/update-package-group.js",
|
||||||
"version": "npx prettier lerna.json --write",
|
"version": "npx prettier lerna.json --write",
|
||||||
@ -23,7 +21,8 @@
|
|||||||
"documentation": "ts-node -P scripts/tsconfig.scripts.json ./scripts/documentation/documentation.ts && yarn check-documentation-map",
|
"documentation": "ts-node -P scripts/tsconfig.scripts.json ./scripts/documentation/documentation.ts && yarn check-documentation-map",
|
||||||
"submit-plugin": "node ./scripts/submit-plugin.js",
|
"submit-plugin": "node ./scripts/submit-plugin.js",
|
||||||
"prepare": "is-ci || husky install",
|
"prepare": "is-ci || husky install",
|
||||||
"echo": "echo 123458"
|
"echo": "echo 123458",
|
||||||
|
"lint": "nx workspace-lint"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular-devkit/architect": "~0.1500.0",
|
"@angular-devkit/architect": "~0.1500.0",
|
||||||
@ -308,6 +307,17 @@
|
|||||||
"**/xmlhttprequest-ssl": "~1.6.2",
|
"**/xmlhttprequest-ssl": "~1.6.2",
|
||||||
"minimist": "^1.2.6",
|
"minimist": "^1.2.6",
|
||||||
"underscore": "^1.12.1"
|
"underscore": "^1.12.1"
|
||||||
|
},
|
||||||
|
"nx": {
|
||||||
|
"includeScripts": [
|
||||||
|
"echo",
|
||||||
|
"check-format",
|
||||||
|
"check-imports",
|
||||||
|
"check-lock-files",
|
||||||
|
"depcheck",
|
||||||
|
"documentation",
|
||||||
|
"lint"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,196 +0,0 @@
|
|||||||
/*
|
|
||||||
* This script checks if new versions of node modules are available.
|
|
||||||
* It uses naming conventions to transform constants to matching node module name.
|
|
||||||
*
|
|
||||||
* Usage:
|
|
||||||
* yarn check-versions [file|package]
|
|
||||||
*
|
|
||||||
* Positional arg:
|
|
||||||
* - [file]: relative or absolute file path to the versions file.
|
|
||||||
*
|
|
||||||
* Example:
|
|
||||||
* yarn check-versions react
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { join, relative } from 'path';
|
|
||||||
import { gt } from 'semver';
|
|
||||||
import { readJsonSync, writeJsonSync } from 'fs-extra';
|
|
||||||
import * as chalk from 'chalk';
|
|
||||||
import { dasherize } from '../packages/workspace/src/utils/strings';
|
|
||||||
import * as glob from 'glob';
|
|
||||||
import { execSync } from 'child_process';
|
|
||||||
import { readFileSync, writeFileSync } from 'fs';
|
|
||||||
|
|
||||||
const root = join(__dirname, '..');
|
|
||||||
const excluded = ['nxVersion'];
|
|
||||||
const scoped = [
|
|
||||||
'babel',
|
|
||||||
'emotion',
|
|
||||||
'reduxjs',
|
|
||||||
'swc',
|
|
||||||
'testing-library',
|
|
||||||
'types',
|
|
||||||
];
|
|
||||||
|
|
||||||
try {
|
|
||||||
const files = process.argv[2]
|
|
||||||
? [normalize(process.argv[2])]
|
|
||||||
: glob.sync('packages/**/*/versions.ts').map((x) => relative(root, x));
|
|
||||||
checkFiles(files);
|
|
||||||
} catch (e) {
|
|
||||||
console.log(chalk.red(e.message));
|
|
||||||
process.exitCode = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
function normalize(x: string) {
|
|
||||||
if (x.endsWith('.ts')) {
|
|
||||||
return x;
|
|
||||||
} else {
|
|
||||||
return join('packages', x, 'src/utils/versions.ts');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
function checkFiles(files: string[]) {
|
|
||||||
console.log(chalk.blue(`Checking versions in the following files...\n`));
|
|
||||||
console.log(` - ${files.join('\n - ')}\n`);
|
|
||||||
const maxFileNameLength = Math.max(...files.map((f) => f.length));
|
|
||||||
|
|
||||||
let hasError = false;
|
|
||||||
|
|
||||||
files.forEach((f) => {
|
|
||||||
const projectRoot = f.split('/src/')[0];
|
|
||||||
const migrationsPath = join(projectRoot, 'migrations.json');
|
|
||||||
const migrationsJson = readJsonSync(migrationsPath);
|
|
||||||
let versionsContent = readFileSync(f).toString();
|
|
||||||
const versions = getVersions(f);
|
|
||||||
const npmPackages = getPackages(versions);
|
|
||||||
const results = npmPackages.map(([p, v, o]) => getVersionData(p, v, o));
|
|
||||||
const logContext = `${f.padEnd(maxFileNameLength)}`;
|
|
||||||
const packageUpdates = {};
|
|
||||||
|
|
||||||
results.forEach((r) => {
|
|
||||||
if (r.outdated) {
|
|
||||||
console.log(
|
|
||||||
`${logContext} ❗ ${chalk.bold(
|
|
||||||
r.package
|
|
||||||
)} has new version ${chalk.bold(r.latest)} (current: ${r.prev})`
|
|
||||||
);
|
|
||||||
versionsContent = versionsContent.replace(
|
|
||||||
`${r.variable} = '${r.prev}'`,
|
|
||||||
`${r.variable} = '${r.latest}'`
|
|
||||||
);
|
|
||||||
packageUpdates[r.package] = {
|
|
||||||
version: r.latest,
|
|
||||||
alwaysAddToPackageJson: false,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (r.invalid) {
|
|
||||||
hasError = true;
|
|
||||||
console.log(
|
|
||||||
`${logContext} ⚠️ ${chalk.bold(r.package)} has an invalid version (${
|
|
||||||
r.prev
|
|
||||||
}) specified. Latest is ${r.latest}.`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (Object.keys(packageUpdates).length > 0) {
|
|
||||||
migrationsJson.packageJsonUpdates['x.y.z'] = {
|
|
||||||
version: 'x.y.z',
|
|
||||||
packages: packageUpdates,
|
|
||||||
};
|
|
||||||
writeFileSync(f, versionsContent);
|
|
||||||
writeJsonSync(migrationsPath, migrationsJson, { spaces: 2 });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (hasError) {
|
|
||||||
throw new Error('Invalid versions of packages found (please see above).');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getVersions(path: string) {
|
|
||||||
const versionsPath =
|
|
||||||
path.startsWith('.') || path.startsWith('packages')
|
|
||||||
? join(__dirname, '..', path)
|
|
||||||
: path;
|
|
||||||
try {
|
|
||||||
return require(versionsPath);
|
|
||||||
} catch {
|
|
||||||
throw new Error(`Could not load ${path}. Please make sure it is valid.`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getPackages(versions: Record<string, string>): string[][] {
|
|
||||||
return Object.entries(versions).reduce((acc, [name, version]) => {
|
|
||||||
if (!excluded.includes(name)) {
|
|
||||||
const npmName = getNpmName(name);
|
|
||||||
acc.push([npmName, version, name]);
|
|
||||||
}
|
|
||||||
return acc;
|
|
||||||
}, [] as string[][]);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getNpmName(name: string): string {
|
|
||||||
const dashedName = dasherize(name.replace(/Version$/, ''));
|
|
||||||
const scope = scoped.find((s) => dashedName.startsWith(`${s}-`));
|
|
||||||
|
|
||||||
if (scope) {
|
|
||||||
const rest = dashedName.split(`${scope}-`)[1];
|
|
||||||
return `@${scope}/${rest}`;
|
|
||||||
} else {
|
|
||||||
return dashedName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getVersionData(
|
|
||||||
p: string,
|
|
||||||
v: string,
|
|
||||||
o: string
|
|
||||||
): {
|
|
||||||
variable: string;
|
|
||||||
package: string;
|
|
||||||
outdated: boolean;
|
|
||||||
invalid: boolean;
|
|
||||||
latest: string;
|
|
||||||
prev?: string;
|
|
||||||
} {
|
|
||||||
try {
|
|
||||||
const latest = JSON.parse(
|
|
||||||
execSync(`npm view ${p} version --json --silent`, {
|
|
||||||
stdio: ['ignore'],
|
|
||||||
}).toString('utf-8')
|
|
||||||
);
|
|
||||||
if (gt(latest, v)) {
|
|
||||||
return {
|
|
||||||
variable: o,
|
|
||||||
package: p,
|
|
||||||
outdated: true,
|
|
||||||
invalid: false,
|
|
||||||
latest,
|
|
||||||
prev: v,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (gt(v, latest)) {
|
|
||||||
return {
|
|
||||||
variable: o,
|
|
||||||
package: p,
|
|
||||||
outdated: false,
|
|
||||||
invalid: true,
|
|
||||||
latest,
|
|
||||||
prev: v,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
// ignored
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
variable: o,
|
|
||||||
package: p,
|
|
||||||
outdated: false,
|
|
||||||
invalid: false,
|
|
||||||
latest: v,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user