mirror of
https://github.com/mathuo/dockview
synced 2026-05-21 10:47:16 +00:00
chore: migrate monorepo orchestration from Lerna to NX
Replace Lerna with NX for build orchestration, caching, and release management while keeping all existing build tools untouched. - Add nx and @nx/js, remove lerna from devDependencies - Create nx.json with task pipeline (topological build ordering), caching, and fixed-version release configuration - Update root scripts to use `nx run-many` for build, build:bundle, test - Add release, release:version, release:publish scripts - Update CI workflows (main, publish, deploy-docs) to use NX commands - Fix missing --tag experimental on dockview-angular in publish workflow - Delete lerna.json and scripts/set-experimental-versions.js (replaced by nx release version) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
11
.github/workflows/deploy-docs.yml
vendored
11
.github/workflows/deploy-docs.yml
vendored
@@ -22,16 +22,7 @@ jobs:
|
||||
${{ runner.os }}-node-
|
||||
|
||||
- run: yarn install
|
||||
- run: npm run build
|
||||
working-directory: packages/dockview-core
|
||||
- run: npm run build
|
||||
working-directory: packages/dockview
|
||||
- run: npm run build
|
||||
working-directory: packages/dockview-vue
|
||||
- run: npm run build
|
||||
working-directory: packages/dockview-react
|
||||
- run: npm run build
|
||||
working-directory: packages/dockview-angular
|
||||
- run: npx nx run-many -t build --projects=dockview-core,dockview,dockview-vue,dockview-react,dockview-angular
|
||||
- run: npm run build
|
||||
working-directory: packages/docs
|
||||
- run: npm run docs
|
||||
|
||||
4
.github/workflows/main.yml
vendored
4
.github/workflows/main.yml
vendored
@@ -27,8 +27,8 @@ jobs:
|
||||
${{ runner.os }}-node-
|
||||
|
||||
- run: yarn
|
||||
- run: npm run build
|
||||
- run: npm run build:bundle
|
||||
- run: npx nx run-many -t build --projects=dockview-core,dockview,dockview-vue,dockview-react,dockview-angular
|
||||
- run: npx nx run-many -t build:bundle --projects=dockview-core,dockview,dockview-vue,dockview-react,dockview-angular
|
||||
- run: npm run test:cov
|
||||
- name: SonarCloud Scan
|
||||
if: env.SONAR_TOKEN != ''
|
||||
|
||||
34
.github/workflows/publish.yml
vendored
34
.github/workflows/publish.yml
vendored
@@ -29,21 +29,7 @@ jobs:
|
||||
${{ runner.os }}-node-
|
||||
|
||||
- run: yarn
|
||||
- name: Publish dockview-core
|
||||
run: npm publish --provenance
|
||||
working-directory: packages/dockview-core
|
||||
- name: Publish dockview
|
||||
run: npm publish --provenance
|
||||
working-directory: packages/dockview
|
||||
- name: Publish dockview-vue
|
||||
run: npm publish --provenance
|
||||
working-directory: packages/dockview-vue
|
||||
- name: Publish dockview-react
|
||||
run: npm publish --provenance
|
||||
working-directory: packages/dockview-react
|
||||
- name: Publish dockview-angular
|
||||
run: npm publish --provenance
|
||||
working-directory: packages/dockview-angular
|
||||
- run: npx nx release publish
|
||||
publish-experimental:
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
runs-on: ubuntu-latest
|
||||
@@ -66,19 +52,5 @@ jobs:
|
||||
${{ runner.os }}-node-
|
||||
|
||||
- run: yarn
|
||||
- run: node scripts/set-experimental-versions
|
||||
- name: Publish dockview-core
|
||||
run: npm publish --provenance --tag experimental
|
||||
working-directory: packages/dockview-core
|
||||
- name: Publish dockview
|
||||
run: npm publish --provenance --tag experimental
|
||||
working-directory: packages/dockview
|
||||
- name: Publish dockview-vue
|
||||
run: npm publish --provenance --tag experimental
|
||||
working-directory: packages/dockview-vue
|
||||
- name: Publish dockview-react
|
||||
run: npm publish --provenance --tag experimental
|
||||
working-directory: packages/dockview-react
|
||||
- name: Publish dockview-angular
|
||||
run: npm publish --provenance
|
||||
working-directory: packages/dockview-angular
|
||||
- run: npx nx release version 0.0.0-experimental-$(git rev-parse --short HEAD)-$(date +%Y%m%d) --skip-lockfile-update --git-commit=false --git-tag=false
|
||||
- run: npx nx release publish --tag experimental
|
||||
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -15,3 +15,7 @@ yarn-error.log
|
||||
/build
|
||||
/docs/
|
||||
/generated/
|
||||
|
||||
# NX
|
||||
.nx/cache
|
||||
.nx/workspace-data
|
||||
|
||||
12
lerna.json
12
lerna.json
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"packages": [
|
||||
"packages/*"
|
||||
],
|
||||
"version": "4.13.1",
|
||||
"npmClient": "yarn",
|
||||
"command": {
|
||||
"publish": {
|
||||
"message": "chore(release): publish %s"
|
||||
}
|
||||
}
|
||||
}
|
||||
59
nx.json
Normal file
59
nx.json
Normal file
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"$schema": "./node_modules/nx/schemas/nx-schema.json",
|
||||
"namedInputs": {
|
||||
"default": ["{projectRoot}/**/*", "sharedGlobals"],
|
||||
"sharedGlobals": ["{workspaceRoot}/tsconfig.base.json"],
|
||||
"production": [
|
||||
"default",
|
||||
"!{projectRoot}/src/__tests__/**/*",
|
||||
"!{projectRoot}/jest.config.ts",
|
||||
"!{projectRoot}/**/*.spec.ts",
|
||||
"!{projectRoot}/**/*.test.ts"
|
||||
]
|
||||
},
|
||||
"targetDefaults": {
|
||||
"build": {
|
||||
"dependsOn": ["^build"],
|
||||
"inputs": ["production", "^production"],
|
||||
"outputs": ["{projectRoot}/dist"],
|
||||
"cache": true
|
||||
},
|
||||
"build:bundle": {
|
||||
"dependsOn": ["build"],
|
||||
"inputs": ["production", "^production"],
|
||||
"outputs": ["{projectRoot}/dist"],
|
||||
"cache": true
|
||||
},
|
||||
"test": {
|
||||
"dependsOn": ["^build"],
|
||||
"inputs": ["default", "^production"],
|
||||
"cache": true
|
||||
},
|
||||
"clean": {
|
||||
"cache": false
|
||||
}
|
||||
},
|
||||
"release": {
|
||||
"projects": [
|
||||
"dockview-core",
|
||||
"dockview",
|
||||
"dockview-vue",
|
||||
"dockview-react",
|
||||
"dockview-angular"
|
||||
],
|
||||
"projectsRelationship": "fixed",
|
||||
"version": {
|
||||
"generatorOptions": {
|
||||
"currentVersionSource": "git-tag",
|
||||
"specifierSource": "prompt"
|
||||
}
|
||||
},
|
||||
"git": {
|
||||
"commit": true,
|
||||
"commitMessage": "chore(release): publish {version}",
|
||||
"tag": true
|
||||
}
|
||||
},
|
||||
"defaultBase": "master",
|
||||
"useInferencePlugins": false
|
||||
}
|
||||
15
package.json
15
package.json
@@ -16,15 +16,17 @@
|
||||
"packages/*"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "lerna run build --scope '{dockview-core,dockview,dockview-vue,dockview-react,dockview-angular}'",
|
||||
"build:bundle": "lerna run build:bundle --scope '{dockview-core,dockview,dockview-vue,dockview-react,dockview-angular}'",
|
||||
"clean": "lerna run clean",
|
||||
"build": "nx run-many -t build --projects=dockview-core,dockview,dockview-vue,dockview-react,dockview-angular",
|
||||
"build:bundle": "nx run-many -t build:bundle --projects=dockview-core,dockview,dockview-vue,dockview-react,dockview-angular",
|
||||
"clean": "nx run-many -t clean",
|
||||
"docs": "typedoc && node scripts/docs.mjs",
|
||||
"lint": "eslint 'packages/*/src/**/*.{ts,tsx,js,jsx}'",
|
||||
"lint:fix": "eslint 'packages/*/src/**/*.{ts,tsx,js,jsx}' --fix",
|
||||
"test": "jest --passWithNoTests",
|
||||
"test": "nx run-many -t test",
|
||||
"test:cov": "jest --coverage --passWithNoTests",
|
||||
"version": "lerna version"
|
||||
"release": "nx release",
|
||||
"release:version": "nx release version",
|
||||
"release:publish": "nx release publish"
|
||||
},
|
||||
"resolutions": {
|
||||
"@types/react": "^18.2.46",
|
||||
@@ -62,7 +64,8 @@
|
||||
"jest-environment-jsdom": "^29.7.0",
|
||||
"jest-sonar-reporter": "^2.0.0",
|
||||
"jsdom": "^23.0.1",
|
||||
"lerna": "^8.2.1",
|
||||
"nx": "^20.4.0",
|
||||
"@nx/js": "^20.4.0",
|
||||
"ng-packagr": "^17.0.0",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
const cp = require('child_process');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const rootDir = path.join(__dirname, '..');
|
||||
|
||||
function formatDate() {
|
||||
const date = new Date();
|
||||
|
||||
function pad(value) {
|
||||
if (value.toString().length === 1) {
|
||||
return `0${value}`;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
return `${date.getFullYear()}${pad(date.getMonth() + 1)}${pad(
|
||||
date.getDate()
|
||||
)}`;
|
||||
}
|
||||
|
||||
function shortGitHash() {
|
||||
return cp
|
||||
.execSync('git rev-parse --short HEAD', {
|
||||
cwd: rootDir,
|
||||
})
|
||||
.toString()
|
||||
.replace(/\n/g, '');
|
||||
}
|
||||
|
||||
const version = `0.0.0-experimental-${shortGitHash()}-${formatDate()}`;
|
||||
|
||||
// dockview-core
|
||||
|
||||
const dockviewCorePath = path.join(
|
||||
rootDir,
|
||||
'packages',
|
||||
'dockview-core',
|
||||
'package.json'
|
||||
);
|
||||
const dockviewCorePackageJson = JSON.parse(
|
||||
fs.readFileSync(dockviewCorePath).toString()
|
||||
);
|
||||
|
||||
dockviewCorePackageJson.version = version;
|
||||
|
||||
fs.writeFileSync(
|
||||
dockviewCorePath,
|
||||
JSON.stringify(dockviewCorePackageJson, null, 4)
|
||||
);
|
||||
|
||||
// dockview
|
||||
|
||||
const depPackages = ['dockview', 'dockview-vue', 'dockview-react', 'dockview-angular'];
|
||||
|
||||
for (const depPackage of depPackages) {
|
||||
const dockviewPath = path.join(
|
||||
rootDir,
|
||||
'packages',
|
||||
depPackage,
|
||||
'package.json'
|
||||
);
|
||||
const dockviewPackageJson = JSON.parse(
|
||||
fs.readFileSync(dockviewPath).toString()
|
||||
);
|
||||
|
||||
dockviewPackageJson.version = version;
|
||||
dockviewPackageJson.dependencies['dockview-core'] =
|
||||
dockviewPackageJson.version;
|
||||
|
||||
fs.writeFileSync(
|
||||
dockviewPath,
|
||||
JSON.stringify(dockviewPackageJson, null, 4)
|
||||
);
|
||||
|
||||
// sanity check
|
||||
|
||||
const dvCore = JSON.parse(fs.readFileSync(dockviewCorePath).toString());
|
||||
const dv = JSON.parse(fs.readFileSync(dockviewPath).toString());
|
||||
|
||||
console.log(`dockview-core version: ${dvCore.version}`);
|
||||
console.log(
|
||||
`${depPackage} version: ${dv.version} dockview-core dependency version: ${dv.dependencies['dockview-core']}`
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user