项目文件夹

文件
wehub-resource-sync adf0d17497
publish / version_or_publish (push) Has been cancelled
storybook-build / changes (push) Has been cancelled
storybook-build / :storybook-build (push) Has been cancelled
Sync Gradio Skills to Hugging Face / sync-skills (push) Has been cancelled
functional / changes (push) Has been cancelled
functional / build-frontend (push) Has been cancelled
functional / functional-test-SSR=false (push) Has been cancelled
functional / functional-reload (push) Has been cancelled
js / changes (push) Has been cancelled
js / js-test (push) Has been cancelled
docs-build / changes (push) Has been cancelled
docs-build / docs-build (push) Has been cancelled
docs-build / website-build (push) Has been cancelled
functional / functional-test-SSR=true (push) Has been cancelled
hygiene / hygiene-test (push) Has been cancelled
python / changes (push) Has been cancelled
python / build (push) Has been cancelled
python / test-ubuntu-latest-flaky (push) Has been cancelled
python / test-ubuntu-latest-not-flaky (push) Has been cancelled
python / test-windows-latest-flaky (push) Has been cancelled
python / test-windows-latest-not-flaky (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:17:32 +08:00

105 行
3.2 KiB
Diff

diff --git a/src/cli.js b/src/cli.js
index ca28b1ee1464eeb3f41af007b887a110ebee74e3..e4784a61683424a4b6b481c5bcec1ae9bb5eefa0 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -30,9 +30,10 @@ prog
'--tsconfig',
'A path to a tsconfig or jsconfig file. When not provided, searches for the next upper tsconfig/jsconfig in the workspace path.'
)
+ .option('-c, --cwd', 'The current working directory')
.action(async (args) => {
try {
- const config = await load_config();
+ const config = await load_config({cwd: args.cwd});
// @ts-expect-error
if (config.package) {
diff --git a/src/index.js b/src/index.js
index b91aa92a2b9374ef1def61545690fc5304a40a3f..bc1311390223bac74caabbf26d022f5ed3bbc1c1 100644
--- a/src/index.js
+++ b/src/index.js
@@ -35,13 +35,34 @@ async function do_build(options, analyse_code) {
throw new Error(`${path.relative('.', input)} does not exist`);
}
- rimraf(temp);
- mkdirp(temp);
- const files = scan(input, extensions);
+
+ const tmp_input = path.join(input, 'tmp_input')
+
+ rimraf(temp);
+ rimraf(tmp_input)
+ mkdirp(temp);
+
+ mkdirp(tmp_input)
+ copy(input, tmp_input, {
+ filter: (p) =>
+ !p.includes('node_modules') &&
+ !p.includes('dist') &&
+ !p.includes('tmp_input') &&
+ !p.includes('public') &&
+ !p.endsWith('.stories.svelte') &&
+ !p.endsWith('.test.ts') &&
+ !p.endsWith('.spec.ts') &&
+ !p.endsWith('.md') &&
+ !p.endsWith('package.json') &&
+ !p.endsWith('.gitignore') &&
+ !p.endsWith('.svelte-kit')
+ })
+
+ const files = scan(tmp_input, extensions);
if (options.types) {
- await emit_dts(input, temp, output, options.cwd, alias, files, tsconfig);
+ await emit_dts(tmp_input, temp, output, options.cwd, alias, files, tsconfig);
}
/** @type {Map<string, import('typescript').CompilerOptions>} */
@@ -49,7 +70,7 @@ async function do_build(options, analyse_code) {
for (const file of files) {
await process_file(
- input,
+ tmp_input,
temp,
file,
options.config.preprocess,
@@ -66,11 +87,13 @@ async function do_build(options, analyse_code) {
mkdirp(output);
copy(temp, output);
+ rimraf(path.join(temp, ".."))
+ rimraf(tmp_input)
console.log(
colors
.bold()
- .green(`${path.relative(options.cwd, input)} -> ${path.relative(options.cwd, output)}`)
+ .green(`${path.relative(path.join(options.cwd, "..", ".."), input)} -> ${path.relative(options.cwd, output)}`)
);
}
diff --git a/src/typescript.js b/src/typescript.js
index 1105f935aa9827e990bf3aa53a26c7f3193420ec..ed5ba71889064176b4c374552b2f75e02d4677ae 100644
--- a/src/typescript.js
+++ b/src/typescript.js
@@ -22,6 +22,7 @@ import { load_pkg_json } from './config.js';
*/
export async function emit_dts(input, output, final_output, cwd, alias, files, tsconfig) {
const tmp = `${output}/__package_types_tmp__`;
+ const root = path.resolve(cwd, "..", "..")
rimraf(tmp);
mkdirp(tmp);
@@ -40,7 +41,7 @@ export async function emit_dts(input, output, final_output, cwd, alias, files, t
svelteShimsPath: no_svelte_3
? require.resolve('svelte2tsx/svelte-shims-v4.d.ts')
: require.resolve('svelte2tsx/svelte-shims.d.ts'),
- declarationDir: path.relative(cwd, tmp),
+ declarationDir: path.relative(root, tmp),
tsconfig
});