misc: make copyUntypedFiles work for watch mode (#7445)

This commit is contained in:
Joshua Chen 2022-05-18 19:18:32 +08:00 committed by GitHub
parent 5c3d3cfef1
commit 6b53d4263d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
51 changed files with 71 additions and 187 deletions

View file

@ -14,7 +14,6 @@ packages/docusaurus-*/lib/*
packages/docusaurus-*/lib-next/
packages/eslint-plugin/lib/
packages/stylelint-copyright/lib/
copyUntypedFiles.mjs
packages/create-docusaurus/lib/*
packages/create-docusaurus/templates/facebook

View file

@ -0,0 +1,36 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import fs from 'fs-extra';
import path from 'path';
import chokidar from 'chokidar';
const srcDir = path.join(process.cwd(), 'src');
const libDir = path.join(process.cwd(), 'lib');
const ignoredPattern = /(?:__tests__|\.tsx?$)/;
async function copy() {
await fs.copy(srcDir, libDir, {
filter(testedPath) {
return !ignoredPattern.test(testedPath);
},
});
}
if (process.argv.includes('--watch')) {
const watcher = chokidar.watch(srcDir, {
ignored: ignoredPattern,
ignoreInitial: true,
persistent: true,
});
['add', 'change', 'unlink', 'addDir', 'unlinkDir'].forEach((event) =>
watcher.on(event, copy),
);
} else {
await copy();
}

View file

@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
__tests__
node_modules

View file

@ -14,7 +14,7 @@
"scripts": {
"create-docusaurus": "create-docusaurus",
"build": "tsc --build",
"watch": "tsc --watch"
"watch": "tsc --build --watch"
},
"bin": "bin/index.js",
"publishConfig": {

View file

@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -8,7 +8,7 @@
},
"scripts": {
"build": "tsc --build",
"watch": "tsc --watch"
"watch": "tsc --build --watch"
},
"repository": {
"type": "git",

View file

@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -13,7 +13,7 @@
"types": "src/plugin-content-docs.d.ts",
"scripts": {
"build": "tsc --build",
"watch": "tsc --watch"
"watch": "tsc --build --watch"
},
"publishConfig": {
"access": "public"

View file

@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,20 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import fs from 'fs-extra';
import {fileURLToPath} from 'url';
/**
* Copy all untyped and static assets files to lib.
*/
const srcDir = fileURLToPath(new URL('src', import.meta.url));
const libDir = fileURLToPath(new URL('lib', import.meta.url));
await fs.copy(srcDir, libDir, {
filter(filepath) {
return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath);
},
});

View file

@ -5,8 +5,10 @@
"main": "lib/index.js",
"types": "src/plugin-debug.d.ts",
"scripts": {
"build": "tsc --build && node copyUntypedFiles.mjs && prettier --config ../../.prettierrc --write \"lib/theme/**/*.js\"",
"watch": "node copyUntypedFiles.mjs && tsc --watch"
"build": "tsc --build && node ../../admin/scripts/copyUntypedFiles.mjs && prettier --config ../../.prettierrc --write \"lib/theme/**/*.js\"",
"watch": "run-p -c copy:watch build:watch",
"build:watch": "tsc --build --watch",
"copy:watch": "node ../../admin/scripts/copyUntypedFiles.mjs --watch"
},
"publishConfig": {
"access": "public"

View file

@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -9,7 +9,7 @@
},
"scripts": {
"build": "tsc --build",
"watch": "tsc --watch"
"watch": "tsc --build --watch"
},
"repository": {
"type": "git",

View file

@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -6,7 +6,7 @@
"types": "lib/index.d.ts",
"scripts": {
"build": "tsc --build",
"watch": "tsc --watch"
"watch": "tsc --build --watch"
},
"publishConfig": {
"access": "public"

View file

@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,20 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import fs from 'fs-extra';
import {fileURLToPath} from 'url';
/**
* Copy all untyped and static assets files to lib.
*/
const srcDir = fileURLToPath(new URL('src', import.meta.url));
const libDir = fileURLToPath(new URL('lib', import.meta.url));
await fs.copy(srcDir, libDir, {
filter(filepath) {
return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath);
},
});

View file

@ -5,7 +5,10 @@
"main": "lib/index.js",
"types": "src/plugin-ideal-image.d.ts",
"scripts": {
"build": "tsc --build && node copyUntypedFiles.mjs && prettier --config ../../.prettierrc --write \"lib/theme/**/*.js\""
"build": "tsc --build && node ../../admin/scripts/copyUntypedFiles.mjs && prettier --config ../../.prettierrc --write \"lib/theme/**/*.js\"",
"watch": "run-p -c copy:watch build:watch",
"build:watch": "tsc --build --watch",
"copy:watch": "node ../../admin/scripts/copyUntypedFiles.mjs --watch"
},
"publishConfig": {
"access": "public"

View file

@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,20 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import fs from 'fs-extra';
import {fileURLToPath} from 'url';
/**
* Copy all untyped and static assets files to lib.
*/
const srcDir = fileURLToPath(new URL('src', import.meta.url));
const libDir = fileURLToPath(new URL('lib', import.meta.url));
await fs.copy(srcDir, libDir, {
filter(filepath) {
return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath);
},
});

View file

@ -5,7 +5,10 @@
"main": "lib/index.js",
"types": "src/plugin-pwa.d.ts",
"scripts": {
"build": "tsc --build && node copyUntypedFiles.mjs && prettier --config ../../.prettierrc --write \"lib/theme/**/*.js\""
"build": "tsc --build && node ../../admin/scripts/copyUntypedFiles.mjs && prettier --config ../../.prettierrc --write \"lib/theme/**/*.js\"",
"watch": "run-p -c copy:watch build:watch",
"build:watch": "tsc --build --watch",
"copy:watch": "node ../../admin/scripts/copyUntypedFiles.mjs --watch"
},
"publishConfig": {
"access": "public"

View file

@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,20 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import fs from 'fs-extra';
import {fileURLToPath} from 'url';
/**
* Copy all untyped and static assets files to lib.
*/
const srcDir = fileURLToPath(new URL('src', import.meta.url));
const libDir = fileURLToPath(new URL('lib', import.meta.url));
await fs.copy(srcDir, libDir, {
filter(filepath) {
return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath);
},
});

View file

@ -13,8 +13,10 @@
"./Details": "./lib/components/Details/index.js"
},
"scripts": {
"build": "node copyUntypedFiles.mjs && tsc",
"watch": "node copyUntypedFiles.mjs && tsc --watch"
"build": "tsc && node ../../admin/scripts/copyUntypedFiles.mjs",
"watch": "run-p -c copy:watch build:watch",
"build:watch": "tsc --watch",
"copy:watch": "node ../../admin/scripts/copyUntypedFiles.mjs --watch"
},
"publishConfig": {
"access": "public"

View file

@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,20 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import fs from 'fs-extra';
import {fileURLToPath} from 'url';
/**
* Copy all untyped and static assets files to lib.
*/
const srcDir = fileURLToPath(new URL('src', import.meta.url));
const libDir = fileURLToPath(new URL('lib', import.meta.url));
await fs.copy(srcDir, libDir, {
filter(filepath) {
return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath);
},
});

View file

@ -11,7 +11,10 @@
"access": "public"
},
"scripts": {
"build": "tsc --build && node copyUntypedFiles.mjs && prettier --config ../../.prettierrc --write \"lib/theme/**/*.js\""
"build": "tsc --build && node ../../admin/scripts/copyUntypedFiles.mjs && prettier --config ../../.prettierrc --write \"lib/theme/**/*.js\"",
"watch": "run-p -c copy:watch build:watch",
"build:watch": "tsc --build --watch",
"copy:watch": "node ../../admin/scripts/copyUntypedFiles.mjs --watch"
},
"repository": {
"type": "git",

View file

@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,20 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import fs from 'fs-extra';
import {fileURLToPath} from 'url';
/**
* Copy all untyped and static assets files to lib.
*/
const srcDir = fileURLToPath(new URL('src', import.meta.url));
const libDir = fileURLToPath(new URL('lib', import.meta.url));
await fs.copy(srcDir, libDir, {
filter(filepath) {
return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath);
},
});

View file

@ -21,7 +21,10 @@
},
"license": "MIT",
"scripts": {
"build": "tsc --build && node copyUntypedFiles.mjs && prettier --config ../../.prettierrc --write \"lib/theme/**/*.js\""
"build": "tsc --build && node ../../admin/scripts/copyUntypedFiles.mjs && prettier --config ../../.prettierrc --write \"lib/theme/**/*.js\"",
"watch": "run-p -c copy:watch build:watch",
"build:watch": "tsc --build --watch",
"copy:watch": "node ../../admin/scripts/copyUntypedFiles.mjs --watch"
},
"dependencies": {
"@docsearch/react": "^3.0.0",

View file

@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -15,7 +15,7 @@
"license": "MIT",
"scripts": {
"build": "tsc --build",
"watch": "tsc --watch",
"watch": "tsc --build --watch",
"update": "node ./update.mjs"
},
"dependencies": {

View file

@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,20 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import fs from 'fs-extra';
import {fileURLToPath} from 'url';
/**
* Copy all untyped and static assets files to lib.
*/
const srcDir = fileURLToPath(new URL('src', import.meta.url));
const libDir = fileURLToPath(new URL('lib', import.meta.url));
await fs.copy(srcDir, libDir, {
filter(filepath) {
return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath);
},
});

View file

@ -24,8 +24,10 @@
"docusaurus": "bin/docusaurus.mjs"
},
"scripts": {
"build": "tsc --build && node copyUntypedFiles.mjs",
"watch": "node copyUntypedFiles.mjs && tsc --watch"
"build": "tsc --build && node ../../admin/scripts/copyUntypedFiles.mjs",
"watch": "run-p -c copy:watch build:watch",
"build:watch": "tsc --build --watch",
"copy:watch": "node ../../admin/scripts/copyUntypedFiles.mjs --watch"
},
"bugs": {
"url": "https://github.com/facebook/docusaurus/issues"

View file

@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -30,8 +30,7 @@
"netlify:crowdin:downloadTranslationsFailSafe": "yarn netlify:crowdin:wait && (yarn --cwd .. crowdin:download:website || echo 'Crowdin translation download failure (only internal PRs have access to the Crowdin env token)')",
"netlify:crowdin:uploadSources": "yarn --cwd .. crowdin:upload:website",
"netlify:test": "yarn netlify:build:deployPreview && npx --package netlify-cli netlify dev -- --debug",
"typecheck": "tsc",
"watch": "tsc --watch"
"typecheck": "tsc"
},
"dependencies": {
"@crowdin/cli": "^3.7.8",