Compare commits

...

26 Commits

Author SHA1 Message Date
Victor Savkin a6642bf2a8 chore(misc): publish 16.1.3 2023-05-08 16:22:12 -04:00
Victor Savkin bd8cbfaddd chore(misc): publish 16.1.3-beta.0 2023-05-08 15:42:19 -04:00
Leosvel Pérez Espinosa 6f03d0c50a feat(angular): update jest-preset-angular to support angular v16 (#16852) 2023-05-08 15:39:35 -04:00
Leosvel Pérez Espinosa 1bbeed0ac0 feat(storybook): update storybook packages to support typescript v5 (#16853) 2023-05-08 15:39:35 -04:00
Jack Hsu c420793d5e fix(nextjs): withNx works with production build (#16867) 2023-05-08 15:39:35 -04:00
Miroslav Jonaš 16c212fc2c fix(linter): support directories for relative path fix (#16854) 2023-05-08 15:39:35 -04:00
FrozenPandaz 4e2d33c9e1 chore(misc): publish 16.1.2 2023-05-08 09:49:49 -04:00
John White 0defcad1a2 fix(core): migrate using yarn when nxJson has another package manager configured (#16844)
(cherry picked from commit 0654776106)
2023-05-08 09:46:22 -04:00
Marwan Fikrat 4233effd06 feat(core): add skipTypeCheck option to rollup plugin options (#16710)
(cherry picked from commit 878df9a618)
2023-05-08 09:46:11 -04:00
FrozenPandaz 1488728aa3 chore(misc): publish 16.1.1 2023-05-05 17:49:50 -04:00
FrozenPandaz a627a0c26f chore(misc): publish 16.1.1-beta.1 2023-05-05 17:45:28 -04:00
FrozenPandaz 75c06380c6 chore(misc): publish 16.1.1-beta.0 2023-05-05 17:45:27 -04:00
FrozenPandaz 127e8d44c1 Revert "chore(misc): publish 16.1.1-beta.0"
This reverts commit fa25a47614.
2023-05-05 17:45:27 -04:00
Jason Jean 6e08e3f7a6 chore(core): add repo information to native packages (#16826) 2023-05-05 17:45:26 -04:00
Jason Jean b93d46dbc9 fix(devkit): fix issue replacing package dependencies in malformed pa… (#16823) 2023-05-05 17:45:26 -04:00
Craigory Coppola 197105af9a fix(misc): make Nx 16 migration safer when treee throws an exception (#16782) 2023-05-05 17:45:25 -04:00
Craigory Coppola 84dd4180ba feat(repo): add CI check for valid codeowners patterns (#16729) 2023-05-05 17:45:24 -04:00
FrozenPandaz f7fcc6facb chore(misc): publish 16.1.1-beta.0 2023-05-05 17:43:58 -04:00
Jack Hsu 8beb4e4424 fix(nextjs): enable Next.js 13.4 support (#16819) 2023-05-05 17:43:57 -04:00
Craigory Coppola 7eec0d73ae fix(core): obey nx.json package manager property (#16777) 2023-05-05 17:43:57 -04:00
Craigory Coppola a0fb8df4d2 fix(devkit): ensure ignore has been initialized in visitNotIgnoredFiles (#16820) 2023-05-05 17:43:56 -04:00
Craigory Coppola 4942eb4965 fix(misc): update URL to point to live page for plugin registry (#16817) 2023-05-05 17:43:56 -04:00
Vinit Neogi f4724bc621 cleanup(misc): add types to getVersion function (#16677) 2023-05-05 17:43:55 -04:00
Jack Hsu 08de51eea7 docs(core): update Next.js version to 13.3.4 (#16818) 2023-05-05 17:43:55 -04:00
James Henry c63bf49c97 chore(core): enable provenance and update lerna usage (#16814) 2023-05-05 17:43:54 -04:00
Leosvel Pérez Espinosa e7e78c56cd fix(core): handle schema property with const value (#16797) 2023-05-05 17:43:54 -04:00
42 changed files with 1313 additions and 1456 deletions
+1 -1
View File
@@ -194,7 +194,7 @@ jobs:
pnpm nx-cloud record -- nx format:check --base=$NX_BASE --head=$NX_HEAD &
pids+=($!)
pnpm nx run-many -t check-imports check-commit check-lock-files depcheck --parallel=1 --no-dte &
pnpm nx run-many -t check-imports check-commit check-lock-files depcheck check-codeowners --parallel=1 --no-dte &
pids+=($!)
pnpm nx affected --target=lint --base=$NX_BASE --head=$NX_HEAD --parallel=3 &
+3
View File
@@ -2,6 +2,7 @@ name: publish
env:
DEBUG: napi:*
NX_RUN_GROUP: ${{ github.run_id }}-${{ github.run_attempt }}
NPM_CONFIG_PROVENANCE: true
on:
release:
types: [published]
@@ -203,6 +204,8 @@ jobs:
if: ${{ github.repository_owner == 'nrwl' }}
name: Publish
runs-on: ubuntu-latest
permissions:
id-token: write
needs:
# - build-freebsd
- build
+8 -6
View File
@@ -11,7 +11,7 @@ pnpm-lock.yaml @FrozenPandaz @vsavkin @AgentEnder @jaysoo @JamesHenry
/docs @bcabanes @isaacplmann @juristr
/docs/nx-cloud @StalkAltan @rarmatei @isaacplmann @juristr @bcabanes
/graph/** @philipjfulcher @FrozenPandaz @bcabanes
/images/shared @bcabanes @isaacplmann @juristr
/images @bcabanes @isaacplmann @juristr
/nx-dev/** @bcabanes @isaacplmann @juristr
/typedoc-theme @bcabanes @isaacplmann
@@ -76,7 +76,6 @@ pnpm-lock.yaml @FrozenPandaz @vsavkin @AgentEnder @jaysoo @JamesHenry
/docs/shared/packages/web/** @jaysoo @mandarini @ndcunningham
/docs/shared/packages/webpack/** @jaysoo @mandarini @ndcunningham
/docs/shared/packages/esbuild/** @nartc @jaysoo @ndcunningham
/docs/shared/packages/rollup/** @jaysoo @mandarini @ndcunningham
/docs/shared/packages/vite/** @jaysoo @mandarini @ndcunningham
/packages/js/** @nartc @jaysoo @ndcunningham
/e2e/js/** @nartc @jaysoo @ndcunningham
@@ -121,14 +120,17 @@ pnpm-lock.yaml @FrozenPandaz @vsavkin @AgentEnder @jaysoo @JamesHenry
/docs/generated/devkit/** @FrozenPandaz @AgentEnder
/docs/generated/packages/devkit/** @FrozenPandaz @AgentEnder
/packages/devkit/** @FrozenPandaz @AgentEnder
/packages/devkit/index.ts @FrozenPandaz @vsavkin
/packages/devkit/index.js @FrozenPandaz @vsavkin
/packages/devkit/index.d.ts @FrozenPandaz @vsavkin
/packages/devkit/public-api.ts @FrozenPandaz @vsavkin
/packages/devkit/nx.ts @FrozenPandaz @vsavkin
/packages/devkit/src/utils/module-federation @jaysoo @Coly010
# Nx-Plugin
/docs/generated/packages/plugin/** @AgentEnder @FrozenPandaz
/docs/shared/packages/plugin/** @AgentEnder @FrozenPandaz @isaacplmann @juristr
/packages/plugin/** @AgentEnder @FrozenPandaz
/e2e/nx-plugin/** @AgentEnder @FrozenPandaz
/e2e/plugin/** @AgentEnder @FrozenPandaz
## Core
/docs/generated/packages/nx/** @vsavkin @FrozenPandaz @AgentEnder
@@ -136,7 +138,7 @@ pnpm-lock.yaml @FrozenPandaz @vsavkin @AgentEnder @jaysoo @JamesHenry
/packages/nx/** @vsavkin @FrozenPandaz @AgentEnder
/packages/nx/src/adapter @AgentEnder @leosvelperez
/packages/nx/src/native @vsavkin @FrozenPandaz @Cammisuli
/packages/nx/src/lock-file @meeroslav @FrozenPandaz
/packages/nx/src/plugins/js/lock-file @meeroslav @FrozenPandaz
/packages/nx/src/nx-init/angular/** @Coly010 @leosvelperez @FrozenPandaz
/e2e/nx-init/src/nx-init-angular.test.ts @Coly010 @leosvelperez
/packages/nx/src/nx-init/react/** @jaysoo @xiongemi @mandarini
@@ -170,7 +172,7 @@ pnpm-lock.yaml @FrozenPandaz @vsavkin @AgentEnder @jaysoo @JamesHenry
# Global Files
project.json @FrozenPandaz @vsavkin
jest.config.ts @barbados-clemens @FrozenPandaz
jest.preset.ts @barbados-clemens @FrozenPandaz
jest.preset.js @barbados-clemens @FrozenPandaz
# Overrides - These are applied last, so override any matches above.
docs/generated/manifests/* @bcabanes @FrozenPandaz @jaysoo @AgentEnder @isaacplmann @juristr
+3 -3
View File
@@ -142,19 +142,19 @@ nx test jest
To make sure your changes do not break any E2E tests, run:
```bash
nx e2e e2e-cli # or any other project here
nx e2e e2e-vite # or any other project here
```
Running E2E tests can take some time, so it is often useful to run a single test. To run a single suite of tests, run:
```bash
nx e2e e2e-cli -t versions # I often add qqqq to my test name so I can use -t qqqq
nx e2e e2e-vite -t versions # I often add qqqq to my test name so I can use -t qqqq
```
Sometimes tests pass locally but they fail on the CI. To reproduce the CI environment and be able to debug the issue, run:
```bash
NX_VERBOSE_LOGGING=true CI=true SELECTED_PM=pnpm pnpm nx e2e e2e-cli --t="should do something is this test"
NX_VERBOSE_LOGGING=true CI=true SELECTED_PM=pnpm pnpm nx e2e e2e-vite --t="should do something is this test"
```
The above command sets verbose logging (this exposes stack traces and underlying errors), sets the defaults to be CI-like and sets Pnpm as the selected package manager.
@@ -159,6 +159,11 @@
"type": "boolean",
"description": "Generate package.json with 'exports' field. This field defines entry points in the package and is used by Node and the TypeScript compiler.",
"default": false
},
"skipTypeCheck": {
"type": "boolean",
"description": "Whether to skip TypeScript type checking.",
"default": false
}
},
"required": ["tsConfig", "main", "outputPath"],
+1 -1
View File
@@ -1,6 +1,6 @@
{
"packages": ["build/packages/*", "build/packages/nx/native-packages/*"],
"version": "16.1.0",
"version": "16.1.3",
"granularPathspec": false,
"command": {
"publish": {
+9 -9
View File
@@ -11,6 +11,7 @@
"check-imports": "node ./scripts/check-imports.js",
"check-lock-files": "node ./scripts/check-lock-files.js",
"check-documentation-map": "ts-node -P ./scripts/tsconfig.scripts.json ./scripts/documentation/map-link-checker.ts",
"check-codeowners": "ts-node -P ./scripts/tsconfig.scripts.json ./scripts/check-codeowners.ts",
"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",
"nx-release": "ts-node -P ./scripts/tsconfig.release.json ./scripts/nx-release",
@@ -48,8 +49,6 @@
"@jest/reporters": "^29.4.1",
"@jest/test-result": "^29.4.1",
"@jest/types": "^29.4.1",
"@lerna/publish": "6.0.0",
"@lerna/version": "6.0.0",
"@monodon/rust": "1.1.2",
"@napi-rs/cli": "2.14.0",
"@nestjs/cli": "^9.0.0",
@@ -86,11 +85,11 @@
"@rollup/plugin-node-resolve": "^13.0.4",
"@rollup/plugin-url": "^7.0.0",
"@schematics/angular": "~16.0.0",
"@storybook/addon-essentials": "^7.0.8",
"@storybook/core-server": "^7.0.8",
"@storybook/react": "^7.0.8",
"@storybook/react-webpack5": "^7.0.8",
"@storybook/types": "^7.0.8",
"@storybook/addon-essentials": "^7.0.9",
"@storybook/core-server": "^7.0.9",
"@storybook/react": "^7.0.9",
"@storybook/react-webpack5": "^7.0.9",
"@storybook/types": "^7.0.9",
"@svgr/rollup": "^6.1.2",
"@svgr/webpack": "^6.1.2",
"@swc-node/register": "^1.4.2",
@@ -194,7 +193,7 @@
"jsonc-eslint-parser": "^2.1.0",
"jsonc-parser": "3.2.0",
"kill-port": "^1.6.1",
"lerna": "6.0.0",
"lerna": "6.6.2",
"less": "4.1.3",
"less-loader": "11.1.0",
"license-webpack-plugin": "^4.0.2",
@@ -311,7 +310,7 @@
"history": "^5.3.0",
"json-schema-to-typescript": "^10.1.5",
"jsonpointer": "^5.0.0",
"next": "13.1.1",
"next": "13.3.4",
"next-seo": "^5.13.0",
"npm-run-path": "^4.0.1",
"preact": "10.6.4",
@@ -341,6 +340,7 @@
"check-format",
"check-imports",
"check-lock-files",
"check-codeowners",
"depcheck",
"documentation"
]
+16
View File
@@ -1110,6 +1110,22 @@
"alwaysAddToPackageJson": false
}
}
},
"16.1.3-jest": {
"version": "16.1.3-beta.0",
"requires": {
"@angular-devkit/build-angular": ">=13.0.0 <17.0.0",
"@angular/compiler-cli": ">=13.0.0 <17.0.0",
"@angular/core": ">=13.0.0 <17.0.0",
"@angular/platform-browser-dynamic": ">=13.0.0 <17.0.0",
"jest": "^29.0.0"
},
"packages": {
"jest-preset-angular": {
"version": "~13.1.0",
"alwaysAddToPackageJson": false
}
}
}
}
}
+1 -1
View File
@@ -25,6 +25,6 @@ export const postcssUrlVersion = '~10.1.3';
export const autoprefixerVersion = '^10.4.0';
export const tsNodeVersion = '10.9.1';
export const jestPresetAngularVersion = '~13.0.0';
export const jestPresetAngularVersion = '~13.1.0';
export const typesNodeVersion = '16.11.7';
export const jasmineMarblesVersion = '^0.9.2';
@@ -18,6 +18,7 @@ export function visitNotIgnoredFiles(
ig.add(tree.read('.gitignore', 'utf-8'));
}
if (tree.exists('.nxignore')) {
ig ??= ignore();
ig.add(tree.read('.nxignore', 'utf-8'));
}
dirPath = normalizePathRelativeToRoot(dirPath, tree.root);
@@ -165,6 +165,14 @@ describe('replaceNrwlPackageWithNxPackage', () => {
});
});
it('should handle broken package.json files', () => {
tree.write('package.json', '{ broken: "json ');
expect(() =>
replaceNrwlPackageWithNxPackage(tree, 'old-package', 'new-package')
).not.toThrow();
});
it('should replace any mentions in files', () => {
expect(tree.read('README.txt').toString()).toContain('new-package');
expect(tree.read('README.txt').toString()).not.toContain('old-package');
+36 -21
View File
@@ -4,6 +4,7 @@ import { requireNx } from '../../nx';
import { visitNotIgnoredFiles } from '../generators/visit-not-ignored-files';
import { basename } from 'path';
import { isBinaryPath } from './binary-extensions';
const { logger } = requireNx();
const {
getProjects,
@@ -37,20 +38,26 @@ function replacePackageInDependencies(
return;
}
updateJson<PackageJson>(tree, path, (packageJson) => {
for (const deps of [
packageJson.dependencies ?? {},
packageJson.devDependencies ?? {},
packageJson.peerDependencies ?? {},
packageJson.optionalDependencies ?? {},
]) {
if (oldPackageName in deps) {
deps[newPackageName] = deps[oldPackageName];
delete deps[oldPackageName];
try {
updateJson<PackageJson>(tree, path, (packageJson) => {
for (const deps of [
packageJson.dependencies ?? {},
packageJson.devDependencies ?? {},
packageJson.peerDependencies ?? {},
packageJson.optionalDependencies ?? {},
]) {
if (oldPackageName in deps) {
deps[newPackageName] = deps[oldPackageName];
delete deps[oldPackageName];
}
}
}
return packageJson;
});
return packageJson;
});
} catch (e) {
console.warn(
`Could not replace ${oldPackageName} with ${newPackageName} in ${path}.`
);
}
});
}
@@ -162,15 +169,23 @@ function replaceMentions(
return;
}
const contents = tree.read(path).toString();
try {
const contents = tree.read(path).toString();
if (!contents.includes(oldPackageName)) {
return;
if (!contents.includes(oldPackageName)) {
return;
}
tree.write(
path,
contents.replace(new RegExp(oldPackageName, 'g'), newPackageName)
);
} catch {
// Its **probably** ok, contents can be null if the file is too large or
// there was an access exception.
logger.warn(
`An error was thrown when trying to update ${path}. If you believe the migration should have updated it, be sure to review the file and open an issue.`
);
}
tree.write(
path,
contents.replace(new RegExp(oldPackageName, 'g'), newPackageName)
);
});
}
+11 -1
View File
@@ -7,7 +7,7 @@ import {
} from '@nx/devkit';
import { findNodes } from '@nx/js';
import { getModifiers } from '@typescript-eslint/type-utils';
import { existsSync, readFileSync } from 'fs';
import { existsSync, lstatSync, readdirSync, readFileSync } from 'fs';
import { dirname } from 'path';
import ts = require('typescript');
@@ -81,6 +81,16 @@ function hasMemberExport(exportedMember, filePath) {
}
export function getRelativeImportPath(exportedMember, filePath, basePath) {
if (lstatSync(filePath).isDirectory()) {
const file = readdirSync(filePath).find((file) =>
/^index\.[jt]sx?$/.exec(file)
);
if (file) {
filePath = joinPathFragments(filePath, file);
} else {
return;
}
}
const fileContent = readFileSync(filePath, 'utf8');
// use the TypeScript AST to find the path to the file where exportedMember is defined
+18 -1
View File
@@ -5,7 +5,6 @@
import * as path from 'path';
import type { NextConfig } from 'next';
import type { NextConfigFn } from '../src/utils/config';
import { forNextVersion } from '../src/utils/config';
import type { NextBuildBuilderOptions } from '../src/utils/types';
import type { DependentBuildableProjectNode } from '@nx/js/src/utils/buildable-libs-utils';
import type { ProjectGraph, ProjectGraphProjectNode, Target } from '@nx/devkit';
@@ -156,6 +155,15 @@ function withNx(
_nextConfig = {} as WithNxOptions,
context: WithNxContext = getWithNxContext()
): NextConfigFn {
// If this is not set user will see compile errors in Next.js 13.4.
// See: https://github.com/nrwl/nx/issues/16692, https://github.com/vercel/next.js/issues/49169
// TODO(jack): Remove this once Nx is refactored to invoke CLI directly.
forNextVersion('>=13.4.0', () => {
process.env['__NEXT_PRIVATE_PREBUNDLED_REACT'] =
// Not in Next 13.3 or earlier, so need to access config via string
_nextConfig.experimental['serverActions'] ? 'experimental' : 'next';
});
return async (phase: string) => {
const { PHASE_PRODUCTION_SERVER } = await import('next/constants');
if (phase === PHASE_PRODUCTION_SERVER) {
@@ -456,6 +464,15 @@ export function getAliasForProject(
return null;
}
// Runs a function if the Next.js version satisfies the range.
export function forNextVersion(range: string, fn: () => void) {
const semver = require('semver');
const nextJsVersion = require('next/package.json').version;
if (semver.satisfies(nextJsVersion, range)) {
fn();
}
}
// Support for older generated code: `const withNx = require('@nx/next/plugins/with-nx');`
module.exports = withNx;
// Support for newer generated code: `const { withNx } = require(...);`
-9
View File
@@ -107,12 +107,3 @@ function isTsRule(r: RuleSetRule): boolean {
return r.test.test('a.ts');
}
// Runs a function if the Next.js version satisfies the range.
export function forNextVersion(range: string, fn: () => void) {
const semver = require('semver');
const nextJsVersion = require('next/package.json').version;
if (semver.satisfies(nextJsVersion, range)) {
fn();
}
}
@@ -1,6 +1,11 @@
{
"name": "@nx/nx-darwin-arm64",
"version": "0.0.0",
"repository": {
"type": "git",
"url": "https://github.com/nrwl/nx.git",
"directory": "packages/nx/native-packages/darwin-arm64"
},
"os": [
"darwin"
],
@@ -1,6 +1,11 @@
{
"name": "@nx/nx-darwin-x64",
"version": "0.0.0",
"repository": {
"type": "git",
"url": "https://github.com/nrwl/nx.git",
"directory": "packages/nx/native-packages/darwin-x64"
},
"os": [
"darwin"
],
@@ -1,6 +1,11 @@
{
"name": "@nx/nx-linux-arm-gnueabihf",
"version": "0.0.0",
"repository": {
"type": "git",
"url": "https://github.com/nrwl/nx.git",
"directory": "packages/nx/native-packages/linux-arm-gnueabihf"
},
"os": [
"linux"
],
@@ -1,6 +1,11 @@
{
"name": "@nx/nx-linux-arm64-gnu",
"version": "0.0.0",
"repository": {
"type": "git",
"url": "https://github.com/nrwl/nx.git",
"directory": "packages/nx/native-packages/linux-arm64-gnu"
},
"os": [
"linux"
],
@@ -1,6 +1,11 @@
{
"name": "@nx/nx-linux-arm64-musl",
"version": "0.0.0",
"repository": {
"type": "git",
"url": "https://github.com/nrwl/nx.git",
"directory": "packages/nx/native-packages/linux-arm64-musl"
},
"os": [
"linux"
],
@@ -1,6 +1,11 @@
{
"name": "@nx/nx-linux-x64-gnu",
"version": "0.0.0",
"repository": {
"type": "git",
"url": "https://github.com/nrwl/nx.git",
"directory": "packages/nx/native-packages/linux-x64-gnu"
},
"os": [
"linux"
],
@@ -1,6 +1,11 @@
{
"name": "@nx/nx-linux-x64-musl",
"version": "0.0.0",
"repository": {
"type": "git",
"url": "https://github.com/nrwl/nx.git",
"directory": "packages/nx/native-packages/linux-x64-musl"
},
"os": [
"linux"
],
@@ -1,6 +1,11 @@
{
"name": "@nx/nx-win32-arm64-msvc",
"version": "0.0.0",
"repository": {
"type": "git",
"url": "https://github.com/nrwl/nx.git",
"directory": "packages/nx/native-packages/win32-arm64-msvc"
},
"os": [
"win32"
],
@@ -1,6 +1,11 @@
{
"name": "@nx/nx-win32-x64-msvc",
"version": "0.0.0",
"repository": {
"type": "git",
"url": "https://github.com/nrwl/nx.git",
"directory": "packages/nx/native-packages/win32-x64-msvc"
},
"os": [
"win32"
],
+1 -1
View File
@@ -54,7 +54,7 @@ export async function listHandler(args: ListArgs): Promise<void> {
bodyLines: [
'Looking for a technology / framework not listed above?',
'There are many excellent plugins matintained by the Nx community.',
'Search for the one you need here: https://nx.dev/community.',
'Search for the one you need here: https://nx.dev/plugins/registry.',
],
});
+1 -1
View File
@@ -1558,7 +1558,7 @@ async function runNxMigration(
name
);
const fn = require(implPath)[fnSymbol];
const host = new FsTree(root, false);
const host = new FsTree(root, process.env.NX_VERBOSE_LOGGING === 'true');
await fn(host, {});
host.lock();
const changes = host.listChanges();
@@ -218,10 +218,12 @@ function findCreatedProjectFiles(tree: Tree) {
if (fileName === 'project.json') {
createdProjectFiles.push(change.path);
} else if (fileName === 'package.json') {
const contents: PackageJson = JSON.parse(change.content.toString());
if (contents.nx) {
createdProjectFiles.push(change.path);
}
try {
const contents: PackageJson = JSON.parse(change.content.toString());
if (contents.nx) {
createdProjectFiles.push(change.path);
}
} catch {}
}
}
}
@@ -93,8 +93,8 @@ export function createPackageJson(
}
const getVersion = (
packageName,
version,
packageName: string,
version: string,
section: 'devDependencies' | 'dependencies'
) => {
return (
@@ -0,0 +1,43 @@
jest.mock('fs');
import * as fs from 'fs';
import * as configModule from 'nx/src/config/configuration';
import { detectPackageManager } from 'nx/src/utils/package-manager';
describe('package-manager', () => {
it('should detect package manager in nxJson', () => {
jest.spyOn(configModule, 'readNxJson').mockReturnValueOnce({
cli: {
packageManager: 'pnpm',
},
});
const packageManager = detectPackageManager();
expect(packageManager).toEqual('pnpm');
expect(fs.existsSync).not.toHaveBeenCalled();
});
it('should detect yarn package manager from yarn.lock', () => {
jest.spyOn(configModule, 'readNxJson').mockReturnValueOnce({});
(fs.existsSync as jest.Mock).mockReturnValueOnce(true);
const packageManager = detectPackageManager();
expect(packageManager).toEqual('yarn');
expect(fs.existsSync).toHaveBeenNthCalledWith(1, 'yarn.lock');
});
it('should detect pnpm package manager from pnpm-lock.yaml', () => {
jest.spyOn(configModule, 'readNxJson').mockReturnValueOnce({});
(fs.existsSync as jest.Mock).mockImplementation((path) => {
return path === 'pnpm-lock.yaml';
});
const packageManager = detectPackageManager();
expect(packageManager).toEqual('pnpm');
expect(fs.existsSync).toHaveBeenCalledTimes(3);
});
it('should use npm package manager as default', () => {
jest.spyOn(configModule, 'readNxJson').mockReturnValueOnce({});
(fs.existsSync as jest.Mock).mockReturnValue(false);
const packageManager = detectPackageManager();
expect(packageManager).toEqual('npm');
expect(fs.existsSync).toHaveBeenCalledTimes(5);
});
});
+10 -5
View File
@@ -8,6 +8,7 @@ import { writeJsonFile } from './fileutils';
import { readModulePackageJson } from './package-json';
import { gte, lt } from 'semver';
import { workspaceRoot } from './workspace-root';
import { readNxJson } from '../config/configuration';
const execAsync = promisify(exec);
@@ -28,11 +29,15 @@ export interface PackageManagerCommands {
* Detects which package manager is used in the workspace based on the lock file.
*/
export function detectPackageManager(dir: string = ''): PackageManager {
return existsSync(join(dir, 'yarn.lock'))
? 'yarn'
: existsSync(join(dir, 'pnpm-lock.yaml'))
? 'pnpm'
: 'npm';
const nxJson = readNxJson();
return (
nxJson.cli?.packageManager ??
(existsSync(join(dir, 'yarn.lock'))
? 'yarn'
: existsSync(join(dir, 'pnpm-lock.yaml'))
? 'pnpm'
: 'npm')
);
}
/**
+21
View File
@@ -982,6 +982,27 @@ describe('params', () => {
).not.toThrow();
});
it('should handle const value', () => {
const schema = {
properties: {
a: {
const: 3,
},
},
};
expect(() => validateOptsAgainstSchema({ a: 3 }, schema)).not.toThrow();
expect(() =>
validateOptsAgainstSchema({ a: true }, schema)
).toThrowErrorMatchingInlineSnapshot(
`"Property 'a' does not match the schema. 'true' should be '3'."`
);
expect(() =>
validateOptsAgainstSchema({ a: 123 }, schema)
).toThrowErrorMatchingInlineSnapshot(
`"Property 'a' does not match the schema. '123' should be '3'."`
);
});
describe('array', () => {
it('should handle validating patterns', () => {
const schema = {
+7
View File
@@ -33,6 +33,7 @@ type PropertyDescription = {
| { $source: 'projectName' }
| { $source: 'unparsed' };
additionalProperties?: boolean;
const?: any;
'x-prompt'?:
| string
| { message: string; type: string; items?: any[]; multiselect?: boolean };
@@ -359,6 +360,12 @@ function validateProperty(
const isPrimitive = typeof value !== 'object';
if (isPrimitive) {
if (schema.const !== undefined && value !== schema.const) {
throw new SchemaError(
`Property '${propName}' does not match the schema. '${value}' should be '${schema.const}'.`
);
}
if (Array.isArray(schema.type)) {
const passes = schema.type.some((t) => {
try {
@@ -44,6 +44,7 @@ export function normalizeRollupExecutorOptions(
project,
projectRoot,
outputPath,
skipTypeCheck: options.skipTypeCheck || false,
};
}
@@ -214,7 +214,7 @@ export function createRollupOptions(
json(),
(useTsc || useBabel) &&
require('rollup-plugin-typescript2')({
check: true,
check: !options.skipTypeCheck,
tsconfig: options.tsConfig,
tsconfigOverride: {
compilerOptions: createTsCompilerOptions(
+1
View File
@@ -31,4 +31,5 @@ export interface RollupExecutorOptions {
compiler?: 'babel' | 'tsc' | 'swc';
javascriptEnabled?: boolean;
generateExportsField?: boolean;
skipTypeCheck?: boolean;
}
@@ -146,6 +146,11 @@
"type": "boolean",
"description": "Generate package.json with 'exports' field. This field defines entry points in the package and is used by Node and the TypeScript compiler.",
"default": false
},
"skipTypeCheck": {
"type": "boolean",
"description": "Whether to skip TypeScript type checking.",
"default": false
}
},
"required": ["tsConfig", "main", "outputPath"],
+108
View File
@@ -62,6 +62,114 @@
}
},
"packageJsonUpdates": {
"16.1.3": {
"version": "16.1.3-beta.0",
"requires": {
"@storybook/core-server": ">=7.0.0 <7.0.9"
},
"packages": {
"@storybook/core-server": {
"version": "^7.0.9",
"alwaysAddToPackageJson": false
},
"@storybook/angular": {
"version": "^7.0.9",
"alwaysAddToPackageJson": false
},
"@storybook/react": {
"version": "^7.0.9",
"alwaysAddToPackageJson": false
},
"@storybook/web-components-vite": {
"version": "^7.0.9",
"alwaysAddToPackageJson": false
},
"@storybook/web-components-webpack5": {
"version": "^7.0.9",
"alwaysAddToPackageJson": false
},
"@storybook/builder-vite": {
"version": "^7.0.9",
"alwaysAddToPackageJson": false
},
"@storybook/builder-webpack5": {
"version": "^7.0.9",
"alwaysAddToPackageJson": false
},
"@storybook/addon-a11y": {
"version": "^7.0.9",
"alwaysAddToPackageJson": false
},
"@storybook/addon-actions": {
"version": "^7.0.9",
"alwaysAddToPackageJson": false
},
"@storybook/addon-backgrounds": {
"version": "^7.0.9",
"alwaysAddToPackageJson": false
},
"@storybook/addon-controls": {
"version": "^7.0.9",
"alwaysAddToPackageJson": false
},
"@storybook/addon-docs": {
"version": "^7.0.9",
"alwaysAddToPackageJson": false
},
"@storybook/addon-essentials": {
"version": "^7.0.9",
"alwaysAddToPackageJson": false
},
"@storybook/addon-mdx-gfm": {
"version": "^7.0.9",
"alwaysAddToPackageJson": false
},
"@storybook/addon-highlight": {
"version": "^7.0.9",
"alwaysAddToPackageJson": false
},
"@storybook/addon-interactions": {
"version": "^7.0.9",
"alwaysAddToPackageJson": false
},
"@storybook/addon-jest": {
"version": "^7.0.9",
"alwaysAddToPackageJson": false
},
"@storybook/addon-links": {
"version": "^7.0.9",
"alwaysAddToPackageJson": false
},
"@storybook/addon-measure": {
"version": "^7.0.9",
"alwaysAddToPackageJson": false
},
"@storybook/addon-outline": {
"version": "^7.0.9",
"alwaysAddToPackageJson": false
},
"@storybook/addon-storyshots": {
"version": "^7.0.9",
"alwaysAddToPackageJson": false
},
"@storybook/addon-storyshots-puppeteer": {
"version": "^7.0.9",
"alwaysAddToPackageJson": false
},
"@storybook/addon-storysource": {
"version": "^7.0.9",
"alwaysAddToPackageJson": false
},
"@storybook/addon-toolbars": {
"version": "^7.0.9",
"alwaysAddToPackageJson": false
},
"@storybook/addon-viewport": {
"version": "^7.0.9",
"alwaysAddToPackageJson": false
}
}
},
"16.1.0": {
"version": "16.1.0-beta.0",
"requires": {
@@ -10,10 +10,10 @@ exports[`@nx/storybook:init dependencies for package.json should add angular rel
"devDependencies": {
"@angular/forms": "*",
"@nx/js": "0.0.1",
"@nx/storybook": "^7.0.8",
"@storybook/addon-essentials": "7.0.8",
"@storybook/angular": "7.0.8",
"@storybook/core-server": "7.0.8",
"@nx/storybook": "^7.0.9",
"@storybook/addon-essentials": "7.0.9",
"@storybook/angular": "7.0.9",
"@storybook/core-server": "7.0.9",
"existing": "1.0.0",
"prettier": "^2.6.2",
"typescript": "~5.0.2",
+1 -1
View File
@@ -5,5 +5,5 @@ export const storybookTestRunnerVersion = '^0.7.2';
export const litVersion = '^2.6.1';
export const tsNodeVersion = '10.9.1';
export const storybookVersion = '^7.0.8';
export const storybookVersion = '^7.0.9';
export const reactVersion = '^18.2.0';
+884 -1382
View File
File diff suppressed because it is too large Load Diff
+49
View File
@@ -0,0 +1,49 @@
import * as fg from 'fast-glob';
import * as path from 'path';
import * as fs from 'fs';
import { output } from '@nx/devkit';
async function main() {
const codeowners = fs.readFileSync(
path.join(__dirname, '../CODEOWNERS'),
'utf-8'
);
const codeownersLines = codeowners
.split('\n')
.filter((line) => line.trim().length > 0 && !line.startsWith('#'));
const errors: string[] = [];
for (const line of codeownersLines) {
// This is perhaps a bit naive, but it should
// work for all paths and patterns that do not
// contain spaces.
const specifiedPattern = line.split(' ')[0];
let foundMatchingFiles = false;
const patternsToCheck = specifiedPattern.startsWith('/')
? [`.${specifiedPattern}`]
: [`./${specifiedPattern}`, `**/${specifiedPattern}`];
for (const pattern of patternsToCheck) {
foundMatchingFiles ||=
fg.sync(pattern, {
ignore: ['node_modules', 'dist', 'build', '.git'],
cwd: path.join(__dirname, '..'),
onlyFiles: false,
}).length > 0;
}
if (!foundMatchingFiles) {
errors.push(specifiedPattern);
}
}
if (errors.length > 0) {
output.error({
title: `The following patterns in CODEOWNERS do not match any files:`,
bodyLines: errors.map((e) => `- ${e}`),
});
process.exit(1);
}
}
main();
+2 -2
View File
@@ -7,8 +7,8 @@ import { join } from 'path';
import { parse } from 'semver';
import * as version from '@lerna/version';
import * as publish from '@lerna/publish';
const version = require('lerna/commands/version');
const publish = require('lerna/commands/publish');
const lernaJsonPath = join(__dirname, '../lerna.json');
const originalLernaJson = readFileSync(lernaJsonPath);