diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3d488efdda..3ef4ccb457 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -47,7 +47,8 @@ jobs: git commit -a -m v${{ inputs.version }} git tag v${{ inputs.version }} git show HEAD - - run: npm run build + - run: npm run build:ci + - run: npm run check - run: npm run format:check - run: npm run lint - name: check stackblitz angular lockfile diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 362ccf7c0f..ee1bb1af0f 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -17,7 +17,6 @@ jobs: registry-url: 'https://registry.npmjs.org' - run: npm ci - run: npx playwright install --with-deps - - run: npm run build code-coverage core - run: npm run build:coverage - run: npm run e2e -- --shard=${{ matrix.shard }}/${{ strategy.job-total}} - id: check_lcov diff --git a/.gitignore b/.gitignore index 0802337661..0a32b06a42 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ dist.tar.gz .nyc_output/ .idea style-bootstrap/css/ -generated \ No newline at end of file +generated +.wireit \ No newline at end of file diff --git a/angular/demo/package.json b/angular/demo/package.json index 6e824e5d9b..c8ffd15f61 100644 --- a/angular/demo/package.json +++ b/angular/demo/package.json @@ -4,13 +4,54 @@ "type": "module", "scripts": { "ng": "ng", - "dev": "ng serve", - "dev:coverage": "node --import @agnos-ui/code-coverage/interceptReadFile ../../node_modules/@angular/cli/bin/ng.js serve", - "build": "ng build", - "build:coverage": "node --import @agnos-ui/code-coverage/interceptReadFile ../../node_modules/@angular/cli/bin/ng.js build --configuration=coverage", + "dev": "wireit", + "dev:coverage": "wireit", + "build": "wireit", + "build:coverage": "wireit", "watch": "ng build --watch --configuration development", "preview": "node scripts/preview.cjs dist --port 4200 --single" }, + "wireit": { + "dev": { + "command": "ng serve", + "dependencies": [ + "../headless:generate:exports" + ], + "service": true + }, + "dev:coverage": { + "command": "node --import @agnos-ui/code-coverage/interceptReadFile ../../node_modules/@angular/cli/bin/ng.js serve", + "dependencies": [ + "../../code-coverage:build", + "../headless:generate:exports" + ], + "service": true + }, + "build": { + "command": "ng build", + "dependencies": [ + "../lib:build", + "../../style-bootstrap:build" + ], + "files": [ + "src/**", + "angular.json", + "tsconfig.json", + "webpack.cjs" + ], + "output": [ + "dist/**" + ] + }, + "build:coverage": { + "command": "node --import @agnos-ui/code-coverage/interceptReadFile ../../node_modules/@angular/cli/bin/ng.js build --configuration=coverage", + "dependencies": [ + "../lib:build", + "../../style-bootstrap:build", + "../../code-coverage:build" + ] + } + }, "dependencies": { "@agnos-ui/angular-headless": "", "@agnos-ui/angular": "", diff --git a/angular/headless/package.json b/angular/headless/package.json index 9ffc538350..3ecfd91bae 100644 --- a/angular/headless/package.json +++ b/angular/headless/package.json @@ -12,14 +12,79 @@ }, "scripts": { "ng": "ng", - "build": "run-s generate:exports build:*", - "generate:exports": "node ../../scripts/generateExports.js angular/headless core @agnos-ui/core", - "build:src": "ng build", - "build:pkg": "node ../../scripts/buildPackageJson.js dist dist .", + "build": "wireit", "test": "vitest run", "tdd": "vitest", "tdd:ui": "vitest --ui", - "test:coverage": "node --import @agnos-ui/code-coverage/interceptReadFile ../../node_modules/vitest/vitest.mjs run --coverage" + "test:coverage": "wireit" + }, + "wireit": { + "generate:exports": { + "command": "node ../../scripts/generateExports.js angular/headless core @agnos-ui/core", + "files": [ + "src/**", + "../../core/src/**", + "!src/generated/**", + "../../scripts/generateExports.js" + ], + "output": [ + "src/generated/**" + ] + }, + "build:src": { + "command": "ng build", + "dependencies": [ + "generate:exports", + "../../core:build" + ], + "files": [ + "src/**", + "!src/generated/**", + "tsconfig.json", + "angular.json", + "ng-package.json" + ], + "output": [ + "dist/**", + "!dist/README.md", + "!dist/package.json" + ] + }, + "build:pkg": { + "command": "node ../../scripts/buildPackageJson.js . dist", + "dependencies": [ + "build:src" + ], + "files": [ + "../../scripts/buildPackageJson.js", + "package.json", + "README.md" + ], + "output": [ + "dist/README.md", + "dist/package.json" + ] + }, + "build": { + "dependencies": [ + "build:pkg" + ] + }, + "test:coverage": { + "command": "node --import @agnos-ui/code-coverage/interceptReadFile ../../node_modules/vitest/vitest.mjs run --coverage", + "dependencies": [ + "../../code-coverage:build" + ], + "files": [ + "src/**", + "!src/generated/**", + "tsconfig.spec.json", + "vitest.config.ts" + ], + "output": [ + "coverage" + ] + } }, "peerDependencies": { "@angular/common": "*", diff --git a/angular/lib/package.json b/angular/lib/package.json index 696c1c4c0e..0f20608f2e 100644 --- a/angular/lib/package.json +++ b/angular/lib/package.json @@ -12,7 +12,47 @@ }, "scripts": { "ng": "ng", - "build": "ng build && node ../../scripts/buildPackageJson.js dist dist ." + "build": "wireit" + }, + "wireit": { + "build:src": { + "command": "ng build", + "dependencies": [ + "../headless:build" + ], + "files": [ + "src/**", + "!src/generated/**", + "tsconfig.json", + "angular.json", + "ng-package.json" + ], + "output": [ + "dist/**", + "!dist/README.md", + "!dist/package.json" + ] + }, + "build:pkg": { + "command": "node ../../scripts/buildPackageJson.js . dist", + "dependencies": [ + "build:src" + ], + "files": [ + "../../scripts/buildPackageJson.js", + "package.json", + "README.md" + ], + "output": [ + "dist/README.md", + "dist/package.json" + ] + }, + "build": { + "dependencies": [ + "build:pkg" + ] + } }, "peerDependencies": { "@angular/common": "*", diff --git a/base-po/package.json b/base-po/package.json index 4e63b62bbe..4a7989acba 100644 --- a/base-po/package.json +++ b/base-po/package.json @@ -11,10 +11,46 @@ "module": "dist/lib/index.mjs", "types": "dist/lib/index.d.ts", "scripts": { - "build": "npm run build:rollup && npm run build:dts && npm run build:api-extractor", - "build:rollup": "tsc && vite build", - "build:dts": "tsc -p tsconfig.d.json", - "build:api-extractor": "api-extractor run" + "build": "wireit" + }, + "wireit": { + "build:src": { + "command": "vite build", + "files": [ + "lib/**", + "vite.config.ts" + ], + "output": [ + "dist/lib/index.js", + "dist/lib/index.mjs" + ] + }, + "build:dts": { + "command": "tsc -p tsconfig.d.json", + "files": [ + "lib/**", + "tsconfig.json", + "tsconfig.d.json" + ], + "output": [ + "dist/dts/**" + ] + }, + "build": { + "command": "api-extractor run", + "dependencies": [ + "build:src", + "build:dts" + ], + "files": [ + "lib/**", + "tsconfig.json", + "tsconfig.d.json" + ], + "output": [ + "dist/lib/index.d.ts" + ] + } }, "peerDependencies": { "@playwright/test": "*" diff --git a/code-coverage/lib/filter.ts b/code-coverage/lib/filter.ts index e53ecd2a35..46c0d0cc2f 100644 --- a/code-coverage/lib/filter.ts +++ b/code-coverage/lib/filter.ts @@ -7,7 +7,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url)); export const rootFolder = path.join(__dirname, '..', '..', '..'); export const filter = createFilter( - ['core/**/*', 'angular/{headless,lib}/src/**/*', 'react/{headless,lib}/**/*', 'svelte/{headless,lib}/**/*'], + ['core/src/**/*', 'angular/{headless,lib}/src/**/*', 'react/{headless,lib}/src/**/*', 'svelte/{headless,lib}/src/**/*'], ['node_modules', '**/*.spec.ts', '**/__mocks__/**'], { resolve: rootFolder, diff --git a/code-coverage/package.json b/code-coverage/package.json index f0faa80b26..756629e36f 100644 --- a/code-coverage/package.json +++ b/code-coverage/package.json @@ -17,9 +17,21 @@ "vite": "^5.0.11" }, "scripts": { - "build": "npm run build:rollup && npm run build:dts", - "build:rollup": "tsc && vite build", - "build:dts": "tsc -p tsconfig.d.json" + "build": "wireit" + }, + "wireit": { + "build": { + "command": "vite build && tsc -p tsconfig.d.json", + "files": [ + "lib/**", + "tsconfig.json", + "tsconfig.d.json", + "vite.config.ts" + ], + "output": [ + "dist/**" + ] + } }, "type": "module", "exports": { diff --git a/core/package.json b/core/package.json index ed47313ea5..88e1f85204 100644 --- a/core/package.json +++ b/core/package.json @@ -40,16 +40,88 @@ } }, "scripts": { - "build": "run-s clean:dist build:*", - "clean:dist": "node ../scripts/rm.js dist", - "build:src": "tsc", - "build:pkg": "node ../scripts/buildPackageJson.js . dist", - "build:api-extractor": "api-extractor run", - "check:tests": "tsc -p tsconfig.tests.json", - "test": "npm run check:tests && vitest run", + "build": "wireit", + "build:src": "wireit", + "build:pkg": "wireit", + "check": "wireit", + "check:api-extractor": "wireit", + "check:tests": "wireit", + "test": "vitest run", "tdd": "vitest", "tdd:ui": "vitest --ui", - "test:coverage": "node --import @agnos-ui/code-coverage/interceptReadFile ../node_modules/vitest/vitest.mjs run --coverage" + "test:coverage": "wireit" + }, + "wireit": { + "build:src": { + "command": "tsc", + "files": [ + "src/**", + "tsconfig.json" + ], + "output": [ + "dist/**", + "!dist/package.json", + "!dist/README.md" + ] + }, + "build:pkg": { + "command": "node ../scripts/buildPackageJson.js . dist", + "files": [ + "package.json", + "README.md", + "../scripts/buildPackageJson.js" + ], + "output": [ + "dist/package.json", + "dist/README.md" + ] + }, + "build": { + "dependencies": [ + "build:src", + "build:pkg" + ] + }, + "check:api-extractor": { + "command": "api-extractor run", + "dependencies": [ + "build:src" + ], + "files": [ + "src/**", + "tsconfig.json" + ], + "output": [] + }, + "check:tests": { + "command": "tsc -p tsconfig.tests.json", + "files": [ + "src/**", + "tsconfig.tests.json", + "vitest.config.ts" + ], + "output": [] + }, + "check": { + "dependencies": [ + "check:api-extractor", + "check:tests" + ] + }, + "test:coverage": { + "command": "node --import @agnos-ui/code-coverage/interceptReadFile ../node_modules/vitest/vitest.mjs run --coverage", + "dependencies": [ + "../code-coverage:build" + ], + "files": [ + "src/**", + "tsconfig.tests.json", + "vitest.config.ts" + ], + "output": [ + "coverage/**" + ] + } }, "dependencies": { "@amadeus-it-group/tansu": "0.0.24" diff --git a/demo/package.json b/demo/package.json index c5b9f570db..b9188360bc 100644 --- a/demo/package.json +++ b/demo/package.json @@ -3,13 +3,76 @@ "private": true, "type": "module", "scripts": { - "dev": "npm run generate:doc && vite dev", - "build": "npm run generate:doc && npm run build:demo && npm run svelte-check", - "build:coverage": "npm run generate:doc && npm run build:demo", - "build:demo": "vite build", - "generate:doc": "ts-node --project ../scripts/doc/tsconfig.json ../scripts/doc/generate-docs.ts", + "dev": "wireit", + "build": "wireit", + "generate:doc": "wireit", + "build:coverage": "wireit", "preview": "vite preview", - "svelte-check": "svelte-check" + "check": "wireit" + }, + "wireit": { + "generate:doc": { + "command": "ts-node --project ../scripts/doc/tsconfig.json ../scripts/doc/generate-docs.ts", + "files": [ + "../core/src/**", + "../scripts/doc/tsconfig.json", + "../scripts/doc/generate-docs.ts" + ], + "output": [ + "generated/**" + ] + }, + "dev": { + "command": "vite dev", + "dependencies": [ + "generate:doc", + "../angular/demo:dev", + "../react/demo:dev", + "../svelte/demo:dev" + ], + "service": true + }, + "build": { + "command": "vite build", + "dependencies": [ + "generate:doc", + "../angular/demo:build", + "../react/demo:build", + "../svelte/demo:build" + ], + "files": [ + "src/**", + "static/**", + "svelte.config.js", + "vite.config.ts", + "vite-env.d.ts", + "tsconfig.json", + "tsconfig.sw.json" + ], + "output": [ + "dist/**", + ".svelte-kit/**" + ] + }, + "build:coverage": { + "command": "vite build", + "dependencies": [ + "generate:doc", + "../angular/demo:build:coverage", + "../react/demo:build:coverage", + "../svelte/demo:build:coverage" + ] + }, + "check": { + "command": "svelte-check", + "dependencies": [ + "build" + ], + "files": [ + "src/**" + ], + "output": [] + } }, "dependencies": { "@floating-ui/dom": "^1.5.4", diff --git a/eslint-plugin/package.json b/eslint-plugin/package.json index f4573af6d7..ec6d3994ef 100644 --- a/eslint-plugin/package.json +++ b/eslint-plugin/package.json @@ -17,10 +17,44 @@ "svelte-eslint-parser": "^0.33.1" }, "scripts": { - "build": "tsc && vite build", + "build": "wireit", + "check": "wireit", "tdd": "vitest", "tdd:ui": "vitest --ui", "test": "vitest run", - "test:coverage": "vitest run --coverage" + "test:coverage": "wireit" + }, + "wireit": { + "build": { + "command": "vite build", + "files": [ + "src/**", + "vite.config.ts" + ], + "output": [ + "dist/**" + ] + }, + "check": { + "command": "tsc", + "files": [ + "src/**", + "tsconfig.json", + "vite.config.ts", + "vitest.config.ts" + ], + "output": [] + }, + "test:coverage": { + "command": "vitest run --coverage", + "files": [ + "src/**", + "test/**", + "vitest.config.ts" + ], + "output": [ + "coverage/**" + ] + } } } diff --git a/package-lock.json b/package-lock.json index 96612ac8c3..7335a9a527 100644 --- a/package-lock.json +++ b/package-lock.json @@ -48,7 +48,8 @@ "ts-node": "^10.9.2", "typescript": "~5.2.2", "vite": "^5.0.11", - "vitest": "^1.2.0" + "vitest": "^1.2.0", + "wireit": "^0.14.3" }, "engines": { "node": "^20.11.0", @@ -16107,6 +16108,23 @@ "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", "dev": true }, + "node_modules/proper-lockfile": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/proper-lockfile/-/proper-lockfile-4.1.2.tgz", + "integrity": "sha512-TjNPblN4BwAWMXU8s9AEz4JmQxnD1NNL7bNOY/AKUzyamc379FWASUhc/K1pL2noVb+XmZKLL68cjzLsiOAMaA==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.4", + "retry": "^0.12.0", + "signal-exit": "^3.0.2" + } + }, + "node_modules/proper-lockfile/node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true + }, "node_modules/proxy-addr": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", @@ -20058,6 +20076,25 @@ "integrity": "sha512-CC1bOL87PIWSBhDcTrdeLo6eGT7mCFtrg0uIJtqJUFyK+eJnzl8A1niH56uu7KMa5XFrtiV+AQuHO3n7DsHnLQ==", "dev": true }, + "node_modules/wireit": { + "version": "0.14.3", + "resolved": "https://registry.npmjs.org/wireit/-/wireit-0.14.3.tgz", + "integrity": "sha512-vNSzIBJ1YLMM6dzGUiUMw11KmHOFiXIaOHcQPWVT4j5oCaXQSIYS5AExEzRkAAlm5F0hRPTwDUoazUHu5ZLCNQ==", + "dev": true, + "dependencies": { + "braces": "^3.0.2", + "chokidar": "^3.5.3", + "fast-glob": "^3.2.11", + "jsonc-parser": "^3.0.0", + "proper-lockfile": "^4.1.2" + }, + "bin": { + "wireit": "bin/wireit.js" + }, + "engines": { + "node": ">=14.14.0" + } + }, "node_modules/wrap-ansi": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", diff --git a/package.json b/package.json index 242bf15e20..39f3f6431c 100644 --- a/package.json +++ b/package.json @@ -47,32 +47,84 @@ "ts-node": "^10.9.2", "typescript": "~5.2.2", "vite": "^5.0.11", - "vitest": "^1.2.0" + "vitest": "^1.2.0", + "wireit": "^0.14.3" }, "scripts": { - "build:coverage": "node scripts/run.js build:coverage serial", + "build:coverage": "wireit", "build": "node scripts/run.js build serial", - "build:rollup": "node scripts/run.js build:rollup serial", - "build:demo": "node scripts/run.js build:demo serial", - "build:dts": "node scripts/run.js build:dts serial", - "build:api-extractor": "node scripts/run.js build:api-extractor serial", + "build:ci": "wireit", + "check": "wireit", "tdd": "node scripts/run.js tdd", "tdd:ui": "node scripts/run.js tdd:ui", "test:coverage": "node scripts/run.js test:coverage", "test": "node scripts/run.js test serial", "format:fix": "prettier . \"**/*.svelte\" --write --cache .", "format:check": "prettier . \"**/*.svelte\" --check --cache .", - "lint": "eslint --ext ts,tsx,svelte .", + "lint": "wireit", "dev": "node scripts/run.js dev", "dev:coverage": "node scripts/run.js dev:coverage", "preview": "node scripts/run.js preview", - "e2e": "node scripts/e2e.js", - "e2e:ui": "playwright test --ui", + "e2e": "wireit", + "e2e:ui": "wireit", "postinstall": "husky install", "syncpack:check": "syncpack lint", "syncpack:fix": "syncpack fix-mismatches", - "generate:exports": "node scripts/run.js generate:exports serial", - "prepare": "npm run generate:exports" + "prepare": "wireit" + }, + "wireit": { + "build:ci": { + "dependencies": [ + "./code-coverage:build", + "./demo:build", + "./eslint-plugin:build", + "./page-objects:build" + ] + }, + "build:coverage": { + "dependencies": [ + "./demo:build:coverage" + ] + }, + "e2e": { + "command": "node scripts/e2e.js", + "dependencies": [ + "./code-coverage:build" + ] + }, + "e2e:ui": { + "command": "playwright test --ui", + "dependencies": [ + "./code-coverage:build" + ] + }, + "prepare": { + "dependencies": [ + "./angular/headless:generate:exports", + "./react/headless:generate:exports", + "./react/lib:generate:exports", + "./svelte/headless:generate:exports", + "./svelte/lib:generate:exports" + ] + }, + "check": { + "dependencies": [ + "./core:check", + "./eslint-plugin:check", + "./react/demo:check", + "./svelte/headless:check", + "./svelte/lib:check", + "./svelte/demo:check", + "./demo:check" + ] + }, + "lint": { + "command": "eslint --ext ts,tsx,svelte .", + "dependencies": [ + "./eslint-plugin:build", + "./svelte/lib:build" + ] + } }, "workspaces": [ "code-coverage", diff --git a/page-objects/package.json b/page-objects/package.json index 8d00ad9f28..302ab2b39f 100644 --- a/page-objects/package.json +++ b/page-objects/package.json @@ -12,12 +12,54 @@ ], "main": "dist/lib/index.js", "module": "dist/lib/index.mjs", - "types": "dist/lib/index.d.ts", + "types": "dist/dts/index.d.ts", "scripts": { - "build": "npm run build:rollup && npm run build:dts && npm run build:api-extractor", - "build:rollup": "tsc && vite build", - "build:dts": "tsc -p tsconfig.d.json", - "build:api-extractor": "api-extractor run" + "build": "wireit" + }, + "wireit": { + "build:src": { + "command": "vite build", + "dependencies": [ + "../base-po:build" + ], + "files": [ + "lib/**", + "vite.config.ts" + ], + "output": [ + "dist/lib/index.js", + "dist/lib/index.mjs" + ] + }, + "build:dts": { + "command": "tsc -p tsconfig.d.json", + "dependencies": [ + "../base-po:build" + ], + "files": [ + "lib/**", + "tsconfig.json", + "tsconfig.d.json" + ], + "output": [ + "dist/dts/**" + ] + }, + "build": { + "command": "api-extractor run", + "dependencies": [ + "build:src", + "build:dts" + ], + "files": [ + "lib/**", + "tsconfig.json", + "tsconfig.d.json" + ], + "output": [ + "dist/lib/index.d.ts" + ] + } }, "dependencies": { "@agnos-ui/base-po": "" diff --git a/react/demo/package.json b/react/demo/package.json index 5d6a7e1542..3d5d7be5d4 100644 --- a/react/demo/package.json +++ b/react/demo/package.json @@ -2,14 +2,67 @@ "name": "@agnos-ui/react-demo", "private": true, "scripts": { - "dev": "vite", - "dev:coverage": "vite -c vite.coverage.config.ts", - "build:coverage": "vite build -c vite.coverage.config.ts", - "build": "run-s build:demo check:types", - "build:demo": "vite build", - "check:types": "tsc", + "dev": "wireit", + "dev:coverage": "wireit", + "build:coverage": "wireit", + "build": "wireit", + "check": "wireit", "preview": "vite preview" }, + "wireit": { + "dev": { + "command": "vite", + "dependencies": [ + "../lib:generate:exports", + "../headless:generate:exports" + ], + "service": true + }, + "dev:coverage": { + "command": "vite -c vite.coverage.config.ts", + "dependencies": [ + "../../code-coverage:build", + "../lib:generate:exports", + "../headless:generate:exports" + ], + "service": true + }, + "build": { + "command": "vite build", + "dependencies": [ + "../lib:build", + "../../style-bootstrap:build" + ], + "files": [ + "src/**", + "tsconfig.json", + "vite.config.ts" + ], + "output": [ + "dist/**" + ] + }, + "build:coverage": { + "command": "vite build -c vite.coverage.config.ts", + "dependencies": [ + "../../code-coverage:build", + "../../style-bootstrap:build", + "../lib:generate:exports", + "../headless:generate:exports" + ] + }, + "check": { + "command": "tsc", + "files": [ + "src/**", + "tsconfig.json" + ], + "output": [], + "dependencies": [ + "../lib:build" + ] + } + }, "devDependencies": { "@types/react": "^18.2.47", "@types/react-dom": "^18.2.18", diff --git a/react/demo/vite.config.ts b/react/demo/vite.config.ts index 087e8599bf..9c9386829a 100644 --- a/react/demo/vite.config.ts +++ b/react/demo/vite.config.ts @@ -9,6 +9,7 @@ export default defineConfig((config) => ({ base: config.command === 'serve' ? '/react/samples' : './', server: { port: 3000, + strictPort: true, }, build: { emptyOutDir: true, diff --git a/react/headless/package.json b/react/headless/package.json index aee95b4dd7..7e4eab00fb 100644 --- a/react/headless/package.json +++ b/react/headless/package.json @@ -40,11 +40,56 @@ } }, "scripts": { - "build": "run-s clean:dist generate:exports build:*", - "clean:dist": "node ../../scripts/rm dist", - "generate:exports": "node ../../scripts/generateExports.js react/headless core @agnos-ui/core", - "build:src": "tsc", - "build:pkg": "node ../../scripts/buildPackageJson . dist" + "build": "wireit" + }, + "wireit": { + "generate:exports": { + "command": "node ../../scripts/generateExports.js react/headless core @agnos-ui/core", + "files": [ + "src/**", + "../../core/src/**", + "!src/generated/**", + "../../scripts/generateExports.js" + ], + "output": [ + "src/generated/**" + ] + }, + "build:src": { + "command": "tsc", + "dependencies": [ + "generate:exports", + "../../core:build" + ], + "files": [ + "src/**", + "!src/generated/**", + "tsconfig.json" + ], + "output": [ + "dist/**", + "!dist/README.md", + "!dist/package.json" + ] + }, + "build:pkg": { + "command": "node ../../scripts/buildPackageJson.js . dist", + "files": [ + "../../scripts/buildPackageJson.js", + "package.json", + "README.md" + ], + "output": [ + "dist/README.md", + "dist/package.json" + ] + }, + "build": { + "dependencies": [ + "build:src", + "build:pkg" + ] + } }, "dependencies": { "@agnos-ui/core": "", diff --git a/react/lib/package.json b/react/lib/package.json index df9c190043..6b49f663b1 100644 --- a/react/lib/package.json +++ b/react/lib/package.json @@ -40,11 +40,58 @@ } }, "scripts": { - "build": "run-s clean:dist generate:exports build:*", - "clean:dist": "node ../../scripts/rm.js dist", - "generate:exports": "node ../../scripts/generateExports.js react/lib react/headless @agnos-ui/react-headless", - "build:src": "tsc", - "build:pkg": "node ../../scripts/buildPackageJson.js . dist" + "build": "wireit" + }, + "wireit": { + "generate:exports": { + "command": "node ../../scripts/generateExports.js react/lib react/headless @agnos-ui/react-headless", + "dependencies": [ + "../headless:generate:exports" + ], + "files": [ + "src/**", + "!src/generated/**", + "../../scripts/generateExports.js" + ], + "output": [ + "src/generated/**" + ] + }, + "build:src": { + "command": "tsc", + "dependencies": [ + "generate:exports", + "../headless:build" + ], + "files": [ + "src/**", + "!src/generated/**", + "tsconfig.json" + ], + "output": [ + "dist/**", + "!dist/README.md", + "!dist/package.json" + ] + }, + "build:pkg": { + "command": "node ../../scripts/buildPackageJson.js . dist", + "files": [ + "../../scripts/buildPackageJson.js", + "package.json", + "README.md" + ], + "output": [ + "dist/README.md", + "dist/package.json" + ] + }, + "build": { + "dependencies": [ + "build:src", + "build:pkg" + ] + } }, "dependencies": { "@agnos-ui/react-headless": "", diff --git a/scripts/buildPackageJson.js b/scripts/buildPackageJson.js index 7fe3f813e2..f3fb5c1d22 100644 --- a/scripts/buildPackageJson.js +++ b/scripts/buildPackageJson.js @@ -1,11 +1,10 @@ -const {writeFileSync, cpSync, existsSync} = require('fs'); +const {writeFileSync, cpSync, existsSync, mkdirSync} = require('fs'); const path = require('path'); -let [, , sourceFolder, outputFolder, repositoryDirectory] = process.argv; +let [, , sourceFolder, outputFolder] = process.argv; sourceFolder = path.resolve(sourceFolder); outputFolder = path.resolve(outputFolder); -repositoryDirectory = repositoryDirectory != null ? path.resolve(repositoryDirectory) : sourceFolder; const rootPath = path.join(__dirname, '..'); const rootPackage = require('../package.json'); @@ -17,7 +16,7 @@ const pkg = { }; const packageName = sourcePackage.name; -const directory = path.posix.relative(rootPath, repositoryDirectory); +const directory = path.posix.relative(rootPath, sourceFolder); const frameworkName = directory.split('/')[0]; const isCore = frameworkName === 'core'; const isHeadless = isCore || packageName.endsWith('-headless'); @@ -39,6 +38,7 @@ pkg.keywords.push(...rootPackage.keywords); pkg.repository.directory = directory; delete pkg.private; delete pkg.scripts; +delete pkg.wireit; delete pkg.devDependencies; const cleanObjDistPrefix = (obj, ...keys) => { @@ -58,12 +58,14 @@ if (pkg.exports) { } } +mkdirSync(outputFolder, {recursive: true}); + const packageJsonOutputFile = path.join(outputFolder, 'package.json'); console.log(`Writing ${packageJsonOutputFile}`); writeFileSync(packageJsonOutputFile, JSON.stringify(pkg, null, '\t')); -// Copy README.md from repositoryDirectory +// Copy README.md from sourceFolder const readmeOutputFile = path.join(outputFolder, 'README.md'); -const readmeSourceFile = path.join(repositoryDirectory, 'README.md'); +const readmeSourceFile = path.join(sourceFolder, 'README.md'); console.log(`Copying ${readmeSourceFile} to ${readmeOutputFile}`); cpSync(readmeSourceFile, readmeOutputFile); diff --git a/style-bootstrap/package.json b/style-bootstrap/package.json index 8ea179b342..8940478f77 100644 --- a/style-bootstrap/package.json +++ b/style-bootstrap/package.json @@ -8,7 +8,18 @@ "css" ], "scripts": { - "build": "sass scss/agnosui.scss css/agnosui.css" + "build": "wireit" + }, + "wireit": { + "build": { + "command": "sass scss/agnosui.scss css/agnosui.css", + "files": [ + "scss" + ], + "output": [ + "css" + ] + } }, "files": [ "scss", diff --git a/svelte/demo/package.json b/svelte/demo/package.json index 01785f4303..1932916b90 100644 --- a/svelte/demo/package.json +++ b/svelte/demo/package.json @@ -3,13 +3,66 @@ "type": "module", "private": true, "scripts": { - "dev": "vite", - "dev:coverage": "vite -c vite.coverage.config.ts", - "build": "run-s build:demo check:svelte", - "build:coverage": "vite build -c vite.coverage.config.ts", - "build:demo": "vite build", + "dev": "wireit", + "dev:coverage": "wireit", + "build": "wireit", + "build:coverage": "wireit", "preview": "vite preview", - "check:svelte": "svelte-check --fail-on-warnings --output human-verbose" + "check": "wireit" + }, + "wireit": { + "dev": { + "command": "vite", + "service": true, + "dependencies": [ + "../lib:generate:exports", + "../headless:generate:exports" + ] + }, + "dev:coverage": { + "command": "vite -c vite.coverage.config.ts", + "service": true, + "dependencies": [ + "../../code-coverage:build", + "../lib:generate:exports", + "../headless:generate:exports" + ] + }, + "build": { + "command": "vite build", + "dependencies": [ + "../lib:build", + "../../style-bootstrap:build" + ], + "files": [ + "src/**", + "tsconfig.json", + "vite.config.ts" + ], + "output": [ + "dist/**" + ] + }, + "build:coverage": { + "command": "vite build -c vite.coverage.config.ts", + "dependencies": [ + "../../code-coverage:build", + "../../style-bootstrap:build", + "../lib:generate:exports", + "../headless:generate:exports" + ] + }, + "check": { + "command": "svelte-check --fail-on-warnings --output human-verbose", + "dependencies": [ + "../lib:build" + ], + "files": [ + "src/**", + "tsconfig.json" + ], + "output": [] + } }, "dependencies": { "@amadeus-it-group/tansu": "0.0.24", diff --git a/svelte/demo/vite.config.ts b/svelte/demo/vite.config.ts index ff7ec89a9c..f177f29b7d 100644 --- a/svelte/demo/vite.config.ts +++ b/svelte/demo/vite.config.ts @@ -9,6 +9,7 @@ export default defineConfig((config) => ({ base: config.command === 'serve' ? '/svelte/samples' : './', server: { port: 3001, + strictPort: true, }, build: { emptyOutDir: true, diff --git a/svelte/headless/package.json b/svelte/headless/package.json index 044d9f6ffa..ce0057e5e6 100644 --- a/svelte/headless/package.json +++ b/svelte/headless/package.json @@ -49,11 +49,72 @@ } }, "scripts": { - "build": "run-s generate:exports build:* check:svelte", - "generate:exports": "node ../../scripts/generateExports.js svelte/headless core @agnos-ui/core", - "build:src": "svelte-package -i src", - "build:pkg": "node ../../scripts/buildPackageJson.js . dist", - "check:svelte": "svelte-check --fail-on-warnings --output human-verbose" + "build": "wireit", + "check": "wireit" + }, + "wireit": { + "generate:exports": { + "command": "node ../../scripts/generateExports.js svelte/headless core @agnos-ui/core", + "files": [ + "src/**", + "../../core/src/**", + "!src/generated/**", + "../../scripts/generateExports.js" + ], + "output": [ + "src/generated/**" + ] + }, + "build:src": { + "command": "svelte-package -i src", + "dependencies": [ + "generate:exports", + "../../core:build" + ], + "files": [ + "src/**", + "!src/generated/**", + "tsconfig.json" + ], + "output": [ + "dist/**", + ".svelte-kit/**", + "!dist/README.md", + "!dist/package.json" + ] + }, + "build:pkg": { + "command": "node ../../scripts/buildPackageJson.js . dist", + "dependencies": [ + "build:src" + ], + "files": [ + "../../scripts/buildPackageJson.js", + "package.json", + "README.md" + ], + "output": [ + "dist/README.md", + "dist/package.json" + ] + }, + "build": { + "dependencies": [ + "build:pkg" + ] + }, + "check": { + "command": "svelte-check --fail-on-warnings --output human-verbose", + "dependencies": [ + "generate:exports", + "../../core:build" + ], + "files": [ + "src/**", + "tsconfig.json" + ], + "output": [] + } }, "dependencies": { "@agnos-ui/core": "", diff --git a/svelte/lib/package.json b/svelte/lib/package.json index 82d5a6b3c4..d4f5ead34a 100644 --- a/svelte/lib/package.json +++ b/svelte/lib/package.json @@ -49,11 +49,71 @@ } }, "scripts": { - "build": "run-s generate:exports build:* check:svelte", - "generate:exports": "node ../../scripts/generateExports.js svelte/lib svelte/headless @agnos-ui/svelte-headless", - "build:src": "svelte-package -i src", - "build:pkg": "node ../../scripts/buildPackageJson.js . dist", - "check:svelte": "svelte-check --fail-on-warnings --output human-verbose" + "build": "wireit", + "check": "wireit" + }, + "wireit": { + "generate:exports": { + "command": "node ../../scripts/generateExports.js svelte/lib svelte/headless @agnos-ui/svelte-headless", + "dependencies": [ + "../headless:generate:exports" + ], + "files": [ + "src/**", + "!src/generated/**", + "../../scripts/generateExports.js" + ], + "output": [ + "src/generated/**" + ] + }, + "build:src": { + "command": "svelte-package -i src", + "dependencies": [ + "generate:exports", + "../headless:build" + ], + "files": [ + "src/**", + "!src/generated/**", + "tsconfig.json" + ], + "output": [ + "dist/**", + "!dist/README.md", + "!dist/package.json" + ] + }, + "build:pkg": { + "command": "node ../../scripts/buildPackageJson.js . dist", + "files": [ + "../../scripts/buildPackageJson.js", + "package.json", + "README.md" + ], + "output": [ + "dist/README.md", + "dist/package.json" + ] + }, + "build": { + "dependencies": [ + "build:src", + "build:pkg" + ] + }, + "check": { + "command": "svelte-check --fail-on-warnings --output human-verbose", + "dependencies": [ + "generate:exports", + "../headless:build" + ], + "files": [ + "src/**", + "tsconfig.json" + ], + "output": [] + } }, "dependencies": { "@agnos-ui/style-bootstrap": "",