Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c2fa618647 | |||
| 19872516c0 | |||
| c15a25eecc | |||
| 0f762cde49 | |||
| 46ff3ade22 | |||
| 46ad6ad31e | |||
| 075ec01309 | |||
| f3ae59420a | |||
| ae4fea6ef3 | |||
| 75c6722b4b | |||
| 0078e3f6e0 | |||
| 92737a69dd | |||
| 2ac7746e15 | |||
| d37379fd2f | |||
| 2b045e055b | |||
| 5811e85271 | |||
| 8886f0f9a3 | |||
| 7365438588 | |||
| e49671f2ad | |||
| a5b9bbae8d | |||
| 6da0c2bdcb | |||
| ee4174c9a7 | |||
| 0528b03a26 | |||
| a3b032c368 | |||
| d2bf124d4f | |||
| 168c6595cc |
@@ -85,9 +85,7 @@ Package manager to use
|
||||
|
||||
Type: string
|
||||
|
||||
Choices: [apps, empty, core, npm, ts, web-components, angular, angular-nest, react, react-express, react-native, next, nest, express]
|
||||
|
||||
Customizes the initial content of your workspace. To build your own see https://nx.dev/nx-plugin/overview#preset
|
||||
Customizes the initial content of your workspace. Default presets include: ["apps", "empty", "core", "npm", "ts", "web-components", "angular", "angular-nest", "react", "react-express", "react-native", "next", "nest", "express"]. To build your own see https://nx.dev/nx-plugin/overview#preset
|
||||
|
||||
### style
|
||||
|
||||
|
||||
@@ -213,7 +213,8 @@
|
||||
},
|
||||
"reuse": {
|
||||
"type": "boolean",
|
||||
"description": "Reuse existing installed app (do not delete + reinstall) for a faster run."
|
||||
"description": "Reuse existing installed app (do not delete + reinstall) for a faster run.",
|
||||
"default": true
|
||||
},
|
||||
"cleanup": {
|
||||
"type": "boolean",
|
||||
|
||||
@@ -128,6 +128,24 @@
|
||||
"hidden": false,
|
||||
"path": "/packages/js/src/generators/library/schema.json"
|
||||
},
|
||||
{
|
||||
"name": "init",
|
||||
"factory": "./src/generators/init/init#initGenerator",
|
||||
"schema": {
|
||||
"$schema": "http://json-schema.org/schema",
|
||||
"$id": "NxTypescriptInit",
|
||||
"cli": "nx",
|
||||
"title": "Init nrwl/js",
|
||||
"description": "Init generator placeholder for nrwl/js",
|
||||
"presets": []
|
||||
},
|
||||
"aliases": ["lib"],
|
||||
"x-type": "init",
|
||||
"description": "Init placeholder.",
|
||||
"implementation": "/packages/js/src/generators/init/init#initGenerator.ts",
|
||||
"hidden": false,
|
||||
"path": "/packages/js/src/generators/init/schema.json"
|
||||
},
|
||||
{
|
||||
"name": "convert-to-swc",
|
||||
"factory": "./src/generators/convert-to-swc/convert-to-swc#convertToSwcGenerator",
|
||||
|
||||
+1
-1
@@ -109,7 +109,7 @@
|
||||
"path": "generated/packages/js.json",
|
||||
"schemas": {
|
||||
"executors": ["tsc", "swc"],
|
||||
"generators": ["library", "convert-to-swc"]
|
||||
"generators": ["library", "init", "convert-to-swc"]
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -87,29 +87,10 @@ describe('React Applications', () => {
|
||||
const appName = uniq('app');
|
||||
const libName = uniq('lib');
|
||||
|
||||
runCLI(`generate @nrwl/react:app ${appName} --no-interactive`);
|
||||
runCLI(`generate @nrwl/react:lib ${libName} --no-interactive`);
|
||||
runCLI(`generate @nrwl/react:app ${appName} --no-interactive --js`);
|
||||
runCLI(`generate @nrwl/react:lib ${libName} --no-interactive --js`);
|
||||
|
||||
renameFile(`apps/${appName}/src/main.tsx`, `apps/${appName}/src/main.jsx`);
|
||||
renameFile(
|
||||
`apps/${appName}/src/app/app.tsx`,
|
||||
`apps/${appName}/src/app/app.jsx`
|
||||
);
|
||||
renameFile(
|
||||
`apps/${appName}/src/app/app.spec.tsx`,
|
||||
`apps/${appName}/src/app/app.spec.jsx`
|
||||
);
|
||||
renameFile(
|
||||
`apps/${appName}/src/polyfills.ts`,
|
||||
`apps/${appName}/src/polyfills.js`
|
||||
);
|
||||
updateProjectConfig(appName, (config) => {
|
||||
config.targets.build.options.main = `apps/${appName}/src/main.jsx`;
|
||||
config.targets.build.options.polyfills = `apps/${appName}/src/polyfills.js`;
|
||||
return config;
|
||||
});
|
||||
|
||||
const mainPath = `apps/${appName}/src/main.jsx`;
|
||||
const mainPath = `apps/${appName}/src/main.js`;
|
||||
updateFile(
|
||||
mainPath,
|
||||
`import '@${proj}/${libName}';\n${readFile(mainPath)}`
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nrwl/nx-source",
|
||||
"version": "13.10.0",
|
||||
"version": "13.10.5",
|
||||
"description": "Smart, Fast and Extensible Build System",
|
||||
"homepage": "https://nx.dev",
|
||||
"private": true,
|
||||
@@ -306,4 +306,4 @@
|
||||
"immer": "~9.0.6",
|
||||
"minimist": "^1.2.6"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
import type { Tree } from '@nrwl/devkit';
|
||||
import type { Schema } from '../schema';
|
||||
|
||||
import {
|
||||
readProjectConfiguration,
|
||||
updateProjectConfiguration,
|
||||
} from '@nrwl/devkit';
|
||||
|
||||
export function addImplicitDeps(host: Tree, options: Schema) {
|
||||
if (
|
||||
options.mfeType === 'host' &&
|
||||
Array.isArray(options.remotes) &&
|
||||
options.remotes.length > 0
|
||||
) {
|
||||
const appConfig = readProjectConfiguration(host, options.appName);
|
||||
appConfig.implicitDependencies = Array.isArray(
|
||||
appConfig.implicitDependencies
|
||||
)
|
||||
? [...appConfig.implicitDependencies, ...options.remotes]
|
||||
: [...options.remotes];
|
||||
updateProjectConfiguration(host, options.appName, appConfig);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
export * from './add-cypress-workaround';
|
||||
export * from './add-entry-module';
|
||||
export * from './add-implicit-deps';
|
||||
export * from './add-remote-to-host';
|
||||
export * from './change-build-target';
|
||||
export * from './fix-bootstrap';
|
||||
|
||||
@@ -135,22 +135,6 @@ describe('Init MFE', () => {
|
||||
|
||||
expect(mfeConfigContents).toContain(`'remote1'`);
|
||||
});
|
||||
it('should update the implicit dependencies of the host when --remotes flag supplied', async () => {
|
||||
// ACT
|
||||
await setupMfe(tree, {
|
||||
appName: 'app1',
|
||||
mfeType: 'host',
|
||||
remotes: ['remote1'],
|
||||
});
|
||||
|
||||
// ASSERT
|
||||
const projectConfig: ProjectConfiguration = readProjectConfiguration(
|
||||
tree,
|
||||
'app1'
|
||||
);
|
||||
|
||||
expect(projectConfig.implicitDependencies).toContain('remote1');
|
||||
});
|
||||
|
||||
it('should add a remote application and add it to a specified host applications webpack config when no other remote has been added to it', async () => {
|
||||
// ARRANGE
|
||||
|
||||
@@ -6,7 +6,6 @@ import { readProjectConfiguration, formatFiles } from '@nrwl/devkit';
|
||||
import {
|
||||
addCypressOnErrorWorkaround,
|
||||
addEntryModule,
|
||||
addImplicitDeps,
|
||||
addRemoteToHost,
|
||||
changeBuildTarget,
|
||||
fixBootstrap,
|
||||
@@ -30,7 +29,6 @@ export async function setupMfe(tree: Tree, options: Schema) {
|
||||
generateWebpackConfig(tree, options, projectConfig.root, remotesWithPorts);
|
||||
|
||||
addEntryModule(tree, options, projectConfig.root);
|
||||
addImplicitDeps(tree, options);
|
||||
changeBuildTarget(tree, options);
|
||||
updateTsConfigTarget(tree, options);
|
||||
setupServeTarget(tree, options);
|
||||
|
||||
@@ -41,11 +41,15 @@ export function getComponentProps(
|
||||
const props = getInputPropertyDeclarations(tree, componentPath).map(
|
||||
(node) => {
|
||||
const decoratorContent = findNodes(
|
||||
findNodes(node, SyntaxKind.Decorator)[0],
|
||||
findNodes(node, SyntaxKind.Decorator).find((n) =>
|
||||
n.getText().startsWith('@Input')
|
||||
),
|
||||
SyntaxKind.StringLiteral
|
||||
);
|
||||
const name = decoratorContent.length
|
||||
? decoratorContent[0].getText().slice(1, -1)
|
||||
? !decoratorContent[0].getText().includes('.')
|
||||
? decoratorContent[0].getText().slice(1, -1)
|
||||
: node.name.getText()
|
||||
: node.name.getText();
|
||||
|
||||
const type = getKnobType(node);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { existsSync, readFileSync } from 'fs';
|
||||
import { NormalModuleReplacementPlugin } from 'webpack';
|
||||
import { normalizePath, joinPathFragments, workspaceRoot } from '@nrwl/devkit';
|
||||
import { dirname } from 'path';
|
||||
import { joinPathFragments, workspaceRoot } from '@nrwl/devkit';
|
||||
import { dirname, join, normalize } from 'path';
|
||||
import { ParsedCommandLine } from 'typescript';
|
||||
import {
|
||||
getRootTsConfigPath,
|
||||
@@ -40,9 +40,7 @@ export function shareWorkspaceLibraries(
|
||||
const pathMappings: { name: string; path: string }[] = [];
|
||||
for (const [key, paths] of Object.entries(tsconfigPathAliases)) {
|
||||
if (libraries && libraries.includes(key)) {
|
||||
const pathToLib = normalizePath(
|
||||
joinPathFragments(workspaceRoot, paths[0])
|
||||
);
|
||||
const pathToLib = normalize(join(workspaceRoot, paths[0]));
|
||||
pathMappings.push({
|
||||
name: key,
|
||||
path: pathToLib,
|
||||
@@ -71,10 +69,10 @@ export function shareWorkspaceLibraries(
|
||||
}
|
||||
|
||||
const from = req.context;
|
||||
const to = normalizePath(joinPathFragments(req.context, req.request));
|
||||
const to = normalize(join(req.context, req.request));
|
||||
|
||||
for (const library of pathMappings) {
|
||||
const libFolder = normalizePath(dirname(library.path));
|
||||
const libFolder = normalize(dirname(library.path));
|
||||
if (!from.startsWith(libFolder) && to.startsWith(libFolder)) {
|
||||
req.request = library.name;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ type Arguments = {
|
||||
style: string;
|
||||
nxCloud: boolean;
|
||||
allPrompts: boolean;
|
||||
packageManager: string;
|
||||
packageManager: PackageManager;
|
||||
defaultBase: string;
|
||||
};
|
||||
|
||||
@@ -132,8 +132,13 @@ export const commandsObject: yargs.Argv<Arguments> = yargs
|
||||
type: 'string',
|
||||
})
|
||||
.option('preset', {
|
||||
describe: chalk.dim`Customizes the initial content of your workspace. To build your own see https://nx.dev/nx-plugin/overview#preset`,
|
||||
choices: Object.values(Preset),
|
||||
describe: chalk.dim`Customizes the initial content of your workspace. Default presets include: [${Object.values(
|
||||
Preset
|
||||
)
|
||||
.map((p) => `"${p}"`)
|
||||
.join(
|
||||
', '
|
||||
)}]. To build your own see https://nx.dev/nx-plugin/overview#preset`,
|
||||
type: 'string',
|
||||
})
|
||||
.option('appName', {
|
||||
@@ -600,11 +605,13 @@ async function determineStyle(
|
||||
return Promise.resolve(parsedArgs.style);
|
||||
}
|
||||
|
||||
async function createSandbox(packageManager: string) {
|
||||
async function createSandbox(packageManager: PackageManager) {
|
||||
const installSpinner = ora(
|
||||
`Installing dependencies with ${packageManager}`
|
||||
).start();
|
||||
|
||||
const { install } = getPackageManagerCommand(packageManager);
|
||||
|
||||
const tmpDir = dirSync().name;
|
||||
try {
|
||||
writeFileSync(
|
||||
@@ -620,7 +627,7 @@ async function createSandbox(packageManager: string) {
|
||||
})
|
||||
);
|
||||
|
||||
await execAndWait(`${packageManager} install --silent`, tmpDir);
|
||||
await execAndWait(`${install} --silent`, tmpDir);
|
||||
|
||||
installSpinner.succeed();
|
||||
} catch (e) {
|
||||
|
||||
@@ -413,6 +413,23 @@ describe('schematic:cypress-project', () => {
|
||||
expect(projectConfig.tags).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
it('should not throw an error when --project does not have targets', async () => {
|
||||
const projectConf = readProjectConfiguration(tree, 'my-app');
|
||||
delete projectConf.targets;
|
||||
|
||||
updateProjectConfiguration(tree, 'my-app', projectConf);
|
||||
await cypressProjectGenerator(tree, {
|
||||
name: 'my-app-e2e',
|
||||
project: 'my-app',
|
||||
linter: Linter.EsLint,
|
||||
});
|
||||
|
||||
const projectConfig = readProjectConfiguration(tree, 'my-app-e2e');
|
||||
expect(projectConfig.targets['e2e'].options.devServerTarget).toEqual(
|
||||
'my-app:serve'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('--linter', () => {
|
||||
|
||||
@@ -13,6 +13,8 @@ import {
|
||||
Tree,
|
||||
updateJson,
|
||||
ProjectConfiguration,
|
||||
stripIndents,
|
||||
logger,
|
||||
} from '@nrwl/devkit';
|
||||
import { Linter, lintProjectGenerator } from '@nrwl/linter';
|
||||
import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial';
|
||||
@@ -82,8 +84,15 @@ function addProject(tree: Tree, options: CypressProjectSchema) {
|
||||
};
|
||||
} else if (options.project) {
|
||||
const project = readProjectConfiguration(tree, options.project);
|
||||
|
||||
if (!project.targets) {
|
||||
logger.warn(stripIndents`
|
||||
NOTE: Project, "${options.project}", does not have any targets defined and a baseUrl was not provided. Nx will use
|
||||
"${options.project}:serve" as the devServerTarget. But you may need to define this target within the project, "${options.project}".
|
||||
`);
|
||||
}
|
||||
const devServerTarget =
|
||||
project.targets.serve && project.targets.serve.defaultConfiguration
|
||||
project.targets?.serve && project.targets?.serve?.defaultConfiguration
|
||||
? `${options.project}:serve:${project.targets.serve.defaultConfiguration}`
|
||||
: `${options.project}:serve`;
|
||||
e2eProjectConfig = {
|
||||
|
||||
@@ -1,20 +1,15 @@
|
||||
import {
|
||||
addDependenciesToPackageJson,
|
||||
convertNxGenerator,
|
||||
removeDependenciesFromPackageJson,
|
||||
Tree,
|
||||
updateJson,
|
||||
} from '@nrwl/devkit';
|
||||
|
||||
import { cypressVersion, nxVersion } from '../../utils/versions';
|
||||
import { Schema } from './schema';
|
||||
|
||||
function updateDependencies(host: Tree) {
|
||||
updateJson(host, 'package.json', (json) => {
|
||||
json.dependencies = json.dependencies || {};
|
||||
delete json.dependencies['@nrwl/cypress'];
|
||||
removeDependenciesFromPackageJson(host, ['@nrwl/cypress'], []);
|
||||
|
||||
return json;
|
||||
});
|
||||
return addDependenciesToPackageJson(
|
||||
host,
|
||||
{},
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ export interface DetoxTestOptions {
|
||||
recordTimeline?: 'all' | 'none';
|
||||
captureViewHierarchy?: 'enabled' | 'disabled';
|
||||
retries?: number;
|
||||
resuse?: boolean;
|
||||
reuse: boolean; // default is true
|
||||
cleanup?: boolean;
|
||||
workers?: number;
|
||||
jestReportSpecs?: boolean;
|
||||
|
||||
@@ -92,7 +92,8 @@
|
||||
},
|
||||
"reuse": {
|
||||
"type": "boolean",
|
||||
"description": "Reuse existing installed app (do not delete + reinstall) for a faster run."
|
||||
"description": "Reuse existing installed app (do not delete + reinstall) for a faster run.",
|
||||
"default": true
|
||||
},
|
||||
"cleanup": {
|
||||
"type": "boolean",
|
||||
|
||||
@@ -27,11 +27,13 @@
|
||||
},
|
||||
"homepage": "https://nx.dev",
|
||||
"dependencies": {
|
||||
"nx": "*",
|
||||
"ejs": "^3.1.5",
|
||||
"ignore": "^5.0.4",
|
||||
"rxjs": "^6.5.4",
|
||||
"semver": "7.3.4",
|
||||
"tslib": "^2.3.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"nx": ">= 13.10 <= 15"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,6 @@ import {
|
||||
import type { PackageManager } from 'nx/src/utils/package-manager';
|
||||
import { joinPathFragments } from 'nx/src/utils/path';
|
||||
|
||||
let storedPackageJsonValue: string;
|
||||
|
||||
/**
|
||||
* Runs `npm install` or `yarn install`. It will skip running the install if
|
||||
* `package.json` hasn't changed at all or it hasn't changed since the last invocation.
|
||||
@@ -23,24 +21,27 @@ export function installPackagesTask(
|
||||
cwd: string = '',
|
||||
packageManager: PackageManager = detectPackageManager(cwd)
|
||||
): void {
|
||||
if (
|
||||
!tree
|
||||
.listChanges()
|
||||
.find((f) => f.path === joinPathFragments(cwd, 'package.json')) &&
|
||||
!alwaysRun
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const packageJsonValue = tree.read(
|
||||
joinPathFragments(cwd, 'package.json'),
|
||||
'utf-8'
|
||||
);
|
||||
if (
|
||||
tree
|
||||
.listChanges()
|
||||
.find((f) => f.path === joinPathFragments(cwd, 'package.json')) ||
|
||||
alwaysRun
|
||||
) {
|
||||
// Don't install again if install was already executed with package.json
|
||||
if (storedPackageJsonValue != packageJsonValue || alwaysRun) {
|
||||
storedPackageJsonValue = packageJsonValue;
|
||||
const pmc = getPackageManagerCommand(packageManager);
|
||||
execSync(pmc.install, {
|
||||
cwd: join(tree.root, cwd),
|
||||
stdio: [0, 1, 2],
|
||||
});
|
||||
}
|
||||
let storedPackageJsonValue: string = global['__packageJsonInstallCache__'];
|
||||
// Don't install again if install was already executed with package.json
|
||||
if (storedPackageJsonValue != packageJsonValue || alwaysRun) {
|
||||
global['__packageJsonInstallCache__'] = packageJsonValue;
|
||||
const pmc = getPackageManagerCommand(packageManager);
|
||||
execSync(pmc.install, {
|
||||
cwd: join(tree.root, cwd),
|
||||
stdio: [0, 1, 2],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import {
|
||||
addDependenciesToPackageJson,
|
||||
updateJson,
|
||||
formatFiles,
|
||||
convertNxGenerator,
|
||||
formatFiles,
|
||||
removeDependenciesFromPackageJson,
|
||||
Tree,
|
||||
} from '@nrwl/devkit';
|
||||
import { setDefaultCollection } from '@nrwl/workspace/src/utilities/set-default-collection';
|
||||
import { initGenerator as nodeInitGenerator } from '@nrwl/node';
|
||||
import { setDefaultCollection } from '@nrwl/workspace/src/utilities/set-default-collection';
|
||||
import {
|
||||
expressTypingsVersion,
|
||||
expressVersion,
|
||||
@@ -15,10 +15,8 @@ import {
|
||||
import type { Schema } from './schema';
|
||||
|
||||
function updateDependencies(tree: Tree) {
|
||||
updateJson(tree, 'package.json', (json) => {
|
||||
delete json.dependencies['@nrwl/express'];
|
||||
return json;
|
||||
});
|
||||
removeDependenciesFromPackageJson(tree, ['@nrwl/express'], []);
|
||||
|
||||
return addDependenciesToPackageJson(
|
||||
tree,
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@ import {
|
||||
addDependenciesToPackageJson,
|
||||
convertNxGenerator,
|
||||
GeneratorCallback,
|
||||
removeDependenciesFromPackageJson,
|
||||
stripIndents,
|
||||
Tree,
|
||||
updateJson,
|
||||
@@ -23,16 +24,6 @@ const schemaDefaults = {
|
||||
compiler: 'tsc',
|
||||
} as const;
|
||||
|
||||
function removeNrwlJestFromDeps(host: Tree) {
|
||||
updateJson(host, 'package.json', (json) => {
|
||||
// check whether updating the package.json is necessary
|
||||
if (json.dependencies && json.dependencies['@nrwl/jest']) {
|
||||
delete json.dependencies['@nrwl/jest'];
|
||||
}
|
||||
return json;
|
||||
});
|
||||
}
|
||||
|
||||
function createJestConfig(host: Tree) {
|
||||
if (!host.exists('jest.config.js')) {
|
||||
host.write(
|
||||
@@ -103,8 +94,8 @@ export function jestInitGenerator(tree: Tree, schema: JestInitSchema) {
|
||||
|
||||
let installTask: GeneratorCallback = () => {};
|
||||
if (!options.skipPackageJson) {
|
||||
removeDependenciesFromPackageJson(tree, ['@nrwl/jest'], []);
|
||||
installTask = updateDependencies(tree, options);
|
||||
removeNrwlJestFromDeps(tree);
|
||||
}
|
||||
|
||||
updateExtensions(tree);
|
||||
|
||||
@@ -9,6 +9,13 @@
|
||||
"x-type": "library",
|
||||
"description": "Create a library."
|
||||
},
|
||||
"init": {
|
||||
"factory": "./src/generators/init/init#initSchematic",
|
||||
"schema": "./src/generators/init/schema.json",
|
||||
"aliases": ["lib"],
|
||||
"x-type": "init",
|
||||
"description": "Init placeholder."
|
||||
},
|
||||
"convert-to-swc": {
|
||||
"factory": "./src/generators/convert-to-swc/convert-to-swc#convertToSwcSchematic",
|
||||
"schema": "./src/generators/convert-to-swc/schema.json",
|
||||
@@ -25,6 +32,13 @@
|
||||
"x-type": "library",
|
||||
"description": "Create a library"
|
||||
},
|
||||
"init": {
|
||||
"factory": "./src/generators/init/init#initGenerator",
|
||||
"schema": "./src/generators/init/schema.json",
|
||||
"aliases": ["lib"],
|
||||
"x-type": "init",
|
||||
"description": "Init placeholder."
|
||||
},
|
||||
"convert-to-swc": {
|
||||
"factory": "./src/generators/convert-to-swc/convert-to-swc#convertToSwcGenerator",
|
||||
"schema": "./src/generators/convert-to-swc/schema.json",
|
||||
|
||||
@@ -11,6 +11,12 @@
|
||||
"version": "13.8.5-beta.1",
|
||||
"description": "Adjust .swcrc to .lib.swcrc",
|
||||
"factory": "./src/migrations/update-13-8-5/update-swcrc"
|
||||
},
|
||||
"update-swcrc-exclude": {
|
||||
"cli": "nx",
|
||||
"version": "13.10.1-beta.1",
|
||||
"description": "Update .lib.swcrc to exclude missing test files",
|
||||
"factory": "./src/migrations/update-13-10-1/update-lib-swcrc-exclude"
|
||||
}
|
||||
},
|
||||
"packageJsonUpdates": {}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { convertNxGenerator, logger } from '@nrwl/devkit';
|
||||
|
||||
export async function initGenerator() {
|
||||
logger.info(
|
||||
'This is a placeholder for @nrwl/js:init generator. If you want to create a library, use @nrwl/js:lib instead'
|
||||
);
|
||||
}
|
||||
|
||||
export default initGenerator;
|
||||
export const initSchematic = convertNxGenerator(initGenerator);
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/schema",
|
||||
"$id": "NxTypescriptInit",
|
||||
"cli": "nx",
|
||||
"title": "Init nrwl/js",
|
||||
"description": "Init generator placeholder for nrwl/js"
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Update .lib.swcrc exclude should update the exclude pattern 1`] = `
|
||||
"{
|
||||
\\"jsc\\": {
|
||||
\\"target\\": \\"es2017\\",
|
||||
\\"parser\\": {
|
||||
\\"syntax\\": \\"typescript\\",
|
||||
\\"decorators\\": true,
|
||||
\\"dynamicImport\\": true
|
||||
},
|
||||
\\"transform\\": {
|
||||
\\"decoratorMetadata\\": true,
|
||||
\\"legacyDecorator\\": true
|
||||
},
|
||||
\\"keepClassNames\\": true,
|
||||
\\"externalHelpers\\": true,
|
||||
\\"loose\\": true
|
||||
},
|
||||
\\"module\\": {
|
||||
\\"type\\": \\"commonjs\\",
|
||||
\\"strict\\": true,
|
||||
\\"noInterop\\": true
|
||||
},
|
||||
\\"sourceMaps\\": true,
|
||||
\\"exclude\\": [
|
||||
\\".*.spec.tsx?$\\",
|
||||
\\".*.test.tsx?$\\",
|
||||
\\"./src/jest-setup.ts$\\",
|
||||
\\"./**/jest-setup.ts$\\",
|
||||
\\".*.js$\\"
|
||||
]
|
||||
}
|
||||
"
|
||||
`;
|
||||
@@ -0,0 +1,90 @@
|
||||
import {
|
||||
addProjectConfiguration,
|
||||
ProjectConfiguration,
|
||||
readJson,
|
||||
Tree,
|
||||
updateJson,
|
||||
} from '@nrwl/devkit';
|
||||
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
|
||||
import updateSwcRcExclude from './update-lib-swcrc-exclude';
|
||||
|
||||
const projectConfig: ProjectConfiguration = {
|
||||
root: 'libs/swc-lib',
|
||||
sourceRoot: 'libs/swc-lib/src',
|
||||
targets: {
|
||||
build: {
|
||||
executor: '@nrwl/js:swc',
|
||||
outputs: ['{options.outputPath}'],
|
||||
options: {
|
||||
outputPath: 'dist/libs/swc-lib',
|
||||
main: 'libs/swc-lib/src/index.ts',
|
||||
tsConfig: 'libs/swc-lib/tsconfig.lib.json',
|
||||
assets: ['libs/swc-lib/*.md'],
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const oldSwcRc = {
|
||||
jsc: {
|
||||
target: 'es2017',
|
||||
parser: {
|
||||
syntax: 'typescript',
|
||||
decorators: true,
|
||||
dynamicImport: true,
|
||||
},
|
||||
transform: {
|
||||
decoratorMetadata: true,
|
||||
legacyDecorator: true,
|
||||
},
|
||||
keepClassNames: true,
|
||||
externalHelpers: true,
|
||||
loose: true,
|
||||
},
|
||||
module: {
|
||||
type: 'commonjs',
|
||||
strict: true,
|
||||
noInterop: true,
|
||||
},
|
||||
sourceMaps: true,
|
||||
exclude: [
|
||||
'./src/**/.*.spec.ts$',
|
||||
'./**/.*.spec.ts$',
|
||||
'./src/**/jest-setup.ts$',
|
||||
'./**/jest-setup.ts$',
|
||||
'./**/.*.js$',
|
||||
],
|
||||
};
|
||||
describe('Update .lib.swcrc exclude', () => {
|
||||
let tree: Tree;
|
||||
beforeEach(() => {
|
||||
tree = createTreeWithEmptyWorkspace();
|
||||
addProjectConfiguration(tree, 'swc-lib', projectConfig);
|
||||
|
||||
tree.write('libs/swc-lib/.lib.swcrc', JSON.stringify(oldSwcRc));
|
||||
});
|
||||
|
||||
it('should update the exclude pattern', () => {
|
||||
updateSwcRcExclude(tree);
|
||||
expect(tree.read('libs/swc-lib/.lib.swcrc', 'utf-8')).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should NOT update the exclude pattern if not present', () => {
|
||||
updateJson(tree, 'libs/swc-lib/.lib.swcrc', (json) => {
|
||||
delete json.exclude;
|
||||
return json;
|
||||
});
|
||||
|
||||
const before = readJson(tree, 'libs/swc-lib/.lib.swcrc');
|
||||
updateSwcRcExclude(tree);
|
||||
const after = readJson(tree, 'libs/swc-lib/.lib.swcrc');
|
||||
|
||||
expect(after.exclude).toBeFalsy();
|
||||
expect(after).toEqual(before);
|
||||
});
|
||||
|
||||
it('should do nothing if .lib.swcrc doest not exist', () => {
|
||||
tree.delete('libs/swc-lib/.lib-swcrc');
|
||||
|
||||
expect(() => updateSwcRcExclude(tree)).not.toThrowError();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,41 @@
|
||||
import { readProjectConfiguration, Tree, updateJson } from '@nrwl/devkit';
|
||||
import { forEachExecutorOptions } from '@nrwl/workspace/src/utilities/executor-options-utils';
|
||||
import { join } from 'path';
|
||||
import { SwcExecutorOptions } from '../../utils/schema';
|
||||
import { defaultExclude } from '../../utils/swc/add-swc-config';
|
||||
|
||||
export default function updateSwcRcExclude(tree: Tree) {
|
||||
forEachExecutorOptions(
|
||||
tree,
|
||||
'@nrwl/js:swc',
|
||||
(config: SwcExecutorOptions, projectName) => {
|
||||
const projectConfig = readProjectConfiguration(tree, projectName);
|
||||
const libSwcPath = join(projectConfig.root, '.lib.swcrc');
|
||||
|
||||
if (!tree.exists(libSwcPath)) return;
|
||||
|
||||
updateJson(
|
||||
tree,
|
||||
libSwcPath,
|
||||
(json) => {
|
||||
if (json.exclude) {
|
||||
const excludePatterns = new Set([
|
||||
...defaultExclude,
|
||||
...json.exclude,
|
||||
]);
|
||||
// remove old patterns that are duplicate for new patterns
|
||||
// defined in defaultExclude
|
||||
excludePatterns.delete('./**/.*.spec.ts$');
|
||||
excludePatterns.delete('./src/**/.*.spec.ts$');
|
||||
excludePatterns.delete('./**/.*.js$');
|
||||
excludePatterns.delete('./src/**/jest-setup.ts$');
|
||||
|
||||
json.exclude = [...excludePatterns];
|
||||
}
|
||||
return json;
|
||||
},
|
||||
{ expectComments: true }
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -112,6 +112,7 @@ export class CopyAssetsHandler {
|
||||
// fast-glob only supports Unix paths
|
||||
const files = await fg(pattern.replace(/\\/g, '/'), {
|
||||
cwd: this.rootDir,
|
||||
dot: true, // enable hidden files
|
||||
});
|
||||
|
||||
this.callback(
|
||||
|
||||
@@ -4,11 +4,11 @@ import { Tree } from '@nrwl/devkit';
|
||||
import { join } from 'path';
|
||||
|
||||
export const defaultExclude = [
|
||||
'./src/**/.*.spec.ts$',
|
||||
'./**/.*.spec.ts$',
|
||||
'./src/**/jest-setup.ts$',
|
||||
'.*.spec.tsx?$',
|
||||
'.*.test.tsx?$',
|
||||
'./src/jest-setup.ts$',
|
||||
'./**/jest-setup.ts$',
|
||||
'./**/.*.js$',
|
||||
'.*.js$',
|
||||
];
|
||||
|
||||
const swcOptionsString = () => `{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
addDependenciesToPackageJson,
|
||||
removeDependenciesFromPackageJson,
|
||||
updateJson,
|
||||
writeJson,
|
||||
} from '@nrwl/devkit';
|
||||
@@ -169,13 +170,7 @@ function initEsLint(tree: Tree, options: LinterInitOptions): GeneratorCallback {
|
||||
}
|
||||
|
||||
if (!options.skipPackageJson) {
|
||||
updateJson(tree, 'package.json', (json) => {
|
||||
json.dependencies ||= {};
|
||||
|
||||
delete json.dependencies['@nrwl/linter'];
|
||||
|
||||
return json;
|
||||
});
|
||||
removeDependenciesFromPackageJson(tree, ['@nrwl/linter'], []);
|
||||
}
|
||||
|
||||
writeJson(tree, '.eslintrc.json', globalEsLintConfiguration);
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
NxJsonConfiguration,
|
||||
readJson,
|
||||
Tree,
|
||||
updateJson,
|
||||
} from '@nrwl/devkit';
|
||||
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
|
||||
|
||||
@@ -52,4 +53,15 @@ describe('init', () => {
|
||||
await initGenerator(tree, { unitTestRunner: 'none' });
|
||||
expect(tree.exists('jest.config.js')).toEqual(false);
|
||||
});
|
||||
|
||||
it('should not fail when dependencies is missing from package.json and no other init generators are invoked', async () => {
|
||||
updateJson(tree, 'package.json', (json) => {
|
||||
delete json.dependencies;
|
||||
return json;
|
||||
});
|
||||
|
||||
expect(
|
||||
initGenerator(tree, { unitTestRunner: 'none' })
|
||||
).resolves.toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,19 +3,16 @@ import {
|
||||
convertNxGenerator,
|
||||
formatFiles,
|
||||
GeneratorCallback,
|
||||
removeDependenciesFromPackageJson,
|
||||
Tree,
|
||||
updateJson,
|
||||
} from '@nrwl/devkit';
|
||||
import { jestInitGenerator } from '@nrwl/jest';
|
||||
import { setDefaultCollection } from '@nrwl/workspace/src/utilities/set-default-collection';
|
||||
import { nxVersion, tslibVersion } from '../../utils/versions';
|
||||
import { Schema } from './schema';
|
||||
import { setDefaultCollection } from '@nrwl/workspace/src/utilities/set-default-collection';
|
||||
import { jestInitGenerator } from '@nrwl/jest';
|
||||
|
||||
function updateDependencies(tree: Tree) {
|
||||
updateJson(tree, 'package.json', (json) => {
|
||||
delete json.dependencies['@nrwl/node'];
|
||||
return json;
|
||||
});
|
||||
removeDependenciesFromPackageJson(tree, ['@nrwl/node'], []);
|
||||
|
||||
return addDependenciesToPackageJson(
|
||||
tree,
|
||||
|
||||
@@ -770,11 +770,13 @@ async function generateMigrationsJsonAndUpdatePackageJson(
|
||||
function showConnectToCloudMessage() {
|
||||
try {
|
||||
const nxJson = readJsonFile<NxJsonConfiguration>('nx.json');
|
||||
const defaultRunnerIsUsed = Object.values(nxJson.tasksRunnerOptions).find(
|
||||
(r: any) =>
|
||||
r.runner == '@nrwl/workspace/tasks-runners/default' ||
|
||||
r.runner == 'nx/tasks-runners/default'
|
||||
);
|
||||
const defaultRunnerIsUsed =
|
||||
!nxJson.tasksRunnerOptions ||
|
||||
Object.values(nxJson.tasksRunnerOptions).find(
|
||||
(r: any) =>
|
||||
r.runner == '@nrwl/workspace/tasks-runners/default' ||
|
||||
r.runner == 'nx/tasks-runners/default'
|
||||
);
|
||||
return !!defaultRunnerIsUsed;
|
||||
} catch {
|
||||
return false;
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import { commandsObject } from 'nx/src/command-line/nx-commands';
|
||||
|
||||
describe('nx-commands', () => {
|
||||
it('should parse dot notion cli args', () => {
|
||||
const actual = commandsObject.parse(
|
||||
'nx e2e project-e2e --env.NX_API_URL=http://localhost:4200 --abc.123.xyx=false --a.b=3'
|
||||
);
|
||||
expect(actual).toEqual(
|
||||
expect.objectContaining({
|
||||
abc: {
|
||||
'123': {
|
||||
xyx: 'false',
|
||||
},
|
||||
},
|
||||
a: {
|
||||
b: 3,
|
||||
},
|
||||
env: {
|
||||
NX_API_URL: 'http://localhost:4200',
|
||||
},
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -25,7 +25,8 @@ yargs.wrap(yargs.terminalWidth());
|
||||
export const commandsObject = yargs
|
||||
.parserConfiguration({
|
||||
'strip-dashed': true,
|
||||
'dot-notation': false,
|
||||
// allow parsing --env.SOME_ARG for cypress cli env args
|
||||
'dot-notation': true,
|
||||
})
|
||||
.usage(
|
||||
`
|
||||
|
||||
@@ -49,7 +49,6 @@ export async function buildProjectGraph() {
|
||||
|
||||
const cacheEnabled = process.env.NX_CACHE_PROJECT_GRAPH !== 'false';
|
||||
let cache = cacheEnabled ? readCache() : null;
|
||||
|
||||
return (
|
||||
await buildProjectGraphUsingProjectFileMap(
|
||||
workspaceJson,
|
||||
@@ -292,7 +291,10 @@ function buildExplicitDependenciesUsingWorkers(
|
||||
totalNumOfFilesToProcess: number,
|
||||
builder: ProjectGraphBuilder
|
||||
) {
|
||||
const numberOfWorkers = getNumberOfWorkers();
|
||||
const numberOfWorkers = Math.min(
|
||||
totalNumOfFilesToProcess,
|
||||
getNumberOfWorkers()
|
||||
);
|
||||
const bins = splitFilesIntoBins(
|
||||
ctx,
|
||||
totalNumOfFilesToProcess,
|
||||
|
||||
@@ -26,28 +26,21 @@ export function getResolveRequest(extensions: string[]) {
|
||||
|
||||
const { resolveRequest, ...context } = _context;
|
||||
|
||||
let resolvedPath = defaultMetroResolver(context, moduleName, platform);
|
||||
const resolvedPath =
|
||||
defaultMetroResolver(context, moduleName, platform) ||
|
||||
tsconfigPathsResolver(
|
||||
context,
|
||||
extensions,
|
||||
realModuleName,
|
||||
moduleName,
|
||||
platform
|
||||
) ||
|
||||
pnpmResolver(extensions, context, realModuleName, moduleName);
|
||||
|
||||
if (resolvedPath) {
|
||||
return resolvedPath;
|
||||
}
|
||||
|
||||
resolvedPath = pnpmResolver(
|
||||
extensions,
|
||||
context,
|
||||
realModuleName,
|
||||
moduleName
|
||||
);
|
||||
if (resolvedPath) {
|
||||
return resolvedPath;
|
||||
}
|
||||
|
||||
return tsconfigPathsResolver(
|
||||
context,
|
||||
extensions,
|
||||
realModuleName,
|
||||
moduleName,
|
||||
platform
|
||||
);
|
||||
throw new Error(`Cannot resolve ${chalk.bold(moduleName)}`);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -136,7 +129,6 @@ function tsconfigPathsResolver(
|
||||
)
|
||||
);
|
||||
}
|
||||
throw new Error(`Cannot resolve ${chalk.bold(moduleName)}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -287,6 +287,43 @@
|
||||
"alwaysAddToPackageJson": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"13.10.1": {
|
||||
"version": "13.10.1-beta.1",
|
||||
"packages": {
|
||||
"@types/react": {
|
||||
"version": "18.0.0",
|
||||
"alwaysAddToPackageJson": false
|
||||
},
|
||||
"@types/react-dom": {
|
||||
"version": "18.0.0",
|
||||
"alwaysAddToPackageJson": false
|
||||
},
|
||||
"@types/styled-components": {
|
||||
"version": "5.1.25",
|
||||
"alwaysAddToPackageJson": false
|
||||
},
|
||||
"@emotion/react": {
|
||||
"version": "11.9.0",
|
||||
"alwaysAddToPackageJson": false
|
||||
},
|
||||
"@testing-library/react": {
|
||||
"version": "13.0.0",
|
||||
"alwaysAddToPackageJson": false
|
||||
},
|
||||
"@reduxjs/toolkit": {
|
||||
"version": "1.8.1",
|
||||
"alwaysAddToPackageJson": false
|
||||
},
|
||||
"react-redux": {
|
||||
"version": "7.2.8",
|
||||
"alwaysAddToPackageJson": false
|
||||
},
|
||||
"eslint-plugin-import": {
|
||||
"version": "2.26.0",
|
||||
"alwaysAddToPackageJson": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
<% if (strict) { %>import { StrictMode } from 'react';<% } %>
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import * as ReactDOMClient from 'react-dom/client';
|
||||
<% if (routing) { %>import { BrowserRouter } from 'react-router-dom';<% } %>
|
||||
|
||||
import App from './app/<%= fileName %>';
|
||||
|
||||
ReactDOM.render(<% if (strict) { %><StrictMode><% } %><% if (routing) { %><BrowserRouter><% } %><App /><% if (routing) { %></BrowserRouter><% } %><% if (strict) { %></StrictMode><% } %>, document.getElementById('root'));
|
||||
const root = ReactDOMClient.createRoot(document.getElementById('root') as HTMLElement);
|
||||
root.render(
|
||||
<% if (strict) { %><StrictMode><% } %><% if (routing) { %><BrowserRouter><% } %><App /><% if (routing) { %></BrowserRouter><% } %><% if (strict) { %></StrictMode><% } %>
|
||||
);
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
import { InitSchema } from './schema';
|
||||
import { cypressInitGenerator } from '@nrwl/cypress';
|
||||
import {
|
||||
addDependenciesToPackageJson,
|
||||
convertNxGenerator,
|
||||
GeneratorCallback,
|
||||
readWorkspaceConfiguration,
|
||||
removeDependenciesFromPackageJson,
|
||||
Tree,
|
||||
updateJson,
|
||||
updateWorkspaceConfiguration,
|
||||
} from '@nrwl/devkit';
|
||||
import { jestInitGenerator } from '@nrwl/jest';
|
||||
import { cypressInitGenerator } from '@nrwl/cypress';
|
||||
import { webInitGenerator } from '@nrwl/web';
|
||||
import { setDefaultCollection } from '@nrwl/workspace/src/utilities/set-default-collection';
|
||||
import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial';
|
||||
import { setDefaultCollection } from '@nrwl/workspace/src/utilities/set-default-collection';
|
||||
import {
|
||||
nxVersion,
|
||||
reactDomVersion,
|
||||
reactTestRendererVersion,
|
||||
reactVersion,
|
||||
testingLibraryReactHooksVersion,
|
||||
testingLibraryReactVersion,
|
||||
typesReactDomVersion,
|
||||
typesReactVersion,
|
||||
testingLibraryReactHooksVersion,
|
||||
reactTestRendererVersion,
|
||||
} from '../../utils/versions';
|
||||
import { InitSchema } from './schema';
|
||||
|
||||
function setDefault(host: Tree) {
|
||||
const workspace = readWorkspaceConfiguration(host);
|
||||
@@ -45,12 +45,7 @@ function setDefault(host: Tree) {
|
||||
}
|
||||
|
||||
function updateDependencies(host: Tree) {
|
||||
updateJson(host, 'package.json', (json) => {
|
||||
if (json.dependencies && json.dependencies['@nrwl/react']) {
|
||||
delete json.dependencies['@nrwl/react'];
|
||||
}
|
||||
return json;
|
||||
});
|
||||
removeDependenciesFromPackageJson(host, ['@nrwl/react'], []);
|
||||
|
||||
return addDependenciesToPackageJson(
|
||||
host,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { existsSync, readFileSync } from 'fs';
|
||||
import { NormalModuleReplacementPlugin } from 'webpack';
|
||||
import { joinPathFragments, normalizePath, workspaceRoot } from '@nrwl/devkit';
|
||||
import { dirname } from 'path';
|
||||
import { dirname, join, normalize } from 'path';
|
||||
import { ParsedCommandLine } from 'typescript';
|
||||
import {
|
||||
getRootTsConfigPath,
|
||||
@@ -40,9 +40,7 @@ export function shareWorkspaceLibraries(
|
||||
const pathMappings: { name: string; path: string }[] = [];
|
||||
for (const [key, paths] of Object.entries(tsconfigPathAliases)) {
|
||||
if (libraries && libraries.includes(key)) {
|
||||
const pathToLib = normalizePath(
|
||||
joinPathFragments(workspaceRoot, paths[0])
|
||||
);
|
||||
const pathToLib = normalize(join(workspaceRoot, paths[0]));
|
||||
pathMappings.push({
|
||||
name: key,
|
||||
path: pathToLib,
|
||||
@@ -71,10 +69,10 @@ export function shareWorkspaceLibraries(
|
||||
}
|
||||
|
||||
const from = req.context;
|
||||
const to = normalizePath(joinPathFragments(req.context, req.request));
|
||||
const to = normalize(join(req.context, req.request));
|
||||
|
||||
for (const library of pathMappings) {
|
||||
const libFolder = normalizePath(dirname(library.path));
|
||||
const libFolder = normalize(dirname(library.path));
|
||||
if (!from.startsWith(libFolder) && to.startsWith(libFolder)) {
|
||||
req.request = library.name;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
addDependenciesToPackageJson,
|
||||
readJson,
|
||||
logger,
|
||||
readJson,
|
||||
Tree,
|
||||
} from '@nrwl/devkit';
|
||||
|
||||
@@ -24,9 +24,10 @@ export async function updateToReact18(host: Tree) {
|
||||
react: '18.0.0',
|
||||
'react-dom': '18.0.0',
|
||||
'react-is': '18.0.0',
|
||||
'react-test-renderer': '18.0.0',
|
||||
},
|
||||
{}
|
||||
{
|
||||
'react-test-renderer': '18.0.0',
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ describe('findMainRenderStatement', () => {
|
||||
tree = createTreeWithEmptyWorkspace();
|
||||
});
|
||||
|
||||
it('should return render(...)', () => {
|
||||
it('should return ReactDOM.render(...)', () => {
|
||||
const sourceCode = `
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
@@ -237,6 +237,25 @@ ReactDOM.render(<div/>, document.getElementById('root'));
|
||||
expect(node).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should return root.render(...)', () => {
|
||||
const sourceCode = `
|
||||
import React from 'react';
|
||||
import ReactDOMClient from 'react-dom/client';
|
||||
const root = ReactDOM.createRoot(document.getElementById('root'));
|
||||
root.render(<div/>);
|
||||
`;
|
||||
tree.write('/main.tsx', sourceCode);
|
||||
const source = ts.createSourceFile(
|
||||
'/main.tsx',
|
||||
sourceCode,
|
||||
ts.ScriptTarget.Latest,
|
||||
true
|
||||
);
|
||||
|
||||
const node = utils.findMainRenderStatement(source);
|
||||
expect(node).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should return render(...)', () => {
|
||||
const sourceCode = `
|
||||
import React from 'react';
|
||||
|
||||
@@ -43,6 +43,7 @@ export function findMainRenderStatement(
|
||||
|
||||
for (const expr of calls) {
|
||||
const inner = expr.expression;
|
||||
// React 17 and below
|
||||
if (
|
||||
ts.isPropertyAccessExpression(inner) &&
|
||||
/ReactDOM/i.test(inner.expression.getText()) &&
|
||||
@@ -50,6 +51,15 @@ export function findMainRenderStatement(
|
||||
) {
|
||||
return expr;
|
||||
}
|
||||
|
||||
// React 18
|
||||
if (
|
||||
ts.isPropertyAccessExpression(inner) &&
|
||||
/root/.test(inner.expression.getText()) &&
|
||||
inner.name.getText() === 'render'
|
||||
) {
|
||||
return expr;
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Try to find render from 'react-dom'.
|
||||
@@ -358,7 +368,7 @@ export function addReduxStoreToMain(
|
||||
): StringChange[] {
|
||||
const renderStmt = findMainRenderStatement(source);
|
||||
if (!renderStmt) {
|
||||
logger.warn(`Could not find ReactDOM.render in ${sourcePath}`);
|
||||
logger.warn(`Could not find render(...) in ${sourcePath}`);
|
||||
return [];
|
||||
}
|
||||
const jsx = renderStmt.arguments[0];
|
||||
|
||||
@@ -3,15 +3,15 @@ export const nxVersion = '*';
|
||||
export const reactVersion = '18.0.0';
|
||||
export const reactDomVersion = '18.0.0';
|
||||
export const reactIsVersion = '18.0.0';
|
||||
export const typesReactVersion = '17.0.43';
|
||||
export const typesReactDomVersion = '17.0.14';
|
||||
export const typesReactVersion = '18.0.0';
|
||||
export const typesReactDomVersion = '18.0.0';
|
||||
export const typesReactIsVersion = '17.0.3';
|
||||
|
||||
export const styledComponentsVersion = '5.3.5';
|
||||
export const typesStyledComponentsVersion = '5.1.24';
|
||||
export const typesStyledComponentsVersion = '5.1.25';
|
||||
|
||||
export const emotionStyledVersion = '11.8.1';
|
||||
export const emotionReactVersion = '11.8.2';
|
||||
export const emotionReactVersion = '11.9.0';
|
||||
export const emotionBabelPlugin = '11.7.2';
|
||||
|
||||
export const styledJsxVersion = '5.0.2';
|
||||
@@ -19,14 +19,14 @@ export const styledJsxVersion = '5.0.2';
|
||||
export const reactRouterDomVersion = '5.3.0';
|
||||
export const typesReactRouterDomVersion = '5.3.3';
|
||||
|
||||
export const testingLibraryReactVersion = '12.1.4';
|
||||
export const testingLibraryReactVersion = '13.0.0';
|
||||
export const testingLibraryReactHooksVersion = '7.0.2';
|
||||
|
||||
export const reduxjsToolkitVersion = '1.8.0';
|
||||
export const reactReduxVersion = '7.2.6';
|
||||
export const reduxjsToolkitVersion = '1.8.1';
|
||||
export const reactReduxVersion = '7.2.8';
|
||||
export const reactTestRendererVersion = '18.0.0';
|
||||
|
||||
export const eslintPluginImportVersion = '2.25.4';
|
||||
export const eslintPluginImportVersion = '2.26.0';
|
||||
export const eslintPluginJsxA11yVersion = '6.5.1';
|
||||
export const eslintPluginReactVersion = '7.29.4';
|
||||
export const eslintPluginReactHooksVersion = '4.4.0';
|
||||
|
||||
@@ -52,7 +52,6 @@ function runInstance(options: StorybookExecutorOptions) {
|
||||
process.env.NODE_ENV = env;
|
||||
return buildDevStandalone({
|
||||
...options,
|
||||
ci: true,
|
||||
configType: env.toUpperCase(),
|
||||
} as any).catch((error) => {
|
||||
// TODO(juri): find a better cleaner way to handle these. Taken from:
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
NxJsonConfiguration,
|
||||
readJson,
|
||||
Tree,
|
||||
updateJson,
|
||||
} from '@nrwl/devkit';
|
||||
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
|
||||
|
||||
@@ -79,5 +80,19 @@ describe('init', () => {
|
||||
});
|
||||
expect(tree.exists('babel.config.json')).toBe(false);
|
||||
});
|
||||
|
||||
it('should not fail when dependencies is missing from package.json and no other init generators are invoked', async () => {
|
||||
updateJson(tree, 'package.json', (json) => {
|
||||
delete json.dependencies;
|
||||
return json;
|
||||
});
|
||||
|
||||
expect(
|
||||
webInitGenerator(tree, {
|
||||
e2eTestRunner: 'none',
|
||||
unitTestRunner: 'none',
|
||||
})
|
||||
).resolves.toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,24 +1,21 @@
|
||||
import { cypressInitGenerator } from '@nrwl/cypress';
|
||||
import {
|
||||
addDependenciesToPackageJson,
|
||||
convertNxGenerator,
|
||||
formatFiles,
|
||||
GeneratorCallback,
|
||||
removeDependenciesFromPackageJson,
|
||||
Tree,
|
||||
updateJson,
|
||||
writeJson,
|
||||
} from '@nrwl/devkit';
|
||||
import { setDefaultCollection } from '@nrwl/workspace/src/utilities/set-default-collection';
|
||||
import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial';
|
||||
import { Schema } from './schema';
|
||||
import { nxVersion } from '../../utils/versions';
|
||||
import { cypressInitGenerator } from '@nrwl/cypress';
|
||||
import { jestInitGenerator } from '@nrwl/jest';
|
||||
import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial';
|
||||
import { setDefaultCollection } from '@nrwl/workspace/src/utilities/set-default-collection';
|
||||
import { nxVersion } from '../../utils/versions';
|
||||
import { Schema } from './schema';
|
||||
|
||||
function updateDependencies(tree: Tree) {
|
||||
updateJson(tree, 'package.json', (json) => {
|
||||
delete json.dependencies['@nrwl/web'];
|
||||
return json;
|
||||
});
|
||||
removeDependenciesFromPackageJson(tree, ['@nrwl/web'], []);
|
||||
|
||||
return addDependenciesToPackageJson(
|
||||
tree,
|
||||
|
||||
@@ -9,9 +9,9 @@ export function updateTasksRunner(host: Tree) {
|
||||
if (
|
||||
config?.tasksRunnerOptions['default'] &&
|
||||
config?.tasksRunnerOptions['default'].runner ==
|
||||
'@nrwl/workspace/tasks-runner/default'
|
||||
'@nrwl/workspace/tasks-runners/default'
|
||||
) {
|
||||
config.tasksRunnerOptions['default'].runner = 'nx/tasks-runner/default';
|
||||
config.tasksRunnerOptions['default'].runner = 'nx/tasks-runners/default';
|
||||
}
|
||||
updateWorkspaceConfiguration(host, config);
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ const options = {
|
||||
updatePackageJsonFiles(parsedVersion, parsedArgs.local);
|
||||
if (parsedArgs.local) {
|
||||
childProcess.execSync(
|
||||
`./scripts/publish.sh ${parsedVersion.version} latest --local`,
|
||||
`./scripts/publish.sh ${parsedVersion.version} previous --local`,
|
||||
{
|
||||
stdio: [0, 1, 2],
|
||||
}
|
||||
@@ -226,7 +226,7 @@ if (parsedArgs.local) {
|
||||
process.exit(0);
|
||||
return;
|
||||
}
|
||||
const npmTag = parsedVersion.isPrerelease ? 'next' : 'latest';
|
||||
const npmTag = parsedVersion.isPrerelease ? 'next' : 'previous';
|
||||
const npmPublishCommand = `./scripts/publish.sh ${output.version} ${npmTag}`;
|
||||
console.log('Executing publishing script for all packages:');
|
||||
console.log(`> ${npmPublishCommand}`);
|
||||
|
||||
Reference in New Issue
Block a user