diff --git a/.vscode/launch.json b/.vscode/launch.json index 743eeae1d54bd..38e7fcbfa7767 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,7 +5,7 @@ "name": "Debug test", "type": "node", "request": "launch", - "program": "${workspaceRoot}/scripts/debug-test.js", + "program": "${workspaceRoot}/scripts/executors/debug-test.js", "cwd": "${fileDirname}", "stopOnEntry": false, "args": ["-i", "--watch"], @@ -22,7 +22,7 @@ "name": "Debug current open test", "type": "node", "request": "launch", - "program": "${workspaceRoot}/scripts/debug-test.js", + "program": "${workspaceRoot}/scripts/executors/debug-test.js", "cwd": "${fileDirname}", "stopOnEntry": false, "args": ["-i", "--testPathPattern=\\b${fileBasenameNoExtension}", "--watch"], @@ -39,7 +39,7 @@ "name": "Debug current open test (v0)", "type": "node", "request": "launch", - "program": "${workspaceRoot}/scripts/debug-test.js", + "program": "${workspaceRoot}/scripts/executors/debug-test.js", "cwd": "${fileDirname}", "stopOnEntry": false, "args": ["-i", "--testPathPattern=\\b${fileBasenameNoExtension}", "--watch"], diff --git a/azure-pipelines.release.yml b/azure-pipelines.release.yml index 47f50182d20d7..7bc8f88f78cb0 100644 --- a/azure-pipelines.release.yml +++ b/azure-pipelines.release.yml @@ -152,7 +152,7 @@ jobs: displayName: 'Publish artifact: homepage.htm' - script: | - node ./scripts/generate-package-manifest + node ./scripts/generators/generate-package-manifest displayName: 'Generate package manifest' - task: PublishBuildArtifacts@1 diff --git a/change/@fluentui-react-6516ce43-5bb4-4fac-8534-ef209de37f83.json b/change/@fluentui-react-6516ce43-5bb4-4fac-8534-ef209de37f83.json new file mode 100644 index 0000000000000..78bb0d242f527 --- /dev/null +++ b/change/@fluentui-react-6516ce43-5bb4-4fac-8534-ef209de37f83.json @@ -0,0 +1,7 @@ +{ + "type": "none", + "comment": "chore: update codepen scripts task alias path", + "packageName": "@fluentui/react", + "email": "martinhochel@microsoft.com", + "dependentChangeType": "none" +} diff --git a/change/@fluentui-react-theme-c86075f4-816b-4c40-b769-07857ec5c36b.json b/change/@fluentui-react-theme-c86075f4-816b-4c40-b769-07857ec5c36b.json new file mode 100644 index 0000000000000..47f2e859d151a --- /dev/null +++ b/change/@fluentui-react-theme-c86075f4-816b-4c40-b769-07857ec5c36b.json @@ -0,0 +1,7 @@ +{ + "type": "none", + "comment": "chore: update token-pipeline scripts task alias path", + "packageName": "@fluentui/react-theme", + "email": "martinhochel@microsoft.com", + "dependentChangeType": "none" +} diff --git a/package.json b/package.json index eed7465219814..a3211185977ef 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "buildto": "lage build --verbose --to", "buildto:lerna": "node ./scripts/monorepo/buildTo.js", "bundle": "lage bundle --verbose", - "bundlesizecollect": "node ./scripts/bundle-size-collect", + "bundlesizecollect": "node ./scripts/generators/bundle-size-collect", "change": "beachball change --no-commit", "check:change": "beachball check", "check:modified-files": "yarn workspace @fluentui/scripts just check-for-modified-files", @@ -27,12 +27,12 @@ "check:installed-dependencies-versions": "satisfied --skip-invalid --ignore \"prettier|angular|lit|sass|@storybook/html|@storybook/mdx2-csf|svelte|@testing-library|vue|@cypress/react|cypress|@swc/wasm|@cactuslab/usepubsub\"", "clean": "lage clean --verbose", "code-style": "lage code-style --verbose", - "codepen": "cd packages/react && node ../../scripts/local-codepen.js", - "copy-notices": "node scripts/copy-notices.js", - "create-component": "plop --plopfile ./scripts/create-component/create-component.ts --dest . --require ./scripts/ts-node-register", - "create-package": "plop --plopfile ./scripts/create-package/plopfile.ts --dest . --require ./scripts/ts-node-register", + "codepen": "cd packages/react && node ../../scripts/executors/local-codepen.js", + "copy-notices": "node scripts/generators/copy-notices.js", + "create-component": "plop --plopfile ./scripts/generators/create-component/index.ts --dest . --require ./scripts/ts-node-register", + "create-package": "plop --plopfile ./scripts/generators/create-package/index.ts --dest . --require ./scripts/ts-node-register", "e2e": "lage e2e --verbose --concurrency=1", - "format": "node scripts/format.js", + "format": "node scripts/executors/format.js", "generate-version-files": "yarn workspace @fluentui/scripts just generate-version-files", "graph": "node ./scripts/dependency-graph-generator/index.js", "lint": "lage lint --verbose", @@ -40,20 +40,20 @@ "lint:log:lerna": "FORCE_COLOR=0 lerna run lint --stream --no-bail > lint.log 2>&1", "perf": "cross-env PERF=true gulp perf --times=100", "perf:debug": "cross-env PERF=true gulp perf:debug --debug", - "postinstall": "node ./scripts/postinstall.js", - "preinstall": "node ./scripts/use-yarn-please.js", + "postinstall": "node ./scripts/package-manager/postinstall.js", + "preinstall": "node ./scripts/package-manager/use-yarn-please.js", "publish:beachball": "beachball publish -b origin/master --access public -y", - "rebuild": "node ./scripts/invalidate-just-cache.js && yarn build --reset-cache", + "rebuild": "node ./scripts/executors/invalidate-just-cache.js && yarn build --reset-cache", "release:fluentui:canary": "node -r ./scripts/ts-node-register ./scripts/fluentui-publish publish-canary", "release:fluentui:minor": "node -r ./scripts/ts-node-register ./scripts/fluentui-publish publish-minor", "release:fluentui:pack-nightly": "node -r ./scripts/ts-node-register ./scripts/fluentui-publish pack-nightly", "release:fluentui:patch": "node -r ./scripts/ts-node-register ./scripts/fluentui-publish publish-patch", "release:fluentui:post-validation": "node -r ./scripts/ts-node-register ./scripts/fluentui-publish post-publish", - "rename-package": "node -r ./scripts/ts-node-register ./scripts/rename-package.ts", + "rename-package": "node -r ./scripts/ts-node-register ./scripts/generators/rename-package.ts", "run:published": "node ./scripts/monorepo/runPublished.js", "runto:lerna": "node ./scripts/monorepo/runTo.js", - "scrub": "node ./scripts/scrub.js", - "start": "node scripts/start.js", + "scrub": "node ./scripts/executors/scrub.js", + "start": "node ./scripts/executors/start.js", "start:northstar": "yarn workspace @fluentui/docs start", "stats:build": "gulp stats", "stats:save": "gulp stats:save", @@ -157,6 +157,7 @@ "@types/node-fetch": "2.5.7", "@types/prettier": "2.2.3", "@types/progress": "2.0.5", + "@types/prompts": "2.4.1", "@types/react": "17.0.44", "@types/react-dom": "17.0.15", "@types/react-is": "17.0.3", @@ -219,8 +220,8 @@ "express": "4.17.1", "extract-comments": "1.1.0", "file-loader": "6.2.0", - "fork-ts-checker-webpack-plugin": "6.1.0", "find-free-port": "2.0.0", + "fork-ts-checker-webpack-plugin": "6.1.0", "fs-extra": "8.1.0", "geckodriver": "3.0.2", "glob": "7.2.0", @@ -262,6 +263,7 @@ "prettier": "2.2.1", "pretty-bytes": "5.6.0", "progress": "2.0.3", + "prompts": "2.4.2", "puppeteer": "14.4.0", "raw-loader": "4.0.2", "react": "17.0.2", diff --git a/packages/react-components/react-theme/package.json b/packages/react-components/react-theme/package.json index 616e1ec18c8ad..2e6f3458a41b7 100644 --- a/packages/react-components/react-theme/package.json +++ b/packages/react-components/react-theme/package.json @@ -21,7 +21,7 @@ "start": "yarn storybook", "storybook": "start-storybook", "test": "jest --passWithNoTests", - "token-pipeline": "node -r ../../../scripts/ts-node-register ../../../scripts/token-pipeline.ts", + "token-pipeline": "node -r ../../../scripts/ts-node-register ../../../scripts/generators/token-pipeline.ts", "type-check": "tsc -b tsconfig.json", "generate-api": "tsc -p ./tsconfig.lib.json --emitDeclarationOnly && just-scripts api-extractor" }, diff --git a/packages/react/package.json b/packages/react/package.json index 2605b9ff92c92..f9a243d7e8737 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -20,7 +20,7 @@ "build-storybook": "cross-env NODE_OPTIONS=--max-old-space-size=3072 just-scripts storybook:build", "clean": "just-scripts clean", "code-style": "just-scripts code-style", - "codepen": "node ../../scripts/local-codepen.js", + "codepen": "node ../../scripts/executors/local-codepen.js", "e2e": "yarn workspace @fluentui/react-examples cypress run --component", "e2e:local": "yarn workspace @fluentui/react-examples cypress open --component", "just": "just-scripts", diff --git a/scripts/CHANGELOG.json b/scripts/CHANGELOG.json deleted file mode 100644 index d69eda3a79827..0000000000000 --- a/scripts/CHANGELOG.json +++ /dev/null @@ -1,185 +0,0 @@ -{ - "name": "@fluentui/scripts", - "entries": [ - { - "date": "Tue, 24 Aug 2021 07:34:48 GMT", - "tag": "@fluentui/scripts_v1.0.0", - "version": "1.0.0", - "comments": { - "none": [ - { - "comment": "Bump @fluentui/eslint-plugin to v1.4.1", - "author": "dzearing@hotmail.com", - "commit": "0abd957c8d4421018e6d792c2a4aa8876967392b", - "package": "@fluentui/scripts" - } - ] - } - }, - { - "date": "Fri, 20 Aug 2021 07:37:28 GMT", - "tag": "@fluentui/scripts_v1.0.0", - "version": "1.0.0", - "comments": { - "none": [ - { - "comment": "Bump @fluentui/eslint-plugin to v1.4.0", - "author": "behowell@microsoft.com", - "commit": "21df8406417c5c5c1d053561a498b920ac962b4b", - "package": "@fluentui/scripts" - } - ] - } - }, - { - "date": "Tue, 03 Aug 2021 07:39:30 GMT", - "tag": "@fluentui/scripts_v1.0.0", - "version": "1.0.0", - "comments": { - "patch": [ - { - "comment": "Bump @fluentui/eslint-plugin to v1.3.3", - "author": "behowell@microsoft.com", - "commit": "86476ee0511ad2693c2829b959f93a87ad10f095", - "package": "@fluentui/scripts" - } - ] - } - }, - { - "date": "Fri, 09 Jul 2021 07:39:31 GMT", - "tag": "@fluentui/scripts_v1.0.0", - "version": "1.0.0", - "comments": { - "patch": [ - { - "comment": "Bump @fluentui/eslint-plugin to v1.3.2", - "author": "martinhochel@microsoft.com", - "commit": "18902eb64710aa6253a79781357b8390bb13665c", - "package": "@fluentui/scripts" - } - ] - } - }, - { - "date": "Mon, 07 Jun 2021 07:38:15 GMT", - "tag": "@fluentui/scripts_v1.0.0", - "version": "1.0.0", - "comments": { - "patch": [ - { - "comment": "Bump @fluentui/eslint-plugin to v1.3.1", - "author": "martinhochel@microsoft.com", - "commit": "f856cb3f7fbc3edb3646204c0c7e435fc7678dd1", - "package": "@fluentui/scripts" - } - ] - } - }, - { - "date": "Thu, 20 May 2021 07:41:54 GMT", - "tag": "@fluentui/scripts_v1.0.0", - "version": "1.0.0", - "comments": { - "patch": [ - { - "comment": "Bump @fluentui/eslint-plugin to v1.3.0", - "author": "elcraig@microsoft.com", - "commit": "630b71c415cd40ed0e36773eab99d62cd02a30fb", - "package": "@fluentui/scripts" - } - ] - } - }, - { - "date": "Fri, 30 Apr 2021 07:42:23 GMT", - "tag": "@fluentui/scripts_v1.0.0", - "version": "1.0.0", - "comments": { - "patch": [ - { - "comment": "Bump @fluentui/eslint-plugin to v1.2.0", - "author": "joschect@microsoft.com", - "commit": "2b62c457bb860f6675fae4acae86ee6c0b06c279", - "package": "@fluentui/scripts" - } - ] - } - }, - { - "date": "Fri, 23 Apr 2021 07:37:10 GMT", - "tag": "@fluentui/scripts_v1.0.0", - "version": "1.0.0", - "comments": { - "patch": [ - { - "comment": "Bump @fluentui/eslint-plugin to v1.1.1", - "author": "olfedias@microsoft.com", - "commit": "7d1a9a8aee217022e55b8c39c723b1390b5d8095", - "package": "@fluentui/scripts" - } - ] - } - }, - { - "date": "Wed, 31 Mar 2021 00:53:43 GMT", - "tag": "@fluentui/scripts_v1.0.0", - "version": "1.0.0", - "comments": { - "patch": [ - { - "comment": "Bump @fluentui/eslint-plugin to v1.1.0", - "author": "elcraig@microsoft.com", - "commit": "d41b79242e6b682dfa58fcd76797ecfd9146d4cf", - "package": "@fluentui/scripts" - } - ] - } - }, - { - "date": "Fri, 26 Feb 2021 01:16:27 GMT", - "tag": "@fluentui/scripts_v1.0.0", - "version": "1.0.0", - "comments": { - "patch": [ - { - "comment": "Bump @fluentui/eslint-plugin to v1.0.1", - "author": "elcraig@microsoft.com", - "commit": "71f0a43b375b4a932ecbcf6778288422db2dc267", - "package": "@fluentui/scripts" - } - ] - } - }, - { - "date": "Thu, 18 Feb 2021 12:27:34 GMT", - "tag": "@fluentui/scripts_v1.0.0", - "version": "1.0.0", - "comments": { - "prerelease": [ - { - "comment": "Bump @fluentui/eslint-plugin to v1.0.0-beta.2", - "author": "elcraig@microsoft.com", - "commit": "1072765ed2e0ffda34688d84d376a8bc4bf928f0", - "package": "@fluentui/scripts" - } - ] - } - }, - { - "date": "Thu, 11 Feb 2021 12:18:41 GMT", - "tag": "@fluentui/scripts_v1.0.0", - "version": "1.0.0", - "comments": { - "none": [ - { - "comment": "Bump @fluentui/eslint-plugin to v1.0.0-beta.1", - "author": "martinhochel@microsoft.com", - "commit": "7566015a7edd355b4fcd3796bc8f44f732ef0877", - "package": "@fluentui/scripts" - } - ] - } - } - ] -} diff --git a/scripts/CHANGELOG.md b/scripts/CHANGELOG.md deleted file mode 100644 index b6c6cf390ecdd..0000000000000 --- a/scripts/CHANGELOG.md +++ /dev/null @@ -1,86 +0,0 @@ -# Change Log - @fluentui/scripts - -This log was last generated on Tue, 03 Aug 2021 07:39:30 GMT and should not be manually modified. - - - -## [1.0.0](https://github.com/microsoft/fluentui/tree/@fluentui/scripts_v1.0.0) - -Tue, 03 Aug 2021 07:39:30 GMT -[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/scripts_v1.0.0..@fluentui/scripts_v1.0.0) - -### Patches - -- Bump @fluentui/eslint-plugin to v1.3.3 ([PR #19169](https://github.com/microsoft/fluentui/pull/19169) by behowell@microsoft.com) - -## [1.0.0](https://github.com/microsoft/fluentui/tree/@fluentui/scripts_v1.0.0) - -Fri, 09 Jul 2021 07:39:31 GMT -[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/scripts_v1.0.0..@fluentui/scripts_v1.0.0) - -### Patches - -- Bump @fluentui/eslint-plugin to v1.3.2 ([PR #18808](https://github.com/microsoft/fluentui/pull/18808) by martinhochel@microsoft.com) - -## [1.0.0](https://github.com/microsoft/fluentui/tree/@fluentui/scripts_v1.0.0) - -Mon, 07 Jun 2021 07:38:15 GMT -[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/scripts_v1.0.0..@fluentui/scripts_v1.0.0) - -### Patches - -- Bump @fluentui/eslint-plugin to v1.3.1 ([PR #18437](https://github.com/microsoft/fluentui/pull/18437) by martinhochel@microsoft.com) - -## [1.0.0](https://github.com/microsoft/fluentui/tree/@fluentui/scripts_v1.0.0) - -Thu, 20 May 2021 07:41:54 GMT -[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/scripts_v1.0.0..@fluentui/scripts_v1.0.0) - -### Patches - -- Bump @fluentui/eslint-plugin to v1.3.0 ([PR #18024](https://github.com/microsoft/fluentui/pull/18024) by elcraig@microsoft.com) - -## [1.0.0](https://github.com/microsoft/fluentui/tree/@fluentui/scripts_v1.0.0) - -Fri, 30 Apr 2021 07:42:23 GMT -[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/scripts_v1.0.0..@fluentui/scripts_v1.0.0) - -### Patches - -- Bump @fluentui/eslint-plugin to v1.2.0 ([PR #17932](https://github.com/microsoft/fluentui/pull/17932) by joschect@microsoft.com) - -## [1.0.0](https://github.com/microsoft/fluentui/tree/@fluentui/scripts_v1.0.0) - -Fri, 23 Apr 2021 07:37:10 GMT -[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/scripts_v1.0.0..@fluentui/scripts_v1.0.0) - -### Patches - -- Bump @fluentui/eslint-plugin to v1.1.1 ([PR #17894](https://github.com/microsoft/fluentui/pull/17894) by olfedias@microsoft.com) - -## [1.0.0](https://github.com/microsoft/fluentui/tree/@fluentui/scripts_v1.0.0) - -Wed, 31 Mar 2021 00:53:43 GMT -[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/scripts_v1.0.0..@fluentui/scripts_v1.0.0) - -### Patches - -- Bump @fluentui/eslint-plugin to v1.1.0 ([PR #17568](https://github.com/microsoft/fluentui/pull/17568) by elcraig@microsoft.com) - -## [1.0.0](https://github.com/microsoft/fluentui/tree/@fluentui/scripts_v1.0.0) - -Fri, 26 Feb 2021 01:16:27 GMT -[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/scripts_v1.0.0..@fluentui/scripts_v1.0.0) - -### Patches - -- Bump @fluentui/eslint-plugin to v1.0.1 ([PR #17169](https://github.com/microsoft/fluentui/pull/17169) by elcraig@microsoft.com) - -## [1.0.0](https://github.com/microsoft/fluentui/tree/@fluentui/scripts_v1.0.0) - -Thu, 18 Feb 2021 12:27:34 GMT -[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/scripts_v1.0.0..@fluentui/scripts_v1.0.0) - -### Changes - -- Bump @fluentui/eslint-plugin to v1.0.0-beta.2 ([PR #16975](https://github.com/microsoft/fluentui/pull/16975) by elcraig@microsoft.com) diff --git a/scripts/config/jest/flamegrillReporter.js b/scripts/config/jest/flamegrillReporter.js deleted file mode 100644 index aad1c7e22a800..0000000000000 --- a/scripts/config/jest/flamegrillReporter.js +++ /dev/null @@ -1,65 +0,0 @@ -const chokidar = require('chokidar'); -const os = require('os'); -const path = require('path'); -const fs = require('fs-extra'); - -const { processProfiles } = require('flamegrill/lib/process'); - -class FlamegrillReporter { - constructor(globalConfig, options) { - this._globalConfig = globalConfig; - this._options = options; - this._watcher = null; - this._logFiles = []; - } - - onTestStart(test) { - this._logFiles = []; - this._watcher = chokidar.watch(path.join(os.tmpdir(), '*-puppeteer.log'), { - ignoreInitial: true, - }); - this._watcher.on('add', file => { - this._logFiles.push(file); - }); - } - - onTestResult(test, testResult, aggregatedResult) { - this._watcher.close(); - - const profiles = /** @type {import('flamegrill/lib/profile').ScenarioProfiles} */ ({}); - const numLogFiles = this._logFiles.length; - const numTests = testResult.testResults.length; - - // there are just unused log files that get generated, we will shift by the "delta" - const delta = numLogFiles - numTests; - - testResult.testResults.forEach((result, index) => { - profiles[result.fullName.replace(/\s/g, '-')] = { - logFile: this._logFiles[index + delta], - metrics: {}, - }; - }); - (async () => { - const root = process.cwd(); - - const outDir = path.join(root, 'dist/flamegrill/output'); - const tempDir = path.join(root, 'dist/flamegrill/tmp'); - await fs.mkdirp(outDir); - await fs.mkdirp(tempDir); - const processed = await processProfiles(profiles, { - outDir, - tempDir, - }); - - console.log('Generated flamecharts: '); - Object.keys(processed).forEach(scenario => { - const result = processed[scenario]; - console.log(` - ${scenario}: ${result.output.flamegraphFile}`); - }); - - console.log(); - })(); - } -} - -module.exports = FlamegrillReporter; diff --git a/scripts/convert-change-files.js b/scripts/convert-change-files.js deleted file mode 100644 index 7f5f341c806bb..0000000000000 --- a/scripts/convert-change-files.js +++ /dev/null @@ -1,74 +0,0 @@ -const fs = require('fs-extra'); -const { spawnSync } = require('child_process'); -const path = require('path'); -const glob = require('glob'); -const chalk = require('chalk'); - -function convertChangeFiles() { - const root = path.resolve(__dirname, '../'); - const changePath = path.join(root, 'change'); - - if (!fs.existsSync(changePath)) { - fs.mkdirpSync(changePath); - } - - const legacyChangeFiles = glob.sync('common/changes/**/*.json'); - - legacyChangeFiles.forEach(legacy => { - const fileStat = fs.statSync(legacy); - const legacyJson = JSON.parse(fs.readFileSync(legacy, 'utf-8')); - - legacyJson.changes.forEach(change => { - const beachballChangeJson = { - comment: change.comment || 'No comment', - type: change.type, - packageName: change.packageName, - email: legacyJson.email, - commit: getCommitByFile(legacy), - date: fileStat.ctime.toISOString(), - }; - - const prefix = change.packageName.replace(/[^a-zA-Z0-9@]/g, '-'); - - fs.writeFileSync( - path.join(changePath, `${prefix}-${getTimeStamp(fileStat.ctime)}.json`), - JSON.stringify(beachballChangeJson, null, 2), - ); - }); - - fs.removeSync(legacy); - }); -} - -function getCommitByFile(file) { - const results = spawnSync('git', ['log', '-n', '1', '--pretty=format:%H', '--', file]); - if (results.status === 0) { - return results.stdout.toString().trim(); - } - - return 'not available'; -} - -function leftPadTwoZeros(someString) { - return ('00' + someString).slice(-2); -} - -function getTimeStamp(date) { - return [ - date.getFullYear(), - leftPadTwoZeros((date.getMonth() + 1).toString()), - leftPadTwoZeros(date.getDate().toString()), - leftPadTwoZeros(date.getHours().toString()), - leftPadTwoZeros(date.getMinutes().toString()), - leftPadTwoZeros(date.getSeconds().toString()), - ].join('-'); -} - -module.exports = convertChangeFiles; - -if (require.main === module) { - convertChangeFiles(); - console.log(chalk.green('git status:')); - spawnSync('git', ['status'], { stdio: 'inherit' }); - console.log(chalk.cyan('Conversion successful! Be sure to git add & git commit & git push this!!')); -} diff --git a/scripts/create-component/plop-templates/stories/{{componentName}}/{{componentName}}Description.md b/scripts/executors/README.md similarity index 100% rename from scripts/create-component/plop-templates/stories/{{componentName}}/{{componentName}}Description.md rename to scripts/executors/README.md diff --git a/scripts/debug-test.js b/scripts/executors/debug-test.js similarity index 81% rename from scripts/debug-test.js rename to scripts/executors/debug-test.js index 4e7a82dcda43b..791f0e3f527f3 100644 --- a/scripts/debug-test.js +++ b/scripts/executors/debug-test.js @@ -1,6 +1,6 @@ const path = require('path'); -const findConfig = require('./find-config'); -const findGitRoot = require('./monorepo/findGitRoot'); +const { findConfig } = require('../utils'); +const { findGitRoot } = require('../monorepo'); const configPath = findConfig('jest.config.js'); const rootPath = findGitRoot(); diff --git a/scripts/format.js b/scripts/executors/format.js similarity index 95% rename from scripts/format.js rename to scripts/executors/format.js index e191e4fc0bdd8..9042d1b3c0b8f 100644 --- a/scripts/format.js +++ b/scripts/executors/format.js @@ -1,11 +1,9 @@ -// @ts-check - // This script is not meant as a general-purpose replacement for prettier. // It only handles certain cases that prettier doesn't support as well/at all natively. const { execSync } = require('child_process'); -const { runPrettier, runPrettierForFolder } = require('./prettier'); -const { findGitRoot } = require('./monorepo'); +const { runPrettier, runPrettierForFolder } = require('../prettier'); +const { findGitRoot } = require('../monorepo'); const parsedArgs = parseArgs(); const root = findGitRoot(); diff --git a/scripts/executors/invalidate-just-cache.js b/scripts/executors/invalidate-just-cache.js new file mode 100644 index 0000000000000..e3d8134ee62c4 --- /dev/null +++ b/scripts/executors/invalidate-just-cache.js @@ -0,0 +1,9 @@ +const fs = require('fs'); +const path = require('path'); +const { workspaceRoot } = require('nx/src/utils/app-root'); + +const topLevelDep = path.join(workspaceRoot, 'node_modules/.just'); + +if (fs.existsSync(topLevelDep)) { + fs.rmSync(topLevelDep, { recursive: true }); +} diff --git a/scripts/local-codepen.js b/scripts/executors/local-codepen.js similarity index 96% rename from scripts/local-codepen.js rename to scripts/executors/local-codepen.js index 3db188609f2e6..1bca12c6de48b 100644 --- a/scripts/local-codepen.js +++ b/scripts/executors/local-codepen.js @@ -4,9 +4,10 @@ const path = require('path'); const fs = require('fs'); const yargs = require('yargs'); const { execSync } = require('child_process'); -const { findGitRoot } = require('./monorepo/index'); const chalk = require('chalk'); +const { findGitRoot } = require('../monorepo'); + const options = yargs.option('webpackConfig', { alias: 'w', type: 'string' }).argv; const webpackConfigFilePath = options.webpackConfig || 'webpack.codepen.config.js'; @@ -15,6 +16,9 @@ const configPath = path.resolve(process.cwd(), webpackConfigFilePath); const gitRoot = findGitRoot(); if (fs.existsSync(configPath)) { + /** + * @type {any} + */ let ngrok; try { console.log("Attempting to npm link globally installed ngrok so it can be require'd"); diff --git a/scripts/scrub.js b/scripts/executors/scrub.js similarity index 98% rename from scripts/scrub.js rename to scripts/executors/scrub.js index e83059e12a5c4..237d70721579a 100644 --- a/scripts/scrub.js +++ b/scripts/executors/scrub.js @@ -1,5 +1,3 @@ -// @ts-check - const child_process = require('child_process'); const fs = require('fs'); const os = require('os'); @@ -58,7 +56,7 @@ function deleteNodeModulesSymlinks(packagePath, failedPaths) { const modules = fs.readdirSync(nodeModulesPath); /** @type {string} */ let mod; - while ((mod = modules.pop())) { + while ((mod = /** @type {string} */ (modules.pop()))) { const modulePath = path.join(nodeModulesPath, mod); if (mod[0] === '@' && !/[/\\]/.test(mod)) { // Add any scoped modules to the list of things to check @@ -133,6 +131,9 @@ async function run() { console.log('Clearing gulp-cache failed, likely due it not being installed.'); } + /** + * @type {string[]} + */ const failedPaths = []; console.log("\nDeleting symlinks from packages' node_modules and rush temp files..."); diff --git a/scripts/start.js b/scripts/executors/start.js similarity index 88% rename from scripts/start.js rename to scripts/executors/start.js index e075a221978c6..00d339b4f6fbf 100644 --- a/scripts/start.js +++ b/scripts/executors/start.js @@ -1,8 +1,7 @@ -// @ts-check - const { spawnSync } = require('child_process'); const prompts = require('prompts'); -const getAllPackageInfo = require('./monorepo/getAllPackageInfo'); +const { getAllPackageInfo } = require('../monorepo'); + const allPackages = getAllPackageInfo(); const extraArgs = process.argv.slice(2); @@ -19,10 +18,15 @@ const projectsWithStartCommand = Object.entries(allPackages) } return acc; - }, []) + }, /** @type {import('prompts').Choice[]} */ ([])) .filter(n => n && !defaults.includes(n.title)) .sort((a, b) => (a.title === b.title ? 0 : a.title > b.title ? 1 : -1)); +/** + * + * @param {string} input + * @param {import('prompts').Choice[]} choices + */ const suggest = (input, choices) => Promise.resolve(choices.filter(i => i.title.includes(input))); (async () => { diff --git a/scripts/executors/tsconfig.json b/scripts/executors/tsconfig.json new file mode 100644 index 0000000000000..762633eb48a71 --- /dev/null +++ b/scripts/executors/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../tsconfig.scripts.json", + "compilerOptions": { + "types": ["node"] + }, + "include": ["**/*.ts", "**/*.js"] +} diff --git a/scripts/create-package/plop-templates-node/src/index.ts b/scripts/generators/README.md similarity index 100% rename from scripts/create-package/plop-templates-node/src/index.ts rename to scripts/generators/README.md diff --git a/scripts/bundle-size-collect.js b/scripts/generators/bundle-size-collect.js similarity index 75% rename from scripts/bundle-size-collect.js rename to scripts/generators/bundle-size-collect.js index d2266082e53e2..36d4f7bf288e1 100644 --- a/scripts/bundle-size-collect.js +++ b/scripts/generators/bundle-size-collect.js @@ -1,4 +1,6 @@ -// @ts-check +/** + * @see {@link ../../azure-pipelines.bundlesize.yml} + */ // This script collates bundle size information from minified files in apps/test-bundles/dist // and writes to apps/test-bundles/dist/bundlesizes.json. @@ -8,7 +10,8 @@ const fs = require('fs'); const path = require('path'); -const distRoot = path.resolve(__dirname, '../apps/test-bundles/dist'); +const distRoot = path.resolve(__dirname, '../../apps/test-bundles/dist'); +/** @type {Record} */ const sizes = {}; const outputFilename = 'bundlesize.json'; @@ -24,10 +27,10 @@ items.forEach(item => { fs.writeFileSync(path.join(distRoot, outputFilename), JSON.stringify({ sizes })); -function getFilesizeInBytes(fileName) { +function getFilesizeInBytes(/** @type {string} */ fileName) { return fs.statSync(fileName).size; } -function getComponentName(fileName) { +function getComponentName(/** @type {string} */ fileName) { return path.basename(fileName, '.min.js'); } diff --git a/scripts/copy-notices.js b/scripts/generators/copy-notices.js similarity index 97% rename from scripts/copy-notices.js rename to scripts/generators/copy-notices.js index 14f7c3dabbeac..7e8be5f8c057e 100644 --- a/scripts/copy-notices.js +++ b/scripts/generators/copy-notices.js @@ -1,4 +1,4 @@ -const monorepo = require('./monorepo'); +const monorepo = require('../monorepo'); const path = require('path'); const fs = require('fs'); diff --git a/scripts/create-component/create-component.ts b/scripts/generators/create-component/index.ts similarity index 96% rename from scripts/create-component/create-component.ts rename to scripts/generators/create-component/index.ts index 658470677ea55..2a820c8dafd03 100644 --- a/scripts/create-component/create-component.ts +++ b/scripts/generators/create-component/index.ts @@ -6,10 +6,11 @@ import * as fs from 'fs-extra'; import * as os from 'os'; import * as path from 'path'; import { execSync } from 'child_process'; -import { findGitRoot, getAllPackageInfo, isConvergedPackage } from '../monorepo/index'; import chalk from 'chalk'; import { names, WorkspaceJsonConfiguration } from '@nrwl/devkit'; +import { findGitRoot, getAllPackageInfo, isConvergedPackage } from '../../monorepo'; + //#endregion //#region Globals @@ -69,6 +70,9 @@ module.exports = (plop: NodePlopAPI) => { actions: (answers: Answers): Actions => { const globOptions: AddManyActionConfig['globOptions'] = { dot: true }; const packageMetadata = getProjectMetadata({ root, name: answers.packageNpmName }); + if (!packageMetadata.sourceRoot) { + throw new Error(`${answers.packageNpmName} has is missing sourceRoot path in workspace.json`); + } const packageName = answers.packageNpmName.replace('@fluentui/', ''); const componentPath = path.join(packageMetadata.sourceRoot, 'components', answers.componentName); diff --git a/scripts/create-component/plop-templates/src/common/isConformant.ts.hbs b/scripts/generators/create-component/plop-templates/src/common/isConformant.ts.hbs similarity index 100% rename from scripts/create-component/plop-templates/src/common/isConformant.ts.hbs rename to scripts/generators/create-component/plop-templates/src/common/isConformant.ts.hbs diff --git a/scripts/create-component/plop-templates/src/components/{{componentName}}/index.ts.hbs b/scripts/generators/create-component/plop-templates/src/components/{{componentName}}/index.ts.hbs similarity index 100% rename from scripts/create-component/plop-templates/src/components/{{componentName}}/index.ts.hbs rename to scripts/generators/create-component/plop-templates/src/components/{{componentName}}/index.ts.hbs diff --git a/scripts/create-component/plop-templates/src/components/{{componentName}}/render{{componentName}}.tsx.hbs b/scripts/generators/create-component/plop-templates/src/components/{{componentName}}/render{{componentName}}.tsx.hbs similarity index 100% rename from scripts/create-component/plop-templates/src/components/{{componentName}}/render{{componentName}}.tsx.hbs rename to scripts/generators/create-component/plop-templates/src/components/{{componentName}}/render{{componentName}}.tsx.hbs diff --git a/scripts/create-component/plop-templates/src/components/{{componentName}}/use{{componentName}}.ts.hbs b/scripts/generators/create-component/plop-templates/src/components/{{componentName}}/use{{componentName}}.ts.hbs similarity index 100% rename from scripts/create-component/plop-templates/src/components/{{componentName}}/use{{componentName}}.ts.hbs rename to scripts/generators/create-component/plop-templates/src/components/{{componentName}}/use{{componentName}}.ts.hbs diff --git a/scripts/create-component/plop-templates/src/components/{{componentName}}/use{{componentName}}Styles.ts.hbs b/scripts/generators/create-component/plop-templates/src/components/{{componentName}}/use{{componentName}}Styles.ts.hbs similarity index 100% rename from scripts/create-component/plop-templates/src/components/{{componentName}}/use{{componentName}}Styles.ts.hbs rename to scripts/generators/create-component/plop-templates/src/components/{{componentName}}/use{{componentName}}Styles.ts.hbs diff --git a/scripts/create-component/plop-templates/src/components/{{componentName}}/{{componentName}}.test.tsx.hbs b/scripts/generators/create-component/plop-templates/src/components/{{componentName}}/{{componentName}}.test.tsx.hbs similarity index 100% rename from scripts/create-component/plop-templates/src/components/{{componentName}}/{{componentName}}.test.tsx.hbs rename to scripts/generators/create-component/plop-templates/src/components/{{componentName}}/{{componentName}}.test.tsx.hbs diff --git a/scripts/create-component/plop-templates/src/components/{{componentName}}/{{componentName}}.tsx.hbs b/scripts/generators/create-component/plop-templates/src/components/{{componentName}}/{{componentName}}.tsx.hbs similarity index 100% rename from scripts/create-component/plop-templates/src/components/{{componentName}}/{{componentName}}.tsx.hbs rename to scripts/generators/create-component/plop-templates/src/components/{{componentName}}/{{componentName}}.tsx.hbs diff --git a/scripts/create-component/plop-templates/src/components/{{componentName}}/{{componentName}}.types.ts.hbs b/scripts/generators/create-component/plop-templates/src/components/{{componentName}}/{{componentName}}.types.ts.hbs similarity index 100% rename from scripts/create-component/plop-templates/src/components/{{componentName}}/{{componentName}}.types.ts.hbs rename to scripts/generators/create-component/plop-templates/src/components/{{componentName}}/{{componentName}}.types.ts.hbs diff --git a/scripts/create-component/plop-templates/src/{{componentName}}.ts.hbs b/scripts/generators/create-component/plop-templates/src/{{componentName}}.ts.hbs similarity index 100% rename from scripts/create-component/plop-templates/src/{{componentName}}.ts.hbs rename to scripts/generators/create-component/plop-templates/src/{{componentName}}.ts.hbs diff --git a/scripts/create-component/plop-templates/stories/{{componentName}}/index.stories.tsx.hbs b/scripts/generators/create-component/plop-templates/stories/{{componentName}}/index.stories.tsx.hbs similarity index 100% rename from scripts/create-component/plop-templates/stories/{{componentName}}/index.stories.tsx.hbs rename to scripts/generators/create-component/plop-templates/stories/{{componentName}}/index.stories.tsx.hbs diff --git a/scripts/create-component/plop-templates/stories/{{componentName}}/{{componentName}}BestPractices.md b/scripts/generators/create-component/plop-templates/stories/{{componentName}}/{{componentName}}BestPractices.md similarity index 100% rename from scripts/create-component/plop-templates/stories/{{componentName}}/{{componentName}}BestPractices.md rename to scripts/generators/create-component/plop-templates/stories/{{componentName}}/{{componentName}}BestPractices.md diff --git a/scripts/create-component/plop-templates/stories/{{componentName}}/{{componentName}}Default.stories.tsx.hbs b/scripts/generators/create-component/plop-templates/stories/{{componentName}}/{{componentName}}Default.stories.tsx.hbs similarity index 100% rename from scripts/create-component/plop-templates/stories/{{componentName}}/{{componentName}}Default.stories.tsx.hbs rename to scripts/generators/create-component/plop-templates/stories/{{componentName}}/{{componentName}}Default.stories.tsx.hbs diff --git a/scripts/create-package/plop-templates-react/etc/{{packageName}}.api.md b/scripts/generators/create-component/plop-templates/stories/{{componentName}}/{{componentName}}Description.md similarity index 100% rename from scripts/create-package/plop-templates-react/etc/{{packageName}}.api.md rename to scripts/generators/create-component/plop-templates/stories/{{componentName}}/{{componentName}}Description.md diff --git a/scripts/create-package/plopfile.ts b/scripts/generators/create-package/index.ts similarity index 96% rename from scripts/create-package/plopfile.ts rename to scripts/generators/create-package/index.ts index 50ff6179facb5..d701873a4ba2a 100644 --- a/scripts/create-package/plopfile.ts +++ b/scripts/generators/create-package/index.ts @@ -7,7 +7,8 @@ import _ from 'lodash'; import chalk from 'chalk'; import { spawnSync } from 'child_process'; import { WorkspaceJsonConfiguration } from '@nrwl/devkit'; -import { findGitRoot, PackageJson } from '../monorepo/index'; + +import { findGitRoot, PackageJson } from '../../monorepo'; const root = findGitRoot(); @@ -210,14 +211,15 @@ function replaceVersionsFromReference( const errorPackages: string[] = []; for (const depType of depTypes) { - if (!newPackageJson[depType]) { + const packageDependencies = newPackageJson[depType]; + if (!packageDependencies) { continue; } - for (const depPkg of Object.keys(newPackageJson[depType])) { + for (const depPkg of Object.keys(packageDependencies)) { if (!answers.hasTests && /\b(jest|enzyme|test(ing)?|react-conformance)\b/.test(depPkg)) { - delete newPackageJson[depType][depPkg]; + delete packageDependencies[depPkg]; } else if (referenceDeps[depType]?.[depPkg]) { - newPackageJson[depType][depPkg] = referenceDeps[depType][depPkg]; + packageDependencies[depPkg] = referenceDeps[depType]?.[depPkg] as string; } else { // Record the error and wait to throw until later for better logs errorPackages.push(`${depPkg} (${depType})`); diff --git a/scripts/create-package/plop-templates-node/.eslintrc.json b/scripts/generators/create-package/plop-templates-node/.eslintrc.json similarity index 100% rename from scripts/create-package/plop-templates-node/.eslintrc.json rename to scripts/generators/create-package/plop-templates-node/.eslintrc.json diff --git a/scripts/create-package/plop-templates-node/README.md b/scripts/generators/create-package/plop-templates-node/README.md similarity index 100% rename from scripts/create-package/plop-templates-node/README.md rename to scripts/generators/create-package/plop-templates-node/README.md diff --git a/scripts/create-package/plop-templates-node/jest.config.js b/scripts/generators/create-package/plop-templates-node/jest.config.js similarity index 100% rename from scripts/create-package/plop-templates-node/jest.config.js rename to scripts/generators/create-package/plop-templates-node/jest.config.js diff --git a/scripts/create-package/plop-templates-node/just.config.ts b/scripts/generators/create-package/plop-templates-node/just.config.ts similarity index 100% rename from scripts/create-package/plop-templates-node/just.config.ts rename to scripts/generators/create-package/plop-templates-node/just.config.ts diff --git a/scripts/create-package/plop-templates-node/package.json.hbs b/scripts/generators/create-package/plop-templates-node/package.json.hbs similarity index 100% rename from scripts/create-package/plop-templates-node/package.json.hbs rename to scripts/generators/create-package/plop-templates-node/package.json.hbs diff --git a/scripts/generators/create-package/plop-templates-node/src/index.ts b/scripts/generators/create-package/plop-templates-node/src/index.ts new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/scripts/create-package/plop-templates-node/tsconfig.json b/scripts/generators/create-package/plop-templates-node/tsconfig.json similarity index 100% rename from scripts/create-package/plop-templates-node/tsconfig.json rename to scripts/generators/create-package/plop-templates-node/tsconfig.json diff --git a/scripts/create-package/plop-templates-react/.babelrc.json b/scripts/generators/create-package/plop-templates-react/.babelrc.json similarity index 100% rename from scripts/create-package/plop-templates-react/.babelrc.json rename to scripts/generators/create-package/plop-templates-react/.babelrc.json diff --git a/scripts/create-package/plop-templates-react/.eslintrc.json b/scripts/generators/create-package/plop-templates-react/.eslintrc.json similarity index 100% rename from scripts/create-package/plop-templates-react/.eslintrc.json rename to scripts/generators/create-package/plop-templates-react/.eslintrc.json diff --git a/scripts/create-package/plop-templates-react/README.md b/scripts/generators/create-package/plop-templates-react/README.md similarity index 100% rename from scripts/create-package/plop-templates-react/README.md rename to scripts/generators/create-package/plop-templates-react/README.md diff --git a/scripts/create-package/plop-templates-react/Spec.md.hbs b/scripts/generators/create-package/plop-templates-react/Spec.md.hbs similarity index 100% rename from scripts/create-package/plop-templates-react/Spec.md.hbs rename to scripts/generators/create-package/plop-templates-react/Spec.md.hbs diff --git a/scripts/create-package/plop-templates-react/config/api-extractor.json b/scripts/generators/create-package/plop-templates-react/config/api-extractor.json similarity index 100% rename from scripts/create-package/plop-templates-react/config/api-extractor.json rename to scripts/generators/create-package/plop-templates-react/config/api-extractor.json diff --git a/scripts/create-package/plop-templates-react/config/tests.js b/scripts/generators/create-package/plop-templates-react/config/tests.js similarity index 100% rename from scripts/create-package/plop-templates-react/config/tests.js rename to scripts/generators/create-package/plop-templates-react/config/tests.js diff --git a/scripts/generators/create-package/plop-templates-react/etc/{{packageName}}.api.md b/scripts/generators/create-package/plop-templates-react/etc/{{packageName}}.api.md new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/scripts/create-package/plop-templates-react/jest.config.js b/scripts/generators/create-package/plop-templates-react/jest.config.js similarity index 100% rename from scripts/create-package/plop-templates-react/jest.config.js rename to scripts/generators/create-package/plop-templates-react/jest.config.js diff --git a/scripts/create-package/plop-templates-react/just.config.ts b/scripts/generators/create-package/plop-templates-react/just.config.ts similarity index 100% rename from scripts/create-package/plop-templates-react/just.config.ts rename to scripts/generators/create-package/plop-templates-react/just.config.ts diff --git a/scripts/create-package/plop-templates-react/package.json.hbs b/scripts/generators/create-package/plop-templates-react/package.json.hbs similarity index 100% rename from scripts/create-package/plop-templates-react/package.json.hbs rename to scripts/generators/create-package/plop-templates-react/package.json.hbs diff --git a/scripts/create-package/plop-templates-react/src/index.ts b/scripts/generators/create-package/plop-templates-react/src/index.ts similarity index 100% rename from scripts/create-package/plop-templates-react/src/index.ts rename to scripts/generators/create-package/plop-templates-react/src/index.ts diff --git a/scripts/create-package/plop-templates-react/tsconfig.json b/scripts/generators/create-package/plop-templates-react/tsconfig.json similarity index 100% rename from scripts/create-package/plop-templates-react/tsconfig.json rename to scripts/generators/create-package/plop-templates-react/tsconfig.json diff --git a/scripts/create-package/plop-templates/.npmignore b/scripts/generators/create-package/plop-templates/.npmignore similarity index 100% rename from scripts/create-package/plop-templates/.npmignore rename to scripts/generators/create-package/plop-templates/.npmignore diff --git a/scripts/create-package/plop-templates/LICENSE b/scripts/generators/create-package/plop-templates/LICENSE similarity index 100% rename from scripts/create-package/plop-templates/LICENSE rename to scripts/generators/create-package/plop-templates/LICENSE diff --git a/scripts/generate-package-manifest.js b/scripts/generators/generate-package-manifest.js similarity index 87% rename from scripts/generate-package-manifest.js rename to scripts/generators/generate-package-manifest.js index 278df5908a14c..e5279863a182e 100644 --- a/scripts/generate-package-manifest.js +++ b/scripts/generators/generate-package-manifest.js @@ -1,8 +1,12 @@ -// @ts-check +/** + * This is used solely for V8 release. + * @see {@link ../../azure-pipelines.release.yml} + */ + const path = require('path'); const fs = require('fs-extra'); const semver = require('semver'); -const { getAllPackageInfo, findGitRoot } = require('./monorepo/index'); +const { getAllPackageInfo, findGitRoot } = require('../monorepo'); // Generate "manifest" file with package.jsons of all the monorepo packages (mainly for ODSP) diff --git a/scripts/rename-package.ts b/scripts/generators/rename-package.ts similarity index 97% rename from scripts/rename-package.ts rename to scripts/generators/rename-package.ts index c5f004d04a41a..719198fb0519c 100644 --- a/scripts/rename-package.ts +++ b/scripts/generators/rename-package.ts @@ -6,8 +6,10 @@ import * as path from 'path'; import { sync as replaceInFileSync, ReplaceResult } from 'replace-in-file'; import { findGitRoot, PackageInfo, listAllTrackedFiles, stageAndCommit } from 'workspace-tools'; -const readConfig: (pth: string) => PackageInfo = require('./read-config').readConfig; -const writeConfig: (pth: string, newValue: any) => void = require('./write-config'); +const { readConfig: _readConfig, writeConfig: _writeConfig } = require('./utils'); + +const readConfig: (pth: string) => PackageInfo = _readConfig; +const writeConfig: (pth: string, newValue: any) => void = _writeConfig; const { runPrettier } = require('./prettier'); const gitRoot = findGitRoot(process.cwd()); @@ -157,6 +159,9 @@ function updateReferences(renameInfo: RenameInfo): string[] { } const match = nameRegex.exec(substr); + if (!match) { + throw new Error('no matches found'); + } // This is the scope or the packages or apps section of the path const firstPart = match[1] === oldScope ? newScope : match[1]; return `${firstPart}/${newUnscopedName}`; diff --git a/scripts/token-pipeline.ts b/scripts/generators/token-pipeline.ts similarity index 96% rename from scripts/token-pipeline.ts rename to scripts/generators/token-pipeline.ts index 3ce57f08518d8..d8a982481e78a 100644 --- a/scripts/token-pipeline.ts +++ b/scripts/generators/token-pipeline.ts @@ -4,8 +4,8 @@ import * as _ from 'lodash'; import * as yargs from 'yargs'; import { execSync } from 'child_process'; -import { findGitRoot } from './monorepo'; -import { createTempDir } from './projects-test'; +import { findGitRoot } from '../monorepo'; +import { createTempDir } from '../projects-test'; const themes = ['light', 'dark', 'teamsDark', 'highContrast'] as const; const repoRoot = findGitRoot(); diff --git a/scripts/generators/tsconfig.json b/scripts/generators/tsconfig.json new file mode 100644 index 0000000000000..6e40c2730b8e1 --- /dev/null +++ b/scripts/generators/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../tsconfig.scripts.json", + "compilerOptions": { + "types": ["node"] + }, + "include": ["**/*.ts", "**/*.js"], + "exclude": ["**/plop-templates/**", "**/plop-templates-node/**", "**/plop-templates-react/**"] +} diff --git a/scripts/invalidate-just-cache.js b/scripts/invalidate-just-cache.js deleted file mode 100644 index 7d4c8875ebad7..0000000000000 --- a/scripts/invalidate-just-cache.js +++ /dev/null @@ -1,8 +0,0 @@ -const fs = require('fs-extra'); -const path = require('path'); - -const topLevelDep = path.join(__dirname, './node_modules/.just'); - -if (fs.pathExistsSync(topLevelDep)) { - fs.removeSync(topLevelDep); -} diff --git a/scripts/jest/jest-resources.js b/scripts/jest/jest-resources.js index 4f5b9c10100df..88ee6e4b0f6c0 100644 --- a/scripts/jest/jest-resources.js +++ b/scripts/jest/jest-resources.js @@ -5,7 +5,7 @@ const { resolveCwd } = require('just-scripts'); const merge = require('../tasks/merge'); const { findRepoDeps } = require('../monorepo'); -const findConfig = require('../find-config'); +const { findConfig } = require('../utils'); const packageJsonPath = findConfig('package.json') ?? ''; const packageRoot = path.dirname(packageJsonPath); diff --git a/scripts/monorepo/findRepoDeps.js b/scripts/monorepo/findRepoDeps.js index 0f7b6cebd290e..bbec9f6bc9b19 100644 --- a/scripts/monorepo/findRepoDeps.js +++ b/scripts/monorepo/findRepoDeps.js @@ -1,4 +1,4 @@ -const { readConfig } = require('../read-config'); +const { readConfig } = require('../utils'); const getAllPackageInfo = require('./getAllPackageInfo'); /** diff --git a/scripts/monorepo/isConvergedPackage.js b/scripts/monorepo/isConvergedPackage.js index 6a172ce47da66..c97fe97089983 100644 --- a/scripts/monorepo/isConvergedPackage.js +++ b/scripts/monorepo/isConvergedPackage.js @@ -1,5 +1,5 @@ const semver = require('semver'); -const { readConfig } = require('../read-config'); +const { readConfig } = require('../utils'); const { getProjectMetadata } = require('./utils'); /** diff --git a/scripts/postinstall.js b/scripts/package-manager/postinstall.js similarity index 98% rename from scripts/postinstall.js rename to scripts/package-manager/postinstall.js index 33bc042073ccc..a3c1a5916d162 100644 --- a/scripts/postinstall.js +++ b/scripts/package-manager/postinstall.js @@ -1,4 +1,3 @@ -// @ts-check const { spawnSync } = require('child_process'); const chalk = require('chalk'); diff --git a/scripts/package-manager/tsconfig.json b/scripts/package-manager/tsconfig.json new file mode 100644 index 0000000000000..1401d82c3b085 --- /dev/null +++ b/scripts/package-manager/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../tsconfig.scripts.json", + "compilerOptions": { + "types": ["node"] + }, + "include": ["**/*.js"] +} diff --git a/scripts/use-yarn-please.js b/scripts/package-manager/use-yarn-please.js similarity index 97% rename from scripts/use-yarn-please.js rename to scripts/package-manager/use-yarn-please.js index d71d1b4448826..c96ff311406c1 100644 --- a/scripts/use-yarn-please.js +++ b/scripts/package-manager/use-yarn-please.js @@ -1,4 +1,3 @@ -// @ts-check const path = require('path'); const { spawnSync } = require('child_process'); @@ -36,6 +35,10 @@ function main() { } function userInvokedNpmInstall() { + if (!npmPath) { + return false; + } + return path.basename(npmPath).includes('npm'); } diff --git a/scripts/package.json b/scripts/package.json index 85da64548204a..d2bca7a7b247d 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -36,7 +36,6 @@ "p-queue": "^6.0.2", "path-browserify": "^1.0.1", "plop": "^2.6.0", - "prompts": "^2.3.0", "react-hot-loader": "^4.13.0", "react-vis": "^1.11.6", "read-pkg-up": "^7.0.1", diff --git a/scripts/tasks/lint-imports.ts b/scripts/tasks/lint-imports.ts index 8bdd6c1bf3ef0..26a50cf1f4f99 100644 --- a/scripts/tasks/lint-imports.ts +++ b/scripts/tasks/lint-imports.ts @@ -1,5 +1,5 @@ import { getAllPackageInfo, findGitRoot } from '../monorepo'; -import { readConfig } from '../read-config'; +import { readConfig } from '../utils'; import * as glob from 'glob'; import * as path from 'path'; import * as fs from 'fs'; diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json index 07ba9e5936b90..b44c6010041e8 100644 --- a/scripts/tsconfig.json +++ b/scripts/tsconfig.json @@ -33,6 +33,10 @@ "./babel/**", "./api-extractor/**", "./typescript/**", - "./lint-staged/**" + "./lint-staged/**", + "./generators/**", + "./executors/**", + "./package-manager/**", + "./utils/**" ] } diff --git a/scripts/tsconfig.scripts.json b/scripts/tsconfig.scripts.json index 7c707022600a7..33f6167d54a82 100644 --- a/scripts/tsconfig.scripts.json +++ b/scripts/tsconfig.scripts.json @@ -53,6 +53,12 @@ { "path": "./screener/tsconfig.json" }, + { + "path": "./generators/tsconfig.json" + }, + { + "path": "./executors/tsconfig.json" + }, { "path": "./github/tsconfig.json" }, @@ -77,6 +83,12 @@ { "path": "./fluentui-publish/tsconfig.json" }, + { + "path": "./package-manager/tsconfig.json" + }, + { + "path": "./utils/tsconfig.json" + }, { "path": "./tsconfig.json" } diff --git a/scripts/typescript-compatibility-build.yml b/scripts/typescript-compatibility-build.yml deleted file mode 100644 index f3e7969605ac5..0000000000000 --- a/scripts/typescript-compatibility-build.yml +++ /dev/null @@ -1,194 +0,0 @@ -trigger: - branches: - include: - - tsc-compat-debug - - refs/tags/office-ui-fabric-react_v* - -variables: - - name: PackageName - value: office-ui-fabric-react - - name: CompatRepoUrl - value: https://github.com/Microsoft/ui-fabric-ts-validation.git - - name: NodeVersion - value: '10.x' - - name: VmImage - value: 'Ubuntu 16.04' - -jobs: - - job: Build - pool: - vmImage: $(VmImage) - timeoutInMinutes: 60 - steps: - - checkout: self - clean: true - - - task: NodeTool@0 - displayName: 'Use Node $(NodeVersion)' - inputs: - versionSpec: '$(NodeVersion)' - checkLatest: true - - # Install Rush repo dependencies - - script: | - node common/scripts/install-run-rush.js install --bypass-policy - displayName: Run Rush install in office-ui-fabric-react repository - - # Build package in Rush repo - - script: | - node common/scripts/install-run-rush.js build --to $(PackageName) - displayName: Run Rush build --to $(PackageName) - - # Run npm pack to simulate installation from feed - - script: | - npm pack ./packages/$(PackageName) - displayName: Run npm pack $(PackageName) - - # Save ReleaseId into a txt artifact file - - script: | - echo *.tgz | grep -oP '(?<=office-ui-fabric-react-).*(?=.tgz)' >> $(Build.StagingDirectory)/compatMap.txt - name: setReleaseIdStep - displayName: Save ReleaseId into a txt artifact file - - # Rename built package tarball to reference later - - script: | - mv *.tgz $(Build.StagingDirectory)/$(PackageName).tgz - displayName: Move $(PackageName).tgz to Build.StagingDirectory - - # Publish built library for validation job - - task: PublishBuildArtifacts@1 - displayName: Publish Build Artifacts - inputs: - pathtoPublish: $(Build.StagingDirectory) - artifactName: compatMapDrop - - - job: Compatibility - dependsOn: Build - condition: succeeded() - timeoutInMinutes: 60 - pool: - vmImage: $(VmImage) - strategy: - maxParallel: 1 - matrix: - 'TypeScript 2.4': - TypeScriptVersion: 2.4 - 'TypeScript 2.7': - TypeScriptVersion: 2.7 - 'TypeScript 2.8': - TypeScriptVersion: 2.8 - 'TypeScript 2.9': - TypeScriptVersion: 2.9 - 'TypeScript 3.0': - TypeScriptVersion: 3.0 - 'TypeScript 3.1': - TypeScriptVersion: 3.1 - 'TypeScript 3.2': - TypeScriptVersion: 3.2 - 'TypeScript 3.3': - TypeScriptVersion: 3.3 - 'TypeScript 3.4': - TypeScriptVersion: 3.4 - steps: - - checkout: none - - task: NodeTool@0 - displayName: 'Use Node $(NodeVersion)' - inputs: - versionSpec: '$(NodeVersion)' - checkLatest: true - - # Download build library - - task: DownloadBuildArtifacts@0 - displayName: 'Download Build Artifacts' - inputs: - artifactName: compatMapDrop - downloadPath: $(Build.StagingDirectory) - - # Clone repository containing versioned TypeScript sample apps - - script: | - git clone $(CompatRepoUrl) $(Build.StagingDirectory)/__tests__ - displayName: Clone compatibility repository - - # Install repository's dependencies - - script: | - node common/scripts/install-run-rush.js install - displayName: Run Rush install in compatibility repository - workingDirectory: $(Build.StagingDirectory)/__tests__ - - # Install built package tarball in sample app - - script: | - npm install $(Build.StagingDirectory)/compatMapDrop/$(PackageName).tgz - displayName: Install $(PackageName) in TypeScript $(TypeScriptVersion) test app - workingDirectory: $(Build.StagingDirectory)/__tests__/tests/$(TypeScriptVersion) - - # Build sample app consuming Fluent UI React to test TypeScript version compatibility - - script: | - node common/scripts/install-run-rush.js test --to $(TypeScriptVersion)-office-ui-fabric-react-test - displayName: Build TypeScript $(TypeScriptVersion) test app - workingDirectory: $(Build.StagingDirectory)/__tests__ - - # Write successful ts versions to compatMap.txt - - script: | - echo $(TypeScriptVersion) >> $(Build.StagingDirectory)/compatMapDrop/compatMap.txt - displayName: Write successful ts versions to compatMap.txt - - # Publish built library for validation job - - task: PublishBuildArtifacts@1 - displayName: Publish Build Artifacts - inputs: - pathtoPublish: $(Build.StagingDirectory)/compatMapDrop - artifactName: compatMapDrop - - - job: InvokePOSTAPI - dependsOn: Compatibility - condition: always() - timeoutInMinutes: 60 - pool: - vmImage: $(VmImage) - steps: - # Download build library - - task: DownloadBuildArtifacts@0 - displayName: 'Download Build Artifacts' - inputs: - artifactName: compatMapDrop - downloadPath: $(Build.StagingDirectory) - - # Invoke POST API with json body - # The artifact file compatMap.txt which has the TS compatibility folows the below format, - # where the first line is the OUFR release and the subsequent lines are the TS versions supported - # 6.182.1 - # 2.8 - # 2.9 - # 3.0 - # 3.1 - # 3.2 - # 3.3 - # 3.4 - # It is then concatenated into a format like 2.8, 2.9, 3.0, 3.1, 3.2, 3.3, 3.4 - # and the fabricweb backend API is invoked which writes these entrie to an Azure table - - powershell: $i = 0; - $releaseVersion = ""; - $compatibleTsVersions = ""; - $compatMapArray = Get-Content $env:BUILD_STAGINGDIRECTORY/compatMapDrop/compatMap.txt; - foreach($line in $compatMapArray) { - if($i -match 0) { - $releaseVersion = $line; - } else { - if($i -match 1) { - $compatibleTsVersions += $line; - } else { - $compatibleTsVersions += ", "; - $compatibleTsVersions += $line; - } - } - $i++; - } - Write-Host $releaseVersion; - Write-Host $compatibleTsVersions; - - $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"; - $headers.Add("AuthToken", "$(releaseVersionVariable)"); - $APIUrl = "https://fabricweb.azurewebsites.net/oufr/registerNewWithTsCompat?version=$releaseVersion&compatibleTsVersions=$compatibleTsVersions"; - $response = Invoke-RestMethod -Uri $APIUrl -Method Get -Headers $headers; - Write-Host $response; - displayName: Invoke POST API with json body diff --git a/scripts/update-package-versions.js b/scripts/update-package-versions.js deleted file mode 100644 index 1a937a2bffa83..0000000000000 --- a/scripts/update-package-versions.js +++ /dev/null @@ -1,60 +0,0 @@ -// @ts-check - -/** - * Script to update all versions and dependencies within the repo. - * - * Usage: - * - * node update-package-versions.js "6.0.0-alpha" ">=6.0.0-0 <7.0.0-0" - */ - -const process = require('process'); -const chalk = require('chalk'); -const getAllPackageInfo = require('./monorepo/getAllPackageInfo'); -const writeConfig = require('./write-config'); - -const allPackages = getAllPackageInfo(); -const newVersion = process.argv[2]; -const newDep = process.argv[3] || newVersion; - -function help() { - console.error( - 'update-package-versions.js - usage:\n node update-package-versions.js "6.0.0-alpha" ">=6.0.0-0 <7.0.0-0"', - ); -} - -if (!allPackages) { - help(); - console.error('Could not find get all the packages'); - process.exit(1); -} - -if (!newVersion || !newDep) { - help(); - console.error('Must specify newVersion and newDep'); - process.exit(1); -} - -for (const name of Object.keys(allPackages)) { - const info = allPackages[name]; - const packageJson = info.packageJson; - - console.log(`Updating ${chalk.magenta(name)} from ${chalk.grey(packageJson.version)} to ${chalk.green(newVersion)}.`); - - packageJson.version = newVersion; - - function updateDependencies(deps) { - for (const dependency in deps) { - if (Object.keys(allPackages).find(name => name === dependency)) { - console.log(` Updating deps ${dependency}`); - - deps[dependency] = newDep; - } - } - } - - updateDependencies(packageJson.dependencies); - updateDependencies(packageJson.devDependencies); - - writeConfig(info.packagePath, packageJson); -} diff --git a/scripts/find-config.js b/scripts/utils/find-config.js similarity index 95% rename from scripts/find-config.js rename to scripts/utils/find-config.js index c90ff576c038a..c6a119f9c40ee 100644 --- a/scripts/find-config.js +++ b/scripts/utils/find-config.js @@ -1,5 +1,3 @@ -// @ts-check - /** * Find a config file path, starting in the current directory and looking up to the Git root directory * (which contain .git) or the drive root. @@ -40,4 +38,4 @@ function findConfig(configName, cwd) { return undefined; } -module.exports = findConfig; +exports.findConfig = findConfig; diff --git a/scripts/utils/index.js b/scripts/utils/index.js new file mode 100644 index 0000000000000..e7b3c9c74b80a --- /dev/null +++ b/scripts/utils/index.js @@ -0,0 +1,5 @@ +module.exports = { + ...require('./find-config'), + ...require('./read-config'), + ...require('./write-config'), +}; diff --git a/scripts/logging.js b/scripts/utils/logging.js similarity index 89% rename from scripts/logging.js rename to scripts/utils/logging.js index 46c8d6556ab52..e0b45c7ac78f4 100644 --- a/scripts/logging.js +++ b/scripts/utils/logging.js @@ -8,7 +8,7 @@ const isVerbose = process.argv.indexOf('--verbose') > -1; * @param {string} packageName * @param {string} task */ -module.exports.logStartTask = (packageName, task) => { +exports.logStartTask = (packageName, task) => { console.log(`${getTimePrefix(packageName)} Starting: ${chalk.cyan(task)}`); }; @@ -19,7 +19,7 @@ module.exports.logStartTask = (packageName, task) => { * @param {number} startTime * @param {string} errorMessage */ -module.exports.logEndTask = (packageName, task, startTime, errorMessage) => { +exports.logEndTask = (packageName, task, startTime, errorMessage) => { console.log( `${getTimePrefix(packageName)} ${getPassFail(errorMessage === undefined)}: ${chalk.cyan(task)} (${getDuration( startTime, @@ -31,7 +31,7 @@ module.exports.logEndTask = (packageName, task, startTime, errorMessage) => { * * @param {unknown} taskStatus */ -module.exports.logStatus = taskStatus => { +exports.logStatus = taskStatus => { if (isProduction || isVerbose) { console.log(' ' + taskStatus); } @@ -43,7 +43,7 @@ module.exports.logStatus = taskStatus => { * @param {boolean} passed * @param {number} startTime */ -module.exports.logEndBuild = (packageName, passed, startTime) => { +exports.logEndBuild = (packageName, passed, startTime) => { console.log(); console.log( `${ diff --git a/scripts/read-config.js b/scripts/utils/read-config.js similarity index 87% rename from scripts/read-config.js rename to scripts/utils/read-config.js index ad7cfba63fde7..0345ea4b25328 100644 --- a/scripts/read-config.js +++ b/scripts/utils/read-config.js @@ -1,7 +1,5 @@ -// @ts-check - const fs = require('fs'); -const findConfig = require('./find-config'); +const { findConfig } = require('./find-config'); const jju = require('jju'); /** @@ -20,4 +18,4 @@ function readConfig(file, cwd) { } } -module.exports = { readConfig }; +exports.readConfig = readConfig; diff --git a/scripts/utils/tsconfig.json b/scripts/utils/tsconfig.json new file mode 100644 index 0000000000000..1401d82c3b085 --- /dev/null +++ b/scripts/utils/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../tsconfig.scripts.json", + "compilerOptions": { + "types": ["node"] + }, + "include": ["**/*.js"] +} diff --git a/scripts/write-config.js b/scripts/utils/write-config.js similarity index 71% rename from scripts/write-config.js rename to scripts/utils/write-config.js index 9fe1cd62df984..13fcdf63f5796 100644 --- a/scripts/write-config.js +++ b/scripts/utils/write-config.js @@ -1,19 +1,19 @@ const fs = require('fs'); -const findConfig = require('./find-config'); +const { findConfig } = require('./find-config'); const jju = require('jju'); /** * Make the requested updates to the given config file. * - * @param {string} file Full path to or name of the config file. If no file exists at the location + * @param {string} filePath Full path to or name of the config file. If no file exists at the location * as given, `file` is assumed to be a config file name and the method will run * `findConfig(file)` to find the full path. * @param {any} newValue Object representing the new contents of the file. Any comments from the * original file should be preserved. * @returns True if operation succeeded */ -function writeConfig(file, newValue) { - file = findConfig(file); +function writeConfig(filePath, newValue) { + const file = findConfig(filePath); if (!file) { return false; } @@ -27,4 +27,4 @@ function writeConfig(file, newValue) { return true; } -module.exports = writeConfig; +exports.writeConfig = writeConfig; diff --git a/scripts/webpack/getResolveAlias.js b/scripts/webpack/getResolveAlias.js index d96cc20127b80..d13f7de1613a0 100644 --- a/scripts/webpack/getResolveAlias.js +++ b/scripts/webpack/getResolveAlias.js @@ -1,7 +1,7 @@ const path = require('path'); const { findRepoDeps, findGitRoot } = require('../monorepo'); -const { readConfig } = require('../read-config'); +const { readConfig } = require('../utils'); /** * diff --git a/tools/generators/migrate-v8-pkg/index.spec.ts b/tools/generators/migrate-v8-pkg/index.spec.ts index 361fc9df78f4c..3f23fea7a0bdb 100644 --- a/tools/generators/migrate-v8-pkg/index.spec.ts +++ b/tools/generators/migrate-v8-pkg/index.spec.ts @@ -124,7 +124,7 @@ function setupDummyPackage( 'build-storybook': 'cross-env NODE_OPTIONS=--max-old-space-size=3072 just-scripts storybook:build', clean: 'just-scripts clean', 'code-style': 'just-scripts code-style', - codepen: 'node ../../scripts/local-codepen.js', + codepen: 'node ../../scripts/executors/local-codepen.js', e2e: 'yarn workspace @fluentui/react-examples e2e --package react', just: 'just-scripts', lint: 'just-scripts lint', diff --git a/yarn.lock b/yarn.lock index 04e2ca97345a8..b95dbe234f3f2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5774,6 +5774,13 @@ dependencies: "@types/node" "*" +"@types/prompts@2.4.1": + version "2.4.1" + resolved "https://registry.yarnpkg.com/@types/prompts/-/prompts-2.4.1.tgz#d47adcb608a0afcd48121ff7c75244694a3a04c5" + integrity sha512-1Mqzhzi9W5KlooNE4o0JwSXGUDeQXKldbGn9NO4tpxwZbHXYd+WcKpCksG2lbhH7U9I9LigfsdVsP2QAY0lNPA== + dependencies: + "@types/node" "*" + "@types/prop-types@*", "@types/prop-types@15.7.1": version "15.7.1" resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.1.tgz#f1a11e7babb0c3cad68100be381d1e064c68f1f6" @@ -21725,7 +21732,7 @@ promise@^8.1.0: dependencies: asap "~2.0.6" -prompts@^2.0.1, prompts@^2.1.0, prompts@^2.3.0, prompts@^2.4.0: +prompts@2.4.2, prompts@^2.0.1, prompts@^2.1.0, prompts@^2.4.0: version "2.4.2" resolved "https://registry.yarnpkg.com/prompts/-/prompts-2.4.2.tgz#7b57e73b3a48029ad10ebd44f74b01722a4cb069" integrity sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==