Skip to content

Commit

Permalink
misc: make copyUntypedFiles work for watch mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Cena committed May 18, 2022
1 parent 5c3d3cf commit 16d705d
Show file tree
Hide file tree
Showing 51 changed files with 71 additions and 187 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 36 additions & 0 deletions admin/scripts/copyUntypedFiles.mjs
Original file line number Diff line number Diff line change
@@ -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();
}
1 change: 0 additions & 1 deletion packages/create-docusaurus/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
__tests__
node_modules
Expand Down
2 changes: 1 addition & 1 deletion packages/create-docusaurus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"scripts": {
"create-docusaurus": "create-docusaurus",
"build": "tsc --build",
"watch": "tsc --watch"
"watch": "tsc --build --watch"
},
"bin": "bin/index.js",
"publishConfig": {
Expand Down
1 change: 0 additions & 1 deletion packages/docusaurus-cssnano-preset/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__
1 change: 0 additions & 1 deletion packages/docusaurus-logger/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__
1 change: 0 additions & 1 deletion packages/docusaurus-mdx-loader/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__
1 change: 0 additions & 1 deletion packages/docusaurus-migrate/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-migrate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"scripts": {
"build": "tsc --build",
"watch": "tsc --watch"
"watch": "tsc --build --watch"
},
"repository": {
"type": "git",
Expand Down
1 change: 0 additions & 1 deletion packages/docusaurus-plugin-client-redirects/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__
1 change: 0 additions & 1 deletion packages/docusaurus-plugin-content-blog/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__
1 change: 0 additions & 1 deletion packages/docusaurus-plugin-content-docs/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-content-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion packages/docusaurus-plugin-content-pages/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__
1 change: 0 additions & 1 deletion packages/docusaurus-plugin-debug/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__
20 changes: 0 additions & 20 deletions packages/docusaurus-plugin-debug/copyUntypedFiles.mjs

This file was deleted.

6 changes: 4 additions & 2 deletions packages/docusaurus-plugin-debug/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion packages/docusaurus-plugin-google-analytics/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-google-analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"scripts": {
"build": "tsc --build",
"watch": "tsc --watch"
"watch": "tsc --build --watch"
},
"repository": {
"type": "git",
Expand Down
1 change: 0 additions & 1 deletion packages/docusaurus-plugin-google-gtag/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-google-gtag/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"types": "lib/index.d.ts",
"scripts": {
"build": "tsc --build",
"watch": "tsc --watch"
"watch": "tsc --build --watch"
},
"publishConfig": {
"access": "public"
Expand Down
1 change: 0 additions & 1 deletion packages/docusaurus-plugin-ideal-image/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__
20 changes: 0 additions & 20 deletions packages/docusaurus-plugin-ideal-image/copyUntypedFiles.mjs

This file was deleted.

5 changes: 4 additions & 1 deletion packages/docusaurus-plugin-ideal-image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion packages/docusaurus-plugin-pwa/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__
20 changes: 0 additions & 20 deletions packages/docusaurus-plugin-pwa/copyUntypedFiles.mjs

This file was deleted.

5 changes: 4 additions & 1 deletion packages/docusaurus-plugin-pwa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion packages/docusaurus-plugin-sitemap/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__
1 change: 0 additions & 1 deletion packages/docusaurus-preset-classic/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__
1 change: 0 additions & 1 deletion packages/docusaurus-remark-plugin-npm2yarn/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__
1 change: 0 additions & 1 deletion packages/docusaurus-theme-classic/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__
Expand Down
1 change: 0 additions & 1 deletion packages/docusaurus-theme-common/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__
20 changes: 0 additions & 20 deletions packages/docusaurus-theme-common/copyUntypedFiles.mjs

This file was deleted.

6 changes: 4 additions & 2 deletions packages/docusaurus-theme-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion packages/docusaurus-theme-live-codeblock/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__
20 changes: 0 additions & 20 deletions packages/docusaurus-theme-live-codeblock/copyUntypedFiles.mjs

This file was deleted.

5 changes: 4 additions & 1 deletion packages/docusaurus-theme-live-codeblock/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion packages/docusaurus-theme-search-algolia/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__
20 changes: 0 additions & 20 deletions packages/docusaurus-theme-search-algolia/copyUntypedFiles.mjs

This file was deleted.

5 changes: 4 additions & 1 deletion packages/docusaurus-theme-search-algolia/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion packages/docusaurus-theme-translations/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
copyUntypedFiles.mjs
.tsbuildinfo*
tsconfig*
__tests__
Expand Down
Loading

0 comments on commit 16d705d

Please sign in to comment.