@ryanatkn/gro 0.179.0 → 0.181.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/build.task.d.ts +2 -0
- package/dist/build.task.d.ts.map +1 -1
- package/dist/build.task.js +15 -11
- package/dist/build_cache.d.ts +4 -4
- package/dist/build_cache.d.ts.map +1 -1
- package/dist/build_cache.js +54 -44
- package/dist/changelog.d.ts +2 -2
- package/dist/changelog.d.ts.map +1 -1
- package/dist/changeset.task.js +11 -11
- package/dist/check.task.js +2 -2
- package/dist/child_process_logging.js +1 -1
- package/dist/clean.task.js +2 -2
- package/dist/clean_fs.d.ts +1 -1
- package/dist/clean_fs.d.ts.map +1 -1
- package/dist/clean_fs.js +3 -4
- package/dist/cli.d.ts +7 -7
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +11 -12
- package/dist/commit.task.js +2 -2
- package/dist/deploy.task.d.ts +7 -0
- package/dist/deploy.task.d.ts.map +1 -1
- package/dist/deploy.task.js +30 -17
- package/dist/disknode.d.ts +1 -1
- package/dist/disknode.d.ts.map +1 -1
- package/dist/esbuild_helpers.d.ts +1 -1
- package/dist/esbuild_helpers.d.ts.map +1 -1
- package/dist/esbuild_plugin_external_worker.d.ts +1 -1
- package/dist/esbuild_plugin_external_worker.d.ts.map +1 -1
- package/dist/esbuild_plugin_external_worker.js +1 -1
- package/dist/esbuild_plugin_svelte.js +4 -4
- package/dist/esbuild_plugin_sveltekit_local_imports.js +2 -2
- package/dist/esbuild_plugin_sveltekit_shim_alias.js +1 -1
- package/dist/filer.d.ts +4 -4
- package/dist/filer.d.ts.map +1 -1
- package/dist/filer.js +105 -54
- package/dist/format.task.js +1 -1
- package/dist/format_directory.d.ts +2 -2
- package/dist/format_directory.d.ts.map +1 -1
- package/dist/format_file.js +1 -1
- package/dist/gen.d.ts +5 -5
- package/dist/gen.d.ts.map +1 -1
- package/dist/gen.js +28 -22
- package/dist/gen.task.js +3 -3
- package/dist/gen_helpers.d.ts +3 -3
- package/dist/gen_helpers.d.ts.map +1 -1
- package/dist/github.d.ts +2 -2
- package/dist/github.d.ts.map +1 -1
- package/dist/github.js +1 -1
- package/dist/gro.config.default.js +1 -1
- package/dist/gro_config.d.ts +1 -1
- package/dist/gro_config.d.ts.map +1 -1
- package/dist/gro_config.js +4 -4
- package/dist/gro_helpers.d.ts +1 -1
- package/dist/gro_helpers.d.ts.map +1 -1
- package/dist/gro_helpers.js +1 -1
- package/dist/gro_plugin_gen.js +4 -4
- package/dist/gro_plugin_server.d.ts +2 -2
- package/dist/gro_plugin_server.d.ts.map +1 -1
- package/dist/gro_plugin_server.js +7 -7
- package/dist/gro_plugin_sveltekit_app.d.ts.map +1 -1
- package/dist/gro_plugin_sveltekit_app.js +40 -36
- package/dist/gro_plugin_sveltekit_library.js +3 -2
- package/dist/input_path.d.ts +5 -5
- package/dist/input_path.d.ts.map +1 -1
- package/dist/input_path.js +17 -15
- package/dist/invoke.js +2 -2
- package/dist/invoke_task.d.ts +2 -2
- package/dist/invoke_task.d.ts.map +1 -1
- package/dist/invoke_task.js +5 -5
- package/dist/lint.task.js +2 -2
- package/dist/loader.js +2 -2
- package/dist/modules.d.ts +3 -3
- package/dist/modules.d.ts.map +1 -1
- package/dist/modules.js +4 -4
- package/dist/package_json.d.ts +6 -6
- package/dist/package_json.d.ts.map +1 -1
- package/dist/package_json.js +14 -16
- package/dist/parse_exports.d.ts +4 -4
- package/dist/parse_exports.d.ts.map +1 -1
- package/dist/parse_exports_context.d.ts +1 -1
- package/dist/parse_exports_context.d.ts.map +1 -1
- package/dist/parse_imports.d.ts +2 -2
- package/dist/parse_imports.d.ts.map +1 -1
- package/dist/parse_imports.js +1 -1
- package/dist/paths.d.ts +1 -1
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +1 -1
- package/dist/publish.task.js +8 -8
- package/dist/reinstall.task.js +1 -1
- package/dist/release.task.js +1 -1
- package/dist/resolve.task.js +2 -2
- package/dist/resolve_specifier.d.ts +2 -2
- package/dist/resolve_specifier.d.ts.map +1 -1
- package/dist/resolve_specifier.js +5 -4
- package/dist/run.task.js +2 -2
- package/dist/run_gen.d.ts +2 -2
- package/dist/run_gen.d.ts.map +1 -1
- package/dist/run_gen.js +10 -9
- package/dist/run_task.d.ts +2 -2
- package/dist/run_task.d.ts.map +1 -1
- package/dist/run_task.js +4 -4
- package/dist/source_json.d.ts +5 -5
- package/dist/source_json.d.ts.map +1 -1
- package/dist/source_json.js +18 -17
- package/dist/svelte_config.js +1 -1
- package/dist/sveltekit_helpers.d.ts +3 -3
- package/dist/sveltekit_helpers.d.ts.map +1 -1
- package/dist/sveltekit_helpers.js +4 -4
- package/dist/sveltekit_shim_app_forms.js +1 -1
- package/dist/sveltekit_shim_app_navigation.js +1 -1
- package/dist/sveltekit_shim_app_paths.js +1 -1
- package/dist/sveltekit_shim_env.js +1 -1
- package/dist/sync.task.js +1 -1
- package/dist/task.d.ts +5 -5
- package/dist/task.d.ts.map +1 -1
- package/dist/task.js +5 -5
- package/dist/task_logging.d.ts +1 -1
- package/dist/task_logging.d.ts.map +1 -1
- package/dist/task_logging.js +2 -2
- package/dist/test.task.d.ts.map +1 -1
- package/dist/test.task.js +5 -4
- package/dist/typecheck.task.js +4 -4
- package/dist/upgrade.task.js +6 -6
- package/dist/watch_dir.d.ts +1 -1
- package/dist/watch_dir.d.ts.map +1 -1
- package/dist/watch_dir.js +2 -2
- package/package.json +8 -8
- package/src/lib/build.task.ts +16 -11
- package/src/lib/build_cache.ts +81 -65
- package/src/lib/changelog.ts +2 -2
- package/src/lib/changeset.task.ts +12 -12
- package/src/lib/check.task.ts +2 -2
- package/src/lib/child_process_logging.ts +1 -1
- package/src/lib/clean.task.ts +2 -2
- package/src/lib/clean_fs.ts +4 -4
- package/src/lib/cli.ts +18 -17
- package/src/lib/commit.task.ts +2 -2
- package/src/lib/deploy.task.ts +33 -16
- package/src/lib/disknode.ts +1 -1
- package/src/lib/esbuild_helpers.ts +1 -1
- package/src/lib/esbuild_plugin_external_worker.ts +3 -3
- package/src/lib/esbuild_plugin_svelte.ts +4 -4
- package/src/lib/esbuild_plugin_sveltekit_local_imports.ts +2 -2
- package/src/lib/esbuild_plugin_sveltekit_shim_alias.ts +1 -1
- package/src/lib/filer.ts +117 -58
- package/src/lib/format.task.ts +1 -1
- package/src/lib/format_directory.ts +2 -2
- package/src/lib/format_file.ts +1 -1
- package/src/lib/gen.task.ts +3 -3
- package/src/lib/gen.ts +56 -50
- package/src/lib/gen_helpers.ts +3 -3
- package/src/lib/github.ts +2 -2
- package/src/lib/gro.config.default.ts +1 -1
- package/src/lib/gro_config.ts +5 -5
- package/src/lib/gro_helpers.ts +1 -1
- package/src/lib/gro_plugin_gen.ts +4 -4
- package/src/lib/gro_plugin_server.ts +9 -9
- package/src/lib/gro_plugin_sveltekit_app.ts +44 -40
- package/src/lib/gro_plugin_sveltekit_library.ts +3 -3
- package/src/lib/input_path.ts +23 -24
- package/src/lib/invoke.ts +2 -2
- package/src/lib/invoke_task.ts +5 -5
- package/src/lib/lint.task.ts +2 -2
- package/src/lib/loader.ts +2 -2
- package/src/lib/modules.ts +7 -7
- package/src/lib/package_json.ts +19 -23
- package/src/lib/parse_exports.ts +4 -4
- package/src/lib/parse_exports_context.ts +2 -2
- package/src/lib/parse_imports.ts +3 -3
- package/src/lib/paths.ts +2 -2
- package/src/lib/publish.task.ts +8 -8
- package/src/lib/reinstall.task.ts +1 -1
- package/src/lib/release.task.ts +1 -1
- package/src/lib/resolve.task.ts +2 -2
- package/src/lib/resolve_specifier.ts +9 -5
- package/src/lib/run.task.ts +2 -2
- package/src/lib/run_gen.ts +18 -13
- package/src/lib/run_task.ts +6 -6
- package/src/lib/source_json.ts +26 -22
- package/src/lib/svelte_config.ts +1 -1
- package/src/lib/sveltekit_helpers.ts +7 -7
- package/src/lib/sveltekit_shim_app_forms.ts +1 -1
- package/src/lib/sveltekit_shim_app_navigation.ts +1 -1
- package/src/lib/sveltekit_shim_app_paths.ts +1 -1
- package/src/lib/sync.task.ts +1 -1
- package/src/lib/task.ts +16 -14
- package/src/lib/task_logging.ts +3 -3
- package/src/lib/test.task.ts +4 -3
- package/src/lib/typecheck.task.ts +4 -4
- package/src/lib/upgrade.task.ts +6 -6
- package/src/lib/watch_dir.ts +3 -3
- package/dist/search_fs.d.ts +0 -26
- package/dist/search_fs.d.ts.map +0 -1
- package/dist/search_fs.js +0 -52
- package/src/lib/search_fs.ts +0 -100
package/dist/gen.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { join, basename, dirname, isAbsolute } from 'node:path';
|
|
2
2
|
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
3
3
|
import { styleText as st } from 'node:util';
|
|
4
|
-
import {
|
|
4
|
+
import { map_concurrent } from '@fuzdev/fuz_util/async.js';
|
|
5
|
+
import { fs_search } from '@fuzdev/fuz_util/fs.js';
|
|
5
6
|
import { print_path } from "./paths.js";
|
|
6
7
|
import { load_modules } from "./modules.js";
|
|
7
8
|
import { InputPath, resolve_input_files, resolve_input_paths, } from "./input_path.js";
|
|
8
|
-
import { search_fs } from "./search_fs.js";
|
|
9
9
|
export const GEN_FILE_PATTERN_TEXT = 'gen';
|
|
10
10
|
export const GEN_FILE_PATTERN = '.' + GEN_FILE_PATTERN_TEXT + '.';
|
|
11
11
|
export const is_gen_path = (path) => path.includes(GEN_FILE_PATTERN);
|
|
@@ -83,19 +83,26 @@ const validate_gen_files = (files) => {
|
|
|
83
83
|
ids.add(file.id);
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
|
-
export const analyze_gen_results = (gen_results) =>
|
|
87
|
-
.
|
|
88
|
-
|
|
86
|
+
export const analyze_gen_results = async (gen_results) => {
|
|
87
|
+
const files = gen_results.successes.flatMap((result) => result.files);
|
|
88
|
+
return map_concurrent(files, (file) => analyze_gen_result(file), 10);
|
|
89
|
+
};
|
|
89
90
|
export const analyze_gen_result = async (file) => {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
91
|
+
let existing_content;
|
|
92
|
+
try {
|
|
93
|
+
existing_content = await readFile(file.id, 'utf8');
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
if (error.code === 'ENOENT') {
|
|
97
|
+
return {
|
|
98
|
+
file,
|
|
99
|
+
existing_content: null,
|
|
100
|
+
is_new: true,
|
|
101
|
+
has_changed: true,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
throw error;
|
|
97
105
|
}
|
|
98
|
-
const existing_content = await readFile(file.id, 'utf8');
|
|
99
106
|
return {
|
|
100
107
|
file,
|
|
101
108
|
existing_content,
|
|
@@ -104,8 +111,8 @@ export const analyze_gen_result = async (file) => {
|
|
|
104
111
|
};
|
|
105
112
|
};
|
|
106
113
|
export const write_gen_results = async (gen_results, analyzed_gen_results, log) => {
|
|
107
|
-
|
|
108
|
-
|
|
114
|
+
const files = gen_results.successes.flatMap((result) => result.files);
|
|
115
|
+
await map_concurrent(files, async (file) => {
|
|
109
116
|
const analyzed = analyzed_gen_results.find((r) => r.file.id === file.id);
|
|
110
117
|
if (!analyzed)
|
|
111
118
|
throw Error('Expected to find analyzed result: ' + file.id);
|
|
@@ -122,17 +129,16 @@ export const write_gen_results = async (gen_results, analyzed_gen_results, log)
|
|
|
122
129
|
else {
|
|
123
130
|
log.info('skipping unchanged', ...log_args);
|
|
124
131
|
}
|
|
125
|
-
})
|
|
126
|
-
.flat());
|
|
132
|
+
}, 10);
|
|
127
133
|
};
|
|
128
134
|
/**
|
|
129
135
|
* Finds modules from input paths. (see `src/lib/input_path.ts` for more)
|
|
130
136
|
*/
|
|
131
|
-
export const find_genfiles = (input_paths, root_dirs, config, timings) => {
|
|
137
|
+
export const find_genfiles = async (input_paths, root_dirs, config, timings) => {
|
|
132
138
|
const extensions = [GEN_FILE_PATTERN];
|
|
133
139
|
// Check which extension variation works - if it's a directory, prefer others first!
|
|
134
140
|
const timing_to_resolve_input_paths = timings?.start('resolve input paths');
|
|
135
|
-
const { resolved_input_paths, unmapped_input_paths } = resolve_input_paths(input_paths, root_dirs, extensions);
|
|
141
|
+
const { resolved_input_paths, unmapped_input_paths } = await resolve_input_paths(input_paths, root_dirs, extensions);
|
|
136
142
|
timing_to_resolve_input_paths?.();
|
|
137
143
|
// Error if any input path could not be mapped.
|
|
138
144
|
if (unmapped_input_paths.length) {
|
|
@@ -145,12 +151,12 @@ export const find_genfiles = (input_paths, root_dirs, config, timings) => {
|
|
|
145
151
|
};
|
|
146
152
|
}
|
|
147
153
|
// Find all of the files for any directories.
|
|
148
|
-
const
|
|
149
|
-
const { resolved_input_files, resolved_input_files_by_root_dir, input_directories_with_no_files } = resolve_input_files(resolved_input_paths, (id) =>
|
|
154
|
+
const timing_to_fs_search = timings?.start('find files');
|
|
155
|
+
const { resolved_input_files, resolved_input_files_by_root_dir, input_directories_with_no_files } = await resolve_input_files(resolved_input_paths, async (id) => await fs_search(id, {
|
|
150
156
|
filter: config.search_filters,
|
|
151
157
|
file_filter: (p) => extensions.some((e) => p.includes(e)),
|
|
152
158
|
}));
|
|
153
|
-
|
|
159
|
+
timing_to_fs_search?.();
|
|
154
160
|
// Error if any input path has no files. (means we have an empty directory)
|
|
155
161
|
if (input_directories_with_no_files.length) {
|
|
156
162
|
return {
|
package/dist/gen.task.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { styleText as st } from 'node:util';
|
|
2
|
-
import { print_ms, print_error } from '@
|
|
3
|
-
import { plural } from '@
|
|
2
|
+
import { print_ms, print_error } from '@fuzdev/fuz_util/print.js';
|
|
3
|
+
import { plural } from '@fuzdev/fuz_util/string.js';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { TaskError } from "./task.js";
|
|
6
6
|
import { run_gen } from "./run_gen.js";
|
|
@@ -30,7 +30,7 @@ export const task = {
|
|
|
30
30
|
const { _: raw_input_paths, root_dirs, check } = args;
|
|
31
31
|
const input_paths = to_input_paths(raw_input_paths);
|
|
32
32
|
// load all of the gen modules
|
|
33
|
-
const found = find_genfiles(input_paths, root_dirs, config, timings);
|
|
33
|
+
const found = await find_genfiles(input_paths, root_dirs, config, timings);
|
|
34
34
|
if (!found.ok) {
|
|
35
35
|
if (found.type === 'input_directories_with_no_files') {
|
|
36
36
|
// TODO maybe let this error like the normal case, but only call `gro gen` if we find gen files? problem is the args would need to be hoisted to callers like `gro sync`
|
package/dist/gen_helpers.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Logger } from '@
|
|
2
|
-
import type { Timings } from '@
|
|
3
|
-
import type { PathId } from '@
|
|
1
|
+
import type { Logger } from '@fuzdev/fuz_util/log.js';
|
|
2
|
+
import type { Timings } from '@fuzdev/fuz_util/timings.js';
|
|
3
|
+
import type { PathId } from '@fuzdev/fuz_util/path.js';
|
|
4
4
|
import type { GroConfig } from './gro_config.ts';
|
|
5
5
|
import { type Filer } from './filer.ts';
|
|
6
6
|
import type { InvokeTask } from './task.ts';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gen_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/gen_helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"gen_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/gen_helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,6BAA6B,CAAC;AACzD,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,0BAA0B,CAAC;AAErD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAoB,KAAK,KAAK,EAAC,MAAM,YAAY,CAAC;AACzD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,WAAW,CAAC;AAY1C;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAC9B,aAAa,MAAM,EACnB,iBAAiB,MAAM,EACvB,QAAQ,SAAS,EACjB,OAAO,KAAK,EACZ,KAAK,MAAM,EACX,SAAS,OAAO,EAChB,aAAa,UAAU,KACrB,OAAO,CAAC,OAAO,CAqCjB,CAAC"}
|
package/dist/github.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FetchValueCache } from '@
|
|
2
|
-
import type { Logger } from '@
|
|
1
|
+
import { FetchValueCache } from '@fuzdev/fuz_util/fetch.js';
|
|
2
|
+
import type { Logger } from '@fuzdev/fuz_util/log.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
export declare const GITHUB_REPO_MATCHER: RegExp;
|
|
5
5
|
export declare const GithubPullRequest: z.ZodObject<{
|
package/dist/github.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/github.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,eAAe,EAAc,MAAM,
|
|
1
|
+
{"version":3,"file":"github.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/github.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,eAAe,EAAc,MAAM,2BAA2B,CAAC;AACvE,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,eAAO,MAAM,mBAAmB,QAA6B,CAAC;AAE9D,eAAO,MAAM,iBAAiB;;;;;;;;iBAQ5B,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAElE;;GAEG;AACH,eAAO,MAAM,uBAAuB,GACnC,OAAO,MAAM,EACb,MAAM,MAAM,EACZ,YAAY,MAAM,EAClB,QAAQ,MAAM,EACd,MAAM,MAAM,EACZ,QAAQ,eAAe,EACvB,cAAc,MAAM,KAClB,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAazC,CAAC"}
|
package/dist/github.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// TODO if this grows at all, use `@octokit/request`,
|
|
2
2
|
// for now it's just calling a single endpoint so we do it manually
|
|
3
3
|
// and we specify just the types we need
|
|
4
|
-
import { FetchValueCache, fetch_value } from '@
|
|
4
|
+
import { FetchValueCache, fetch_value } from '@fuzdev/fuz_util/fetch.js';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
export const GITHUB_REPO_MATCHER = /.+github.com\/(.+)\/(.+)/;
|
|
7
7
|
export const GithubPullRequest = z.looseObject({
|
|
@@ -15,7 +15,7 @@ import { load_package_json } from "./package_json.js";
|
|
|
15
15
|
* - if `src/lib/server/server.ts`, assumes a Node server - needs config
|
|
16
16
|
*/
|
|
17
17
|
const config = async (cfg, svelte_config) => {
|
|
18
|
-
const package_json = load_package_json(); // TODO gets wastefully loaded by some plugins, maybe put in plugin/task context? how does that interact with `map_package_json`?
|
|
18
|
+
const package_json = await load_package_json(); // TODO gets wastefully loaded by some plugins, maybe put in plugin/task context? how does that interact with `map_package_json`?
|
|
19
19
|
const [has_server_result, has_sveltekit_library_result, has_sveltekit_app_result] = await Promise.all([
|
|
20
20
|
has_server(),
|
|
21
21
|
has_sveltekit_library(package_json, svelte_config),
|
package/dist/gro_config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PathFilter, PathId } from '@
|
|
1
|
+
import type { PathFilter, PathId } from '@fuzdev/fuz_util/path.js';
|
|
2
2
|
import type { CreateConfigPlugins } from './plugin.ts';
|
|
3
3
|
import type { PackageJsonMapper } from './package_json.ts';
|
|
4
4
|
import type { ParsedSvelteConfig } from './svelte_config.ts';
|
package/dist/gro_config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gro_config.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/gro_config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,UAAU,EAAE,MAAM,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"gro_config.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/gro_config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,UAAU,EAAE,MAAM,EAAC,MAAM,0BAA0B,CAAC;AAcjE,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,oBAAoB,CAAC;AAG3D;;;GAGG;AACH,eAAO,MAAM,6BAA6B,qEACyB,CAAC;AAEpE;;;;GAIG;AACH,MAAM,WAAW,SAAU,SAAQ,YAAY;IAC9C;;OAEG;IACH,OAAO,EAAE,mBAAmB,CAAC;IAC7B;;;;OAIG;IACH,gBAAgB,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC3C;;;OAGG;IACH,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC9B;;;OAGG;IACH,cAAc,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IAClC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,sCAAsC;IACtC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC;;;;;OAKG;IACH,uBAAuB,EAAE,MAAM,CAAC;CAChC;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC5B,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,gBAAgB,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC5C,cAAc,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/B,cAAc,CAAC,EAAE,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;IACvD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;;;;;;;;;OAcG;IACH,kBAAkB,CAAC,EAChB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACvB,CAAC,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CACtE;AAED,MAAM,MAAM,eAAe,GAAG,CAC7B,WAAW,EAAE,SAAS,EACtB,aAAa,CAAC,EAAE,kBAAkB,KAC9B,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AAE1C,eAAO,MAAM,uBAAuB,QAAO,SAazC,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,QAUnC,CAAC;AAEF,eAAO,MAAM,wBAAwB,QAA+C,CAAC;AAErF;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAU,YAAY,YAAY,KAAG,OAAO,CAAC,SAAS,CA+CjF,CAAC;AAEF,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,eAAe,CAAC;CACjD;AAED,eAAO,MAAM,eAAe,GAAU,YAAgB,KAAG,OAAO,CAAC,SAAS,CAqBzE,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,CACxC,aAAa,EAAE,GAAG,EAClB,WAAW,EAAE,MAAM,KACf,OAAO,CAAC,aAAa,IAAI,eAS7B,CAAC"}
|
package/dist/gro_config.js
CHANGED
|
@@ -7,9 +7,9 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
7
7
|
return path;
|
|
8
8
|
};
|
|
9
9
|
import { join, resolve } from 'node:path';
|
|
10
|
-
import {
|
|
11
|
-
import { identity } from '@
|
|
12
|
-
import { json_stringify_deterministic } from '@
|
|
10
|
+
import { fs_exists } from '@fuzdev/fuz_util/fs.js';
|
|
11
|
+
import { identity } from '@fuzdev/fuz_util/function.js';
|
|
12
|
+
import { json_stringify_deterministic } from '@fuzdev/fuz_util/json.js';
|
|
13
13
|
import { GRO_DIST_DIR, IS_THIS_GRO, paths } from "./paths.js";
|
|
14
14
|
import { GRO_CONFIG_FILENAME, JS_CLI_DEFAULT, NODE_MODULES_DIRNAME, PM_CLI_DEFAULT, SERVER_DIST_PATH, SVELTEKIT_BUILD_DIRNAME, SVELTEKIT_DIST_DIRNAME, } from "./constants.js";
|
|
15
15
|
import create_default_config from "./gro.config.default.js";
|
|
@@ -88,7 +88,7 @@ export const cook_gro_config = async (raw_config) => {
|
|
|
88
88
|
export const load_gro_config = async (dir = paths.root) => {
|
|
89
89
|
const default_config = await cook_gro_config(await create_default_config(create_empty_gro_config()));
|
|
90
90
|
const config_path = join(dir, GRO_CONFIG_FILENAME);
|
|
91
|
-
if (!
|
|
91
|
+
if (!(await fs_exists(config_path))) {
|
|
92
92
|
// No user config file found, so return the default.
|
|
93
93
|
return default_config;
|
|
94
94
|
}
|
package/dist/gro_helpers.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gro_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/gro_helpers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAQ,KAAK,WAAW,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"gro_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/gro_helpers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAQ,KAAK,WAAW,EAAC,MAAM,6BAA6B,CAAC;AAUpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,uBAAuB,GAAI,aAAS,KAAG,MAsBnD,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,GAC7B,aAAa,MAAM,EACnB,aAAa,MAAM,EACnB,MAAM,KAAK,CAAC,MAAM,CAAC,EACnB,eAAuB,KACrB,OAAO,CAAC,WAAW,CAoBrB,CAAC"}
|
package/dist/gro_helpers.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { realpathSync, existsSync } from 'node:fs';
|
|
2
2
|
import { join, resolve } from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import { spawn } from '@
|
|
4
|
+
import { spawn } from '@fuzdev/fuz_util/process.js';
|
|
5
5
|
import { JS_CLI_DEFAULT, NODE_MODULES_DIRNAME, SVELTEKIT_DIST_DIRNAME } from "./constants.js";
|
|
6
6
|
/*
|
|
7
7
|
|
package/dist/gro_plugin_gen.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { EMPTY_OBJECT } from '@
|
|
2
|
-
import { throttle } from '@
|
|
3
|
-
import { UnreachableError } from '@
|
|
1
|
+
import { EMPTY_OBJECT } from '@fuzdev/fuz_util/object.js';
|
|
2
|
+
import { throttle } from '@fuzdev/fuz_util/throttle.js';
|
|
3
|
+
import { UnreachableError } from '@fuzdev/fuz_util/error.js';
|
|
4
4
|
import { paths } from "./paths.js";
|
|
5
5
|
import { find_genfiles, is_gen_path } from "./gen.js";
|
|
6
6
|
import { filter_dependents } from "./filer.js";
|
|
@@ -26,7 +26,7 @@ export const gro_plugin_gen = ({ input_paths = [paths.source], root_dirs = [path
|
|
|
26
26
|
// Some parts of the build may have already happened,
|
|
27
27
|
// making us miss `build` events for gen dependencies,
|
|
28
28
|
// so we run a full `gen` here even if it's usually wasteful.
|
|
29
|
-
const found = find_genfiles(input_paths, root_dirs, config);
|
|
29
|
+
const found = await find_genfiles(input_paths, root_dirs, config);
|
|
30
30
|
if (found.ok && found.value.resolved_input_files.length > 0) {
|
|
31
31
|
await gen();
|
|
32
32
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as esbuild from 'esbuild';
|
|
2
2
|
import type { Config as SvelteConfig } from '@sveltejs/kit';
|
|
3
|
-
import type { Result } from '@
|
|
4
|
-
import type { PathId } from '@
|
|
3
|
+
import type { Result } from '@fuzdev/fuz_util/result.js';
|
|
4
|
+
import type { PathId } from '@fuzdev/fuz_util/path.js';
|
|
5
5
|
import type { Plugin } from './plugin.ts';
|
|
6
6
|
export declare const SERVER_SOURCE_ID: PathId;
|
|
7
7
|
export declare const has_server: (path?: PathId) => Promise<Result<object, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gro_plugin_server.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/gro_plugin_server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,EAAC,MAAM,IAAI,YAAY,EAAC,MAAM,eAAe,CAAC;AAI1D,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"gro_plugin_server.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/gro_plugin_server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,EAAC,MAAM,IAAI,YAAY,EAAC,MAAM,eAAe,CAAC;AAI1D,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,4BAA4B,CAAC;AAGvD,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,0BAA0B,CAAC;AAErD,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAcxC,eAAO,MAAM,gBAAgB,QAA0D,CAAC;AAExF,eAAO,MAAM,UAAU,GACtB,aAAuB,KACrB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,CAAC,CAK3C,CAAC;AAEF,MAAM,WAAW,sBAAsB;IACtC;;OAEG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC7B;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B;;OAEG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC;;OAEG;IACH,aAAa,CAAC,EAAE,YAAY,CAAC;IAC7B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,CAAC,YAAY,EAAE,OAAO,CAAC,YAAY,KAAK,OAAO,CAAC,YAAY,CAAC;IACrF;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;CACd;AAED,MAAM,WAAW,QAAQ;IACxB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,QAAQ,CAAC;AAExD,eAAO,MAAM,iBAAiB,GAAI,mJAgB/B,sBAA2B,KAAG,MAsJhC,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { spawn_restartable_process } from '@
|
|
1
|
+
import { spawn_restartable_process } from '@fuzdev/fuz_util/process.js';
|
|
2
2
|
import * as esbuild from 'esbuild';
|
|
3
3
|
import { join, resolve } from 'node:path';
|
|
4
|
-
import { identity } from '@
|
|
5
|
-
import { strip_before, strip_end } from '@
|
|
6
|
-
import { fs_exists } from '@
|
|
7
|
-
import { throttle } from '@
|
|
4
|
+
import { identity } from '@fuzdev/fuz_util/function.js';
|
|
5
|
+
import { strip_before, strip_end } from '@fuzdev/fuz_util/string.js';
|
|
6
|
+
import { fs_exists } from '@fuzdev/fuz_util/fs.js';
|
|
7
|
+
import { throttle } from '@fuzdev/fuz_util/throttle.js';
|
|
8
8
|
import { base_path_to_path_id, LIB_DIRNAME, paths } from "./paths.js";
|
|
9
9
|
import { GRO_DEV_DIRNAME, SERVER_DIST_PATH } from "./constants.js";
|
|
10
10
|
import { parse_svelte_config, default_svelte_config } from "./svelte_config.js";
|
|
@@ -104,8 +104,8 @@ export const gro_plugin_server = ({ entry_points = [SERVER_SOURCE_ID], dir = pro
|
|
|
104
104
|
try {
|
|
105
105
|
build_result = await build_ctx.rebuild();
|
|
106
106
|
}
|
|
107
|
-
catch (
|
|
108
|
-
log.error('[gro_plugin_server] build failed',
|
|
107
|
+
catch (error) {
|
|
108
|
+
log.error('[gro_plugin_server] build failed', error);
|
|
109
109
|
return;
|
|
110
110
|
}
|
|
111
111
|
const { metafile } = build_result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gro_plugin_sveltekit_app.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/gro_plugin_sveltekit_app.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gro_plugin_sveltekit_app.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/gro_plugin_sveltekit_app.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAExC,OAAO,EAAyB,KAAK,iBAAiB,EAAoB,MAAM,mBAAmB,CAAC;AAGpG,OAAO,EAAC,KAAK,gBAAgB,EAA4C,MAAM,kBAAkB,CAAC;AAKlG,MAAM,WAAW,4BAA4B;IAC5C;;;OAGG;IACH,WAAW,CAAC,EAAE,UAAU,CAAC;IAEzB;;;OAGG;IACH,uBAAuB,CAAC,EAAE,OAAO,GAAG,iBAAiB,CAAC;IAEtD;;;OAGG;IACH,sBAAsB,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAAC;IAEpD;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,GAAG,cAAc,CAAC;IAChD;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE5D,MAAM,MAAM,cAAc,GAAG,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;AAE5D,eAAO,MAAM,wBAAwB,GAAI,oGAMtC,4BAAiC,KAAG,MAmHtC,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { cp, mkdir, rm, writeFile } from 'node:fs/promises';
|
|
2
2
|
import { dirname, join } from 'node:path';
|
|
3
|
+
import { fs_exists } from '@fuzdev/fuz_util/fs.js';
|
|
3
4
|
import { serialize_args, to_forwarded_args } from "./args.js";
|
|
4
5
|
import { serialize_package_json, load_package_json } from "./package_json.js";
|
|
5
6
|
import { TaskError } from "./task.js";
|
|
@@ -13,14 +14,14 @@ export const gro_plugin_sveltekit_app = ({ host_target = 'github_pages', well_kn
|
|
|
13
14
|
return {
|
|
14
15
|
name: 'gro_plugin_sveltekit_app',
|
|
15
16
|
setup: async ({ dev, watch, log, config }) => {
|
|
16
|
-
const found_vite_cli = find_cli(vite_cli);
|
|
17
|
+
const found_vite_cli = await find_cli(vite_cli);
|
|
17
18
|
if (!found_vite_cli)
|
|
18
19
|
throw Error(`Failed to find Vite CLI \`${vite_cli}\`, do you need to run \`${config.pm_cli} i\`?`);
|
|
19
20
|
if (dev) {
|
|
20
21
|
// `vite dev` in development mode
|
|
21
22
|
if (watch) {
|
|
22
23
|
const serialized_args = ['dev', ...serialize_args(to_forwarded_args(vite_cli))];
|
|
23
|
-
sveltekit_process = spawn_cli_process(found_vite_cli, serialized_args, log);
|
|
24
|
+
sveltekit_process = await spawn_cli_process(found_vite_cli, serialized_args, log);
|
|
24
25
|
}
|
|
25
26
|
else {
|
|
26
27
|
log.debug(`the SvelteKit app plugin is loaded but will not output anything` +
|
|
@@ -30,7 +31,7 @@ export const gro_plugin_sveltekit_app = ({ host_target = 'github_pages', well_kn
|
|
|
30
31
|
else {
|
|
31
32
|
// `vite build` in production mode
|
|
32
33
|
// `.well-known/package.json`
|
|
33
|
-
const package_json = load_package_json(); // TODO put in plugin context? same with sveltekit config?
|
|
34
|
+
const package_json = await load_package_json(); // TODO put in plugin context? same with sveltekit config?
|
|
34
35
|
if (well_known_package_json === undefined) {
|
|
35
36
|
well_known_package_json = package_json.public; // eslint-disable-line no-param-reassign
|
|
36
37
|
}
|
|
@@ -42,7 +43,7 @@ export const gro_plugin_sveltekit_app = ({ host_target = 'github_pages', well_kn
|
|
|
42
43
|
const serialized_package_json = mapped_package_json && serialize_package_json(mapped_package_json);
|
|
43
44
|
// `.well-known/source.json` and `.well-known/src/`
|
|
44
45
|
const final_package_json = mapped_package_json ?? package_json;
|
|
45
|
-
const source_json = source_json_create(final_package_json, undefined, log);
|
|
46
|
+
const source_json = await source_json_create(final_package_json, undefined, log);
|
|
46
47
|
if (well_known_source_json === undefined) {
|
|
47
48
|
well_known_source_json = final_package_json.public; // eslint-disable-line no-param-reassign
|
|
48
49
|
}
|
|
@@ -57,7 +58,7 @@ export const gro_plugin_sveltekit_app = ({ host_target = 'github_pages', well_kn
|
|
|
57
58
|
// copy files to `static` before building, in such a way
|
|
58
59
|
// that's non-destructive to existing files and dirs and easy to clean up
|
|
59
60
|
const { assets_path } = default_svelte_config;
|
|
60
|
-
const
|
|
61
|
+
const cleanup_promises = [
|
|
61
62
|
serialized_package_json
|
|
62
63
|
? create_temporarily(join(assets_path, '.well-known/package.json'), serialized_package_json)
|
|
63
64
|
: null,
|
|
@@ -79,9 +80,11 @@ export const gro_plugin_sveltekit_app = ({ host_target = 'github_pages', well_kn
|
|
|
79
80
|
? create_temporarily(join(assets_path, '.nojekyll'), '')
|
|
80
81
|
: null,
|
|
81
82
|
].filter((v) => v != null);
|
|
82
|
-
const
|
|
83
|
+
const cleanups = await Promise.all(cleanup_promises);
|
|
84
|
+
const cleanup = async () => {
|
|
85
|
+
// eslint-disable-next-line no-await-in-loop
|
|
83
86
|
for (const c of cleanups)
|
|
84
|
-
c();
|
|
87
|
+
await c();
|
|
85
88
|
};
|
|
86
89
|
try {
|
|
87
90
|
const serialized_args = ['build', ...serialize_args(to_forwarded_args(vite_cli))];
|
|
@@ -90,11 +93,11 @@ export const gro_plugin_sveltekit_app = ({ host_target = 'github_pages', well_kn
|
|
|
90
93
|
throw new TaskError(`${vite_cli} build failed with exit code ${spawned?.code}`);
|
|
91
94
|
}
|
|
92
95
|
}
|
|
93
|
-
catch (
|
|
94
|
-
cleanup();
|
|
95
|
-
throw
|
|
96
|
+
catch (error) {
|
|
97
|
+
await cleanup();
|
|
98
|
+
throw error;
|
|
96
99
|
}
|
|
97
|
-
cleanup();
|
|
100
|
+
await cleanup();
|
|
98
101
|
}
|
|
99
102
|
},
|
|
100
103
|
teardown: async () => {
|
|
@@ -106,32 +109,32 @@ export const gro_plugin_sveltekit_app = ({ host_target = 'github_pages', well_kn
|
|
|
106
109
|
};
|
|
107
110
|
};
|
|
108
111
|
// TODO probably extract these, and create a common helper or merge them
|
|
109
|
-
const copy_temporarily = (source_path, dest_dir, dest_base_dir = '', filter) => {
|
|
112
|
+
const copy_temporarily = async (source_path, dest_dir, dest_base_dir = '', filter) => {
|
|
110
113
|
const path = join(dest_dir, dest_base_dir, source_path);
|
|
111
114
|
const dir = dirname(path);
|
|
112
|
-
const dir_already_exists =
|
|
115
|
+
const dir_already_exists = await fs_exists(dir);
|
|
113
116
|
let root_created_dir;
|
|
114
117
|
if (!dir_already_exists) {
|
|
115
|
-
root_created_dir = to_root_dir_that_doesnt_exist(dir);
|
|
118
|
+
root_created_dir = await to_root_dir_that_doesnt_exist(dir);
|
|
116
119
|
if (!root_created_dir)
|
|
117
120
|
throw Error();
|
|
118
|
-
|
|
121
|
+
await mkdir(dir, { recursive: true });
|
|
119
122
|
}
|
|
120
|
-
const path_already_exists =
|
|
123
|
+
const path_already_exists = await fs_exists(path);
|
|
121
124
|
if (!path_already_exists) {
|
|
122
|
-
|
|
125
|
+
await cp(source_path, path, { recursive: true, filter });
|
|
123
126
|
}
|
|
124
|
-
return () => {
|
|
127
|
+
return async () => {
|
|
125
128
|
if (!dir_already_exists) {
|
|
126
129
|
if (!root_created_dir)
|
|
127
130
|
throw Error();
|
|
128
|
-
if (
|
|
129
|
-
|
|
131
|
+
if (await fs_exists(root_created_dir)) {
|
|
132
|
+
await rm(root_created_dir, { recursive: true });
|
|
130
133
|
}
|
|
131
134
|
}
|
|
132
135
|
else if (!path_already_exists) {
|
|
133
|
-
if (
|
|
134
|
-
|
|
136
|
+
if (await fs_exists(path)) {
|
|
137
|
+
await rm(path, { recursive: true });
|
|
135
138
|
}
|
|
136
139
|
}
|
|
137
140
|
};
|
|
@@ -143,31 +146,31 @@ const copy_temporarily = (source_path, dest_dir, dest_base_dir = '', filter) =>
|
|
|
143
146
|
* @param contents
|
|
144
147
|
* @returns cleanup function that deletes the file and any created dirs
|
|
145
148
|
*/
|
|
146
|
-
const create_temporarily = (path, contents) => {
|
|
149
|
+
const create_temporarily = async (path, contents) => {
|
|
147
150
|
const dir = dirname(path);
|
|
148
|
-
const dir_already_exists =
|
|
151
|
+
const dir_already_exists = await fs_exists(dir);
|
|
149
152
|
let root_created_dir;
|
|
150
153
|
if (!dir_already_exists) {
|
|
151
|
-
root_created_dir = to_root_dir_that_doesnt_exist(dir);
|
|
154
|
+
root_created_dir = await to_root_dir_that_doesnt_exist(dir);
|
|
152
155
|
if (!root_created_dir)
|
|
153
156
|
throw Error();
|
|
154
|
-
|
|
157
|
+
await mkdir(dir, { recursive: true });
|
|
155
158
|
}
|
|
156
|
-
const path_already_exists =
|
|
159
|
+
const path_already_exists = await fs_exists(path);
|
|
157
160
|
if (!path_already_exists) {
|
|
158
|
-
|
|
161
|
+
await writeFile(path, contents, 'utf8');
|
|
159
162
|
}
|
|
160
|
-
return () => {
|
|
163
|
+
return async () => {
|
|
161
164
|
if (!dir_already_exists) {
|
|
162
165
|
if (!root_created_dir)
|
|
163
166
|
throw Error();
|
|
164
|
-
if (
|
|
165
|
-
|
|
167
|
+
if (await fs_exists(root_created_dir)) {
|
|
168
|
+
await rm(root_created_dir, { recursive: true });
|
|
166
169
|
}
|
|
167
170
|
}
|
|
168
171
|
else if (!path_already_exists) {
|
|
169
|
-
if (
|
|
170
|
-
|
|
172
|
+
if (await fs_exists(path)) {
|
|
173
|
+
await rm(path);
|
|
171
174
|
}
|
|
172
175
|
}
|
|
173
176
|
};
|
|
@@ -177,11 +180,12 @@ const create_temporarily = (path, contents) => {
|
|
|
177
180
|
* for `/a/b/DOESNT_EXIST/NOR_THIS/ETC` returns `/a/b/DOESNT_EXIST`
|
|
178
181
|
* where `/a/b` does exist on the filesystem and `DOESNT_EXIST` is not one of its subdirectories.
|
|
179
182
|
*/
|
|
180
|
-
const to_root_dir_that_doesnt_exist = (dir) => {
|
|
183
|
+
const to_root_dir_that_doesnt_exist = async (dir) => {
|
|
181
184
|
let prev;
|
|
182
185
|
let d = dir;
|
|
183
186
|
do {
|
|
184
|
-
|
|
187
|
+
// eslint-disable-next-line no-await-in-loop
|
|
188
|
+
if (await fs_exists(d)) {
|
|
185
189
|
return prev;
|
|
186
190
|
}
|
|
187
191
|
prev = d;
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { print_spawn_result, spawn } from '@
|
|
1
|
+
import { print_spawn_result, spawn } from '@fuzdev/fuz_util/process.js';
|
|
2
2
|
import { TaskError } from "./task.js";
|
|
3
3
|
import { load_package_json } from "./package_json.js";
|
|
4
4
|
import { run_svelte_package } from "./sveltekit_helpers.js";
|
|
5
5
|
import { SVELTE_PACKAGE_CLI } from "./constants.js";
|
|
6
6
|
export const gro_plugin_sveltekit_library = ({ svelte_package_options, svelte_package_cli = SVELTE_PACKAGE_CLI, } = {}) => {
|
|
7
|
-
const package_json = load_package_json();
|
|
8
7
|
return {
|
|
9
8
|
name: 'gro_plugin_sveltekit_library',
|
|
10
9
|
setup: async ({ dev, log, config }) => {
|
|
11
10
|
if (!dev) {
|
|
11
|
+
const package_json = await load_package_json();
|
|
12
12
|
await run_svelte_package(package_json, svelte_package_options, svelte_package_cli, log, config.pm_cli);
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
adapt: async ({ log, timings, config }) => {
|
|
16
|
+
const package_json = await load_package_json();
|
|
16
17
|
// link the CLI binaries if they exist
|
|
17
18
|
if (package_json.bin) {
|
|
18
19
|
const timing_to_link = timings.start(`${config.pm_cli} link`);
|
package/dist/input_path.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import type { Flavored } from '@
|
|
3
|
-
import type { PathId, ResolvedPath } from '@
|
|
2
|
+
import type { Flavored } from '@fuzdev/fuz_util/types.js';
|
|
3
|
+
import type { PathId, ResolvedPath } from '@fuzdev/fuz_util/path.js';
|
|
4
4
|
export declare const InputPath: z.ZodString;
|
|
5
5
|
export type InputPath = Flavored<z.infer<typeof InputPath>, 'InputPath'>;
|
|
6
6
|
export declare const RawInputPath: z.ZodString;
|
|
@@ -28,7 +28,7 @@ export interface PossiblePath {
|
|
|
28
28
|
* Gets a list of possible source ids for each input path with `extensions`,
|
|
29
29
|
* duplicating each under `root_dirs`, without checking the filesystem.
|
|
30
30
|
*/
|
|
31
|
-
export declare const get_possible_paths: (input_path: InputPath, root_dirs: Array<PathId>, extensions: Array<string>) => Array<PossiblePath
|
|
31
|
+
export declare const get_possible_paths: (input_path: InputPath, root_dirs: Array<PathId>, extensions: Array<string>) => Promise<Array<PossiblePath>>;
|
|
32
32
|
export interface ResolvedInputPath {
|
|
33
33
|
input_path: InputPath;
|
|
34
34
|
id: PathId;
|
|
@@ -50,7 +50,7 @@ export interface ResolvedInputPaths {
|
|
|
50
50
|
* and stopping at the first existing file or falling back to the first existing directory.
|
|
51
51
|
* If none is found for an input path, it's added to `unmapped_input_paths`.
|
|
52
52
|
*/
|
|
53
|
-
export declare const resolve_input_paths: (input_paths: Array<InputPath>, root_dirs: Array<PathId>, extensions: Array<string>) => ResolvedInputPaths
|
|
53
|
+
export declare const resolve_input_paths: (input_paths: Array<InputPath>, root_dirs: Array<PathId>, extensions: Array<string>) => Promise<ResolvedInputPaths>;
|
|
54
54
|
export interface ResolvedInputFiles {
|
|
55
55
|
resolved_input_files: Array<ResolvedInputFile>;
|
|
56
56
|
resolved_input_files_by_root_dir: Map<PathId, Array<ResolvedInputFile>>;
|
|
@@ -60,5 +60,5 @@ export interface ResolvedInputFiles {
|
|
|
60
60
|
* Finds all of the matching files for the given input paths.
|
|
61
61
|
* De-dupes source ids.
|
|
62
62
|
*/
|
|
63
|
-
export declare const resolve_input_files: (resolved_input_paths: Array<ResolvedInputPath>, search?: (dir: string) => Array<ResolvedPath
|
|
63
|
+
export declare const resolve_input_files: (resolved_input_paths: Array<ResolvedInputPath>, search?: (dir: string) => Promise<Array<ResolvedPath>>) => Promise<ResolvedInputFiles>;
|
|
64
64
|
//# sourceMappingURL=input_path.d.ts.map
|
package/dist/input_path.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input_path.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/input_path.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"input_path.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/input_path.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AACtB,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,2BAA2B,CAAC;AACxD,OAAO,KAAK,EAAW,MAAM,EAAE,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAM7E,eAAO,MAAM,SAAS,aAAa,CAAC;AACpC,MAAM,MAAM,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,EAAE,WAAW,CAAC,CAAC;AAEzE,eAAO,MAAM,YAAY,aAAa,CAAC;AACvC,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,EAAE,cAAc,CAAC,CAAC;AAElF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,GACzB,gBAAgB,YAAY,EAC5B,kBAAyB,KACvB,SAOF,CAAC;AAEF,eAAO,MAAM,cAAc,GAC1B,iBAAiB,KAAK,CAAC,YAAY,CAAC,EACpC,YAAY,MAAM,KAChB,KAAK,CAAC,SAAS,CAA4D,CAAC;AAE/E,MAAM,WAAW,YAAY;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,SAAS,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAC9B,YAAY,SAAS,EACrB,WAAW,KAAK,CAAC,MAAM,CAAC,EACxB,YAAY,KAAK,CAAC,MAAM,CAAC,KACvB,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAiC7B,CAAC;AAEF,MAAM,WAAW,iBAAiB;IACjC,UAAU,EAAE,SAAS,CAAC;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,SAAS,CAAC;IACtB,mBAAmB,EAAE,iBAAiB,CAAC;CACvC;AAED,MAAM,WAAW,kBAAkB;IAClC,oBAAoB,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAC/C,4BAA4B,EAAE,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;IAClE,oBAAoB,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;CACvC;AAED;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAC/B,aAAa,KAAK,CAAC,SAAS,CAAC,EAC7B,WAAW,KAAK,CAAC,MAAM,CAAC,EACxB,YAAY,KAAK,CAAC,MAAM,CAAC,KACvB,OAAO,CAAC,kBAAkB,CAkD5B,CAAC;AAEF,MAAM,WAAW,kBAAkB;IAClC,oBAAoB,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAC/C,gCAAgC,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC;IACxE,+BAA+B,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;CAClD;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAC/B,sBAAsB,KAAK,CAAC,iBAAiB,CAAC,EAC9C,SAAQ,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAa,KAC/D,OAAO,CAAC,kBAAkB,CAgE5B,CAAC"}
|