Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: migrate from nx 13 to 15.6.3 #27885

Merged
merged 7 commits into from
May 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
/.prettierignore @microsoft/fluentui-react-build
/.nxignore @microsoft/fluentui-react-build
/jest.preset.js @microsoft/fluentui-react-build
/jest.preset.ts @microsoft/fluentui-react-build
/jest.config.js @microsoft/fluentui-react-build
/jest.config.ts @microsoft/fluentui-react-build
/lerna.json @microsoft/fluentui-react-build
/package.json @microsoft/fluentui-react-build
/sizeauditor.json @microsoft/fluentui-react-build
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js → jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { getJestProjects } = require('@nrwl/jest');

module.exports = {
export default {
projects: [...getJestProjects()],
};
80 changes: 20 additions & 60 deletions migrations.json
Original file line number Diff line number Diff line change
@@ -1,76 +1,36 @@
{
"migrations": [
{
"version": "13.9.0-beta.0",
"description": "Replace @nrwl/tao with nx",
"cli": "nx",
"implementation": "./src/migrations/update-13-9-0/replace-tao-with-nx",
"package": "@nrwl/workspace",
"name": "13-9-0-replace-tao-with-nx"
"version": "15.0.0-beta.1",
"description": "Replace implicitDependencies with namedInputs + target inputs",
"implementation": "./src/migrations/update-15-0-0/migrate-to-inputs",
"package": "nx",
"name": "15.0.0-migrate-to-inputs"
},
{
"version": "13.10.0-beta.0",
"description": "Update the decorate-angular-cli script to require nx instead of @nrwl/cli",
"cli": "nx",
"implementation": "./src/migrations/update-13-10-0/update-decorate-cli",
"package": "@nrwl/workspace",
"name": "13-10-0-update-decorate-cli"
"version": "15.0.0-beta.1",
"description": "Prefix outputs with {workspaceRoot}/{projectRoot} if needed",
"implementation": "./src/migrations/update-15-0-0/prefix-outputs",
"package": "nx",
"name": "15.0.0-prefix-outputs"
},
{
"version": "13.10.0-beta.0",
"description": "Update the tasks runner property to import it from the nx package instead of @nrwl/worksapce",
"cli": "nx",
"implementation": "./src/migrations/update-13-10-0/update-tasks-runner",
"package": "@nrwl/workspace",
"name": "13-10-0-update-tasks-runner"
"version": "15.0.12-beta.1",
"description": "Set project names in project.json files",
"implementation": "./src/migrations/update-15-1-0/set-project-names",
"package": "nx",
"name": "15.1.0-set-project-names"
},
{
"version": "15.0.0-beta.0",
"cli": "nx",
"version": "13.8.5-beta.1",
"description": "Renames @nrwl/node:build to @nrwl/node:webpack",
"factory": "./src/migrations/update-13-8-5/rename-build-to-webpack",
"package": "@nrwl/node",
"name": "rename-build-to-webpack"
},
{
"cli": "nx",
"version": "13.8.5-beta.1",
"description": "Renames @nrwl/node:execute to @nrwl/node:node",
"factory": "./src/migrations/update-13-8-5/rename-execute-to-node",
"package": "@nrwl/node",
"name": "rename-execute-to-node"
},
{
"cli": "nx",
"version": "13.8.5-beta.1",
"description": "Renames @nrwl/node:package to @nrwl/js:tsc",
"factory": "./src/migrations/update-13-8-5/update-package-to-tsc",
"package": "@nrwl/node",
"name": "update-package-to-tsc"
},
{
"cli": "nx",
"version": "13.8.5-beta.1",
"description": "Renames @nrwl/js:node to @nrwl/node:node",
"factory": "./src/migrations/update-13-8-5/update-node-executor",
"package": "@nrwl/js",
"name": "update-node-executor"
},
{
"cli": "nx",
"version": "13.8.5-beta.1",
"description": "Adjust .swcrc to .lib.swcrc",
"factory": "./src/migrations/update-13-8-5/update-swcrc",
"package": "@nrwl/js",
"name": "update-swcrc"
},
{
"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",
"package": "@nrwl/js",
"name": "update-swcrc-exclude"
"description": "Stop hashing jest spec files and config files for build targets and dependent tasks",
"factory": "./src/migrations/update-15-0-0/add-jest-inputs",
"package": "@nrwl/jest",
"name": "add-jest-inputs"
}
]
}
47 changes: 23 additions & 24 deletions nx.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"npmScope": "fluentui",
"implicitDependencies": {
"package.json": {
"dependencies": "*",
"devDependencies": "*"
}
},
"tasksRunnerOptions": {
"default": {
"runner": "nx/tasks-runners/default",
Expand All @@ -28,24 +23,28 @@
"analyzeSourceFiles": true
}
},
"targetDependencies": {
"build": [
{
"target": "build",
"projects": "dependencies"
}
],
"package": [
{
"target": "package",
"projects": "dependencies"
}
],
"prepare": [
{
"target": "prepare",
"projects": "dependencies"
}
"targetDefaults": {
"build": {
"dependsOn": ["^build"]
},
"package": {
"dependsOn": ["^package"]
},
"prepare": {
"dependsOn": ["^prepare"]
},
"test": {
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"]
}
},
"namedInputs": {
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"sharedGlobals": [],
"production": [
"default",
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
"!{projectRoot}/tsconfig.spec.json",
"!{projectRoot}/jest.config.[jt]s"
]
}
}
40 changes: 21 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,23 @@
"@actions/core": "1.9.1",
"@actions/github": "5.0.3",
"@azure/data-tables": "13.0.0",
"@babel/core": "7.21.0",
"@babel/generator": "7.21.1",
"@babel/parser": "7.21.1",
"@babel/core": "7.21.8",
"@babel/generator": "7.21.5",
"@babel/parser": "7.21.8",
"@babel/plugin-proposal-class-properties": "7.18.6",
"@babel/plugin-proposal-decorators": "7.21.0",
"@babel/plugin-proposal-nullish-coalescing-operator": "7.18.6",
"@babel/plugin-proposal-optional-chaining": "7.21.0",
"@babel/plugin-syntax-dynamic-import": "7.8.3",
"@babel/plugin-syntax-object-rest-spread": "7.8.3",
"@babel/plugin-transform-runtime": "7.21.0",
"@babel/preset-env": "7.20.2",
"@babel/plugin-transform-runtime": "7.21.4",
"@babel/preset-env": "7.21.5",
"@babel/preset-react": "7.18.6",
"@babel/preset-typescript": "7.18.6",
"@babel/preset-typescript": "7.21.5",
"@babel/register": "7.21.0",
"@babel/standalone": "7.21.1",
"@babel/traverse": "7.21.2",
"@babel/types": "7.21.2",
"@babel/standalone": "7.21.8",
"@babel/traverse": "7.21.5",
"@babel/types": "7.21.5",
"@cactuslab/usepubsub": "^1.0.2",
"@ctrl/tinycolor": "3.3.4",
"@cypress/react": "5.12.4",
Expand All @@ -100,12 +100,12 @@
"@microsoft/eslint-plugin-sdl": "0.1.9",
"@microsoft/load-themed-styles": "1.10.26",
"@microsoft/loader-load-themed-styles": "2.0.17",
"@nrwl/cli": "13.10.6",
"@nrwl/devkit": "13.10.6",
"@nrwl/jest": "13.10.6",
"@nrwl/js": "13.10.6",
"@nrwl/node": "13.10.6",
"@nrwl/workspace": "13.10.6",
"@nrwl/cli": "15.6.3",
"@nrwl/devkit": "15.6.3",
"@nrwl/jest": "15.6.3",
"@nrwl/js": "15.6.3",
"@nrwl/node": "15.6.3",
"@nrwl/workspace": "15.6.3",
"@octokit/rest": "18.12.0",
"@storybook/addon-a11y": "6.5.15",
"@storybook/addon-actions": "6.5.15",
Expand Down Expand Up @@ -142,6 +142,7 @@
"@types/copy-webpack-plugin": "6.4.0",
"@types/dedent": "0.7.0",
"@types/doctrine": "0.0.5",
"@types/ejs": "3.1.2",
"@types/enzyme": "3.10.7",
"@types/eslint": "7.2.13",
"@types/express": "4.17.15",
Expand Down Expand Up @@ -221,6 +222,7 @@
"doctoc": "2.0.1",
"doctrine": "3.0.0",
"dotparser": "1.1.1",
"ejs": "3.1.9",
"enquirer": "2.3.6",
"enzyme": "3.10.0",
"enzyme-to-json": "3.6.2",
Expand Down Expand Up @@ -282,7 +284,7 @@
"node-fetch": "2.6.7",
"node-plop": "0.25.0",
"node-polyfill-webpack-plugin": "1.0.2",
"nx": "13.10.6",
"nx": "15.6.3",
"p-queue": "6.6.2",
"parse-diff": "0.7.1",
"path-browserify": "1.0.1",
Expand Down Expand Up @@ -331,8 +333,8 @@
"swc-loader": "0.2.3",
"syncpack": "5.6.10",
"tachometer": "0.7.0",
"terser": "5.14.2",
"terser-webpack-plugin": "5.3.1",
"terser": "5.17.4",
"terser-webpack-plugin": "5.3.9",
"through2": "4.0.2",
"tmp": "0.2.1",
"ts-jest": "28.0.8",
Expand All @@ -344,7 +346,7 @@
"typescript": "4.3.5",
"vinyl": "2.2.0",
"vrscreenshotdiff": "0.0.17",
"webpack": "5.74.0",
"webpack": "5.83.1",
"webpack-bundle-analyzer": "4.4.2",
"webpack-cli": "4.10.0",
"webpack-dev-middleware": "4.2.0",
Expand Down
4 changes: 2 additions & 2 deletions scripts/generators/create-component/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as os from 'os';
import * as path from 'path';

import { findGitRoot, getAllPackageInfo, isConvergedPackage } from '@fluentui/scripts-monorepo';
import { WorkspaceJsonConfiguration, names } from '@nrwl/devkit';
import { ProjectsConfigurations, names } from '@nrwl/devkit';
import chalk from 'chalk';
import * as fs from 'fs-extra';
import { Actions } from 'node-plop';
Expand Down Expand Up @@ -173,7 +173,7 @@ const appendToPackageIndex = (data: Data): string => {
//#endregion

function getProjectMetadata(options: { root: string; name: string }) {
const nxWorkspace: WorkspaceJsonConfiguration = JSON.parse(
const nxWorkspace: ProjectsConfigurations = JSON.parse(
fs.readFileSync(path.join(options.root, 'workspace.json'), 'utf-8'),
);

Expand Down
6 changes: 3 additions & 3 deletions scripts/generators/create-package/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { spawnSync } from 'child_process';
import * as path from 'path';

import { PackageJson, findGitRoot } from '@fluentui/scripts-monorepo';
import { WorkspaceJsonConfiguration } from '@nrwl/devkit';
import { ProjectsConfigurations } from '@nrwl/devkit';
import chalk from 'chalk';
import * as fs from 'fs-extra';
import * as jju from 'jju';
Expand Down Expand Up @@ -306,7 +306,7 @@ function updateNxWorkspace(_answers: Answers, config: { root: string; projectNam
};

const nxWorkspaceContent = fs.readFileSync(paths.workspace, 'utf-8');
const nxWorkspace: WorkspaceJsonConfiguration = jju.parse(nxWorkspaceContent);
const nxWorkspace: ProjectsConfigurations = jju.parse(nxWorkspaceContent);
Object.assign(nxWorkspace.projects, templates.workspace);

const updatedNxWorkspace = jju.update(nxWorkspaceContent, nxWorkspace, { mode: 'json', indent: 2 });
Expand All @@ -315,7 +315,7 @@ function updateNxWorkspace(_answers: Answers, config: { root: string; projectNam
}

function getProjectMetadata(options: { root: string; name: string }) {
const nxWorkspace: WorkspaceJsonConfiguration = JSON.parse(
const nxWorkspace: ProjectsConfigurations = JSON.parse(
fs.readFileSync(path.join(options.root, 'workspace.json'), 'utf-8'),
);

Expand Down
4 changes: 2 additions & 2 deletions tools/generators/add-codeowners.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Tree, addProjectConfiguration, stripIndents } from '@nrwl/devkit';
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
import { createTreeWithEmptyV1Workspace } from '@nrwl/devkit/testing';
import { addCodeowner } from './add-codeowners';
import { setupCodeowners } from '../utils-testing';
import { workspacePaths } from '../utils';
Expand All @@ -8,7 +8,7 @@ describe(`#addCodeowner`, () => {
let tree: Tree;

beforeEach(() => {
tree = createTreeWithEmptyWorkspace();
tree = createTreeWithEmptyV1Workspace();

addProjectConfiguration(tree, '@proj/react-one', {
root: '/packages/react-one',
Expand Down
4 changes: 2 additions & 2 deletions tools/generators/dependency-mismatch/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
import { createTreeWithEmptyV1Workspace } from '@nrwl/devkit/testing';
import { Tree, addProjectConfiguration, serializeJson, readWorkspaceConfiguration, readJson } from '@nrwl/devkit';

import generator from './index';
Expand All @@ -9,7 +9,7 @@ describe('dependency-mismatch generator', () => {
let workspaceNpmScope: string;

beforeEach(() => {
appTree = createTreeWithEmptyWorkspace();
appTree = createTreeWithEmptyV1Workspace();
workspaceNpmScope = readWorkspaceConfiguration(appTree).npmScope as string;
});

Expand Down
12 changes: 6 additions & 6 deletions tools/generators/epic-generator/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { addProjectConfiguration, ProjectType, stripIndents, writeJson } from '@nrwl/devkit';
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
import { createTreeWithEmptyV1Workspace } from '@nrwl/devkit/testing';
import { execSync, spawnSync, SpawnSyncReturns } from 'child_process';
import { workspacePaths } from '../../utils';
import epicGenerator from './index';
Expand All @@ -16,7 +16,7 @@ type Package = {
};

function setupTest(packages: Package[]) {
const tree = createTreeWithEmptyWorkspace();
const tree = createTreeWithEmptyV1Workspace();

// Initialize NX package structure
packages.forEach(pckg => {
Expand Down Expand Up @@ -80,15 +80,15 @@ function setupTest(packages: Package[]) {
describe('epic-generator', () => {
describe('validation', () => {
it('requires a non-empty title', () => {
const tree = createTreeWithEmptyWorkspace();
const tree = createTreeWithEmptyV1Workspace();

expect(() =>
epicGenerator(tree, { title: ' ', repository: 'microsoft/fluentui' }),
).toThrowErrorMatchingInlineSnapshot(`"Must provide a title for the issue"`);
});

it('requires a well formatted repository', () => {
const tree = createTreeWithEmptyWorkspace();
const tree = createTreeWithEmptyV1Workspace();

expect(() => epicGenerator(tree, { title: 'test title', repository: 'invalid_repo' }))
.toThrowErrorMatchingInlineSnapshot(`
Expand All @@ -103,7 +103,7 @@ describe('epic-generator', () => {
spawnSyncMock.mockReturnValueOnce({
error: new Error('command not found.'),
});
const tree = createTreeWithEmptyWorkspace();
const tree = createTreeWithEmptyV1Workspace();

expect(() => epicGenerator(tree, { title: 'test title', repository: 'microsoft/fluentui' }))
.toThrowErrorMatchingInlineSnapshot(`
Expand All @@ -117,7 +117,7 @@ describe('epic-generator', () => {
output: [['You are not logged into any GitHub hosts. Run gh auth login to authenticate.']],
});

const tree = createTreeWithEmptyWorkspace();
const tree = createTreeWithEmptyV1Workspace();

expect(() =>
epicGenerator(tree, { title: 'test title', repository: 'microsoft/fluentui' }),
Expand Down
Loading