@ryanatkn/gro 0.191.0 → 0.192.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 +4 -278
- package/package.json +5 -142
- package/LICENSE +0 -21
- package/dist/args.d.ts +0 -37
- package/dist/args.d.ts.map +0 -1
- package/dist/args.js +0 -102
- package/dist/build.task.d.ts +0 -20
- package/dist/build.task.d.ts.map +0 -1
- package/dist/build.task.js +0 -119
- package/dist/build_cache.d.ts +0 -100
- package/dist/build_cache.d.ts.map +0 -1
- package/dist/build_cache.js +0 -299
- package/dist/changelog.d.ts +0 -11
- package/dist/changelog.d.ts.map +0 -1
- package/dist/changelog.js +0 -47
- package/dist/changeset.task.d.ts +0 -35
- package/dist/changeset.task.d.ts.map +0 -1
- package/dist/changeset.task.js +0 -151
- package/dist/changeset_helpers.d.ts +0 -17
- package/dist/changeset_helpers.d.ts.map +0 -1
- package/dist/changeset_helpers.js +0 -7
- package/dist/check.task.d.ts +0 -28
- package/dist/check.task.d.ts.map +0 -1
- package/dist/check.task.js +0 -104
- package/dist/child_process_logging.d.ts +0 -10
- package/dist/child_process_logging.d.ts.map +0 -1
- package/dist/child_process_logging.js +0 -26
- package/dist/clean.task.d.ts +0 -15
- package/dist/clean.task.d.ts.map +0 -1
- package/dist/clean.task.js +0 -40
- package/dist/clean_fs.d.ts +0 -9
- package/dist/clean_fs.d.ts.map +0 -1
- package/dist/clean_fs.js +0 -28
- package/dist/cli.d.ts +0 -34
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -61
- package/dist/commit.task.d.ts +0 -11
- package/dist/commit.task.d.ts.map +0 -1
- package/dist/commit.task.js +0 -24
- package/dist/constants.d.ts +0 -46
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -52
- package/dist/deploy.task.d.ts +0 -29
- package/dist/deploy.task.d.ts.map +0 -1
- package/dist/deploy.task.js +0 -217
- package/dist/dev.task.d.ts +0 -16
- package/dist/dev.task.d.ts.map +0 -1
- package/dist/dev.task.js +0 -44
- package/dist/disknode.d.ts +0 -23
- package/dist/disknode.d.ts.map +0 -1
- package/dist/disknode.js +0 -1
- package/dist/env.d.ts +0 -11
- package/dist/env.d.ts.map +0 -1
- package/dist/env.js +0 -49
- package/dist/esbuild_helpers.d.ts +0 -16
- package/dist/esbuild_helpers.d.ts.map +0 -1
- package/dist/esbuild_helpers.js +0 -36
- package/dist/esbuild_plugin_external_worker.d.ts +0 -23
- package/dist/esbuild_plugin_external_worker.d.ts.map +0 -1
- package/dist/esbuild_plugin_external_worker.js +0 -55
- package/dist/esbuild_plugin_svelte.d.ts +0 -15
- package/dist/esbuild_plugin_svelte.d.ts.map +0 -1
- package/dist/esbuild_plugin_svelte.js +0 -83
- package/dist/esbuild_plugin_sveltekit_local_imports.d.ts +0 -8
- package/dist/esbuild_plugin_sveltekit_local_imports.d.ts.map +0 -1
- package/dist/esbuild_plugin_sveltekit_local_imports.js +0 -30
- package/dist/esbuild_plugin_sveltekit_shim_alias.d.ts +0 -7
- package/dist/esbuild_plugin_sveltekit_shim_alias.d.ts.map +0 -1
- package/dist/esbuild_plugin_sveltekit_shim_alias.js +0 -18
- package/dist/esbuild_plugin_sveltekit_shim_app.d.ts +0 -9
- package/dist/esbuild_plugin_sveltekit_shim_app.d.ts.map +0 -1
- package/dist/esbuild_plugin_sveltekit_shim_app.js +0 -22
- package/dist/esbuild_plugin_sveltekit_shim_env.d.ts +0 -11
- package/dist/esbuild_plugin_sveltekit_shim_env.d.ts.map +0 -1
- package/dist/esbuild_plugin_sveltekit_shim_env.js +0 -18
- package/dist/filer.d.ts +0 -33
- package/dist/filer.d.ts.map +0 -1
- package/dist/filer.js +0 -385
- package/dist/format.task.d.ts +0 -11
- package/dist/format.task.d.ts.map +0 -1
- package/dist/format.task.js +0 -27
- package/dist/format_directory.d.ts +0 -13
- package/dist/format_directory.d.ts.map +0 -1
- package/dist/format_directory.js +0 -40
- package/dist/format_file.d.ts +0 -9
- package/dist/format_file.d.ts.map +0 -1
- package/dist/format_file.js +0 -42
- package/dist/gen.d.ts +0 -142
- package/dist/gen.d.ts.map +0 -1
- package/dist/gen.js +0 -199
- package/dist/gen.task.d.ts +0 -12
- package/dist/gen.task.d.ts.map +0 -1
- package/dist/gen.task.js +0 -149
- package/dist/gen_helpers.d.ts +0 -11
- package/dist/gen_helpers.d.ts.map +0 -1
- package/dist/gen_helpers.js +0 -76
- package/dist/github.d.ts +0 -19
- package/dist/github.d.ts.map +0 -1
- package/dist/github.js +0 -33
- package/dist/gro.config.default.d.ts +0 -13
- package/dist/gro.config.default.d.ts.map +0 -1
- package/dist/gro.config.default.js +0 -33
- package/dist/gro.d.ts +0 -3
- package/dist/gro.d.ts.map +0 -1
- package/dist/gro.js +0 -21
- package/dist/gro_config.d.ts +0 -115
- package/dist/gro_config.d.ts.map +0 -1
- package/dist/gro_config.js +0 -114
- package/dist/gro_helpers.d.ts +0 -49
- package/dist/gro_helpers.d.ts.map +0 -1
- package/dist/gro_helpers.js +0 -97
- package/dist/gro_plugin_gen.d.ts +0 -12
- package/dist/gro_plugin_gen.d.ts.map +0 -1
- package/dist/gro_plugin_gen.js +0 -101
- package/dist/gro_plugin_server.d.ts +0 -80
- package/dist/gro_plugin_server.d.ts.map +0 -1
- package/dist/gro_plugin_server.js +0 -167
- package/dist/gro_plugin_sveltekit_app.d.ts +0 -9
- package/dist/gro_plugin_sveltekit_app.d.ts.map +0 -1
- package/dist/gro_plugin_sveltekit_app.js +0 -42
- package/dist/gro_plugin_sveltekit_library.d.ts +0 -16
- package/dist/gro_plugin_sveltekit_library.d.ts.map +0 -1
- package/dist/gro_plugin_sveltekit_library.js +0 -34
- package/dist/index.d.ts +0 -9
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -4
- package/dist/input_path.d.ts +0 -64
- package/dist/input_path.d.ts.map +0 -1
- package/dist/input_path.js +0 -199
- package/dist/invoke.d.ts +0 -2
- package/dist/invoke.d.ts.map +0 -1
- package/dist/invoke.js +0 -28
- package/dist/invoke_task.d.ts +0 -30
- package/dist/invoke_task.d.ts.map +0 -1
- package/dist/invoke_task.js +0 -104
- package/dist/lint.task.d.ts +0 -11
- package/dist/lint.task.d.ts.map +0 -1
- package/dist/lint.task.js +0 -32
- package/dist/loader.d.ts +0 -6
- package/dist/loader.d.ts.map +0 -1
- package/dist/loader.js +0 -192
- package/dist/module.d.ts +0 -4
- package/dist/module.d.ts.map +0 -1
- package/dist/module.js +0 -6
- package/dist/modules.d.ts +0 -36
- package/dist/modules.d.ts.map +0 -1
- package/dist/modules.js +0 -71
- package/dist/package_json.d.ts +0 -32
- package/dist/package_json.d.ts.map +0 -1
- package/dist/package_json.js +0 -178
- package/dist/parse_exports.d.ts +0 -20
- package/dist/parse_exports.d.ts.map +0 -1
- package/dist/parse_exports.js +0 -65
- package/dist/parse_exports_context.d.ts +0 -21
- package/dist/parse_exports_context.d.ts.map +0 -1
- package/dist/parse_exports_context.js +0 -332
- package/dist/parse_imports.d.ts +0 -5
- package/dist/parse_imports.d.ts.map +0 -1
- package/dist/parse_imports.js +0 -140
- package/dist/paths.d.ts +0 -41
- package/dist/paths.d.ts.map +0 -1
- package/dist/paths.js +0 -69
- package/dist/plugin.d.ts +0 -36
- package/dist/plugin.d.ts.map +0 -1
- package/dist/plugin.js +0 -78
- package/dist/publish.task.d.ts +0 -26
- package/dist/publish.task.d.ts.map +0 -1
- package/dist/publish.task.js +0 -176
- package/dist/register.d.ts +0 -2
- package/dist/register.d.ts.map +0 -1
- package/dist/register.js +0 -2
- package/dist/reinstall.task.d.ts +0 -8
- package/dist/reinstall.task.d.ts.map +0 -1
- package/dist/reinstall.task.js +0 -35
- package/dist/release.task.d.ts +0 -8
- package/dist/release.task.d.ts.map +0 -1
- package/dist/release.task.js +0 -20
- package/dist/resolve.task.d.ts +0 -11
- package/dist/resolve.task.d.ts.map +0 -1
- package/dist/resolve.task.js +0 -38
- package/dist/resolve_specifier.d.ts +0 -22
- package/dist/resolve_specifier.d.ts.map +0 -1
- package/dist/resolve_specifier.js +0 -57
- package/dist/run.task.d.ts +0 -16
- package/dist/run.task.d.ts.map +0 -1
- package/dist/run.task.js +0 -52
- package/dist/run_gen.d.ts +0 -10
- package/dist/run_gen.d.ts.map +0 -1
- package/dist/run_gen.js +0 -73
- package/dist/run_task.d.ts +0 -17
- package/dist/run_task.d.ts.map +0 -1
- package/dist/run_task.js +0 -45
- package/dist/source_json.d.ts +0 -7
- package/dist/source_json.d.ts.map +0 -1
- package/dist/source_json.js +0 -145
- package/dist/svelte_config.d.ts +0 -57
- package/dist/svelte_config.d.ts.map +0 -1
- package/dist/svelte_config.js +0 -81
- package/dist/sveltekit_helpers.d.ts +0 -75
- package/dist/sveltekit_helpers.d.ts.map +0 -1
- package/dist/sveltekit_helpers.js +0 -94
- package/dist/sveltekit_shim_app.d.ts +0 -11
- package/dist/sveltekit_shim_app.d.ts.map +0 -1
- package/dist/sveltekit_shim_app.js +0 -31
- package/dist/sveltekit_shim_app_environment.d.ts +0 -13
- package/dist/sveltekit_shim_app_environment.d.ts.map +0 -1
- package/dist/sveltekit_shim_app_environment.js +0 -14
- package/dist/sveltekit_shim_app_forms.d.ts +0 -5
- package/dist/sveltekit_shim_app_forms.d.ts.map +0 -1
- package/dist/sveltekit_shim_app_forms.js +0 -6
- package/dist/sveltekit_shim_app_navigation.d.ts +0 -10
- package/dist/sveltekit_shim_app_navigation.d.ts.map +0 -1
- package/dist/sveltekit_shim_app_navigation.js +0 -11
- package/dist/sveltekit_shim_app_paths.d.ts +0 -17
- package/dist/sveltekit_shim_app_paths.d.ts.map +0 -1
- package/dist/sveltekit_shim_app_paths.js +0 -10
- package/dist/sveltekit_shim_app_state.d.ts +0 -5
- package/dist/sveltekit_shim_app_state.d.ts.map +0 -1
- package/dist/sveltekit_shim_app_state.js +0 -26
- package/dist/sveltekit_shim_env.d.ts +0 -5
- package/dist/sveltekit_shim_env.d.ts.map +0 -1
- package/dist/sveltekit_shim_env.js +0 -23
- package/dist/sync.task.d.ts +0 -16
- package/dist/sync.task.d.ts.map +0 -1
- package/dist/sync.task.js +0 -39
- package/dist/task.d.ts +0 -98
- package/dist/task.d.ts.map +0 -1
- package/dist/task.js +0 -109
- package/dist/task_logging.d.ts +0 -6
- package/dist/task_logging.d.ts.map +0 -1
- package/dist/task_logging.js +0 -201
- package/dist/test.task.d.ts +0 -13
- package/dist/test.task.d.ts.map +0 -1
- package/dist/test.task.js +0 -53
- package/dist/typecheck.task.d.ts +0 -13
- package/dist/typecheck.task.d.ts.map +0 -1
- package/dist/typecheck.task.js +0 -68
- package/dist/upgrade.task.d.ts +0 -20
- package/dist/upgrade.task.d.ts.map +0 -1
- package/dist/upgrade.task.js +0 -111
- package/dist/watch_dir.d.ts +0 -36
- package/dist/watch_dir.d.ts.map +0 -1
- package/dist/watch_dir.js +0 -69
- package/src/lib/args.ts +0 -115
- package/src/lib/build.task.ts +0 -151
- package/src/lib/build_cache.ts +0 -378
- package/src/lib/changelog.ts +0 -69
- package/src/lib/changeset.task.ts +0 -228
- package/src/lib/changeset_helpers.ts +0 -14
- package/src/lib/check.task.ts +0 -132
- package/src/lib/child_process_logging.ts +0 -38
- package/src/lib/clean.task.ts +0 -48
- package/src/lib/clean_fs.ts +0 -54
- package/src/lib/cli.ts +0 -98
- package/src/lib/commit.task.ts +0 -34
- package/src/lib/constants.ts +0 -56
- package/src/lib/deploy.task.ts +0 -287
- package/src/lib/dev.task.ts +0 -52
- package/src/lib/disknode.ts +0 -26
- package/src/lib/env.ts +0 -78
- package/src/lib/esbuild_helpers.ts +0 -49
- package/src/lib/esbuild_plugin_external_worker.ts +0 -94
- package/src/lib/esbuild_plugin_svelte.ts +0 -134
- package/src/lib/esbuild_plugin_sveltekit_local_imports.ts +0 -38
- package/src/lib/esbuild_plugin_sveltekit_shim_alias.ts +0 -27
- package/src/lib/esbuild_plugin_sveltekit_shim_app.ts +0 -42
- package/src/lib/esbuild_plugin_sveltekit_shim_env.ts +0 -47
- package/src/lib/filer.ts +0 -458
- package/src/lib/format.task.ts +0 -44
- package/src/lib/format_directory.ts +0 -65
- package/src/lib/format_file.ts +0 -49
- package/src/lib/gen.task.ts +0 -206
- package/src/lib/gen.ts +0 -406
- package/src/lib/gen_helpers.ts +0 -131
- package/src/lib/github.ts +0 -46
- package/src/lib/gro.config.default.ts +0 -42
- package/src/lib/gro.ts +0 -29
- package/src/lib/gro_config.ts +0 -254
- package/src/lib/gro_helpers.ts +0 -108
- package/src/lib/gro_plugin_gen.ts +0 -149
- package/src/lib/gro_plugin_server.ts +0 -288
- package/src/lib/gro_plugin_sveltekit_app.ts +0 -58
- package/src/lib/gro_plugin_sveltekit_library.ts +0 -63
- package/src/lib/index.ts +0 -8
- package/src/lib/input_path.ts +0 -254
- package/src/lib/invoke.ts +0 -34
- package/src/lib/invoke_task.ts +0 -139
- package/src/lib/lint.task.ts +0 -39
- package/src/lib/loader.ts +0 -229
- package/src/lib/module.ts +0 -13
- package/src/lib/modules.ts +0 -117
- package/src/lib/package_json.ts +0 -255
- package/src/lib/parse_exports.ts +0 -100
- package/src/lib/parse_exports_context.ts +0 -395
- package/src/lib/parse_imports.ts +0 -180
- package/src/lib/paths.ts +0 -111
- package/src/lib/plugin.ts +0 -106
- package/src/lib/publish.task.ts +0 -228
- package/src/lib/register.ts +0 -3
- package/src/lib/reinstall.task.ts +0 -45
- package/src/lib/release.task.ts +0 -26
- package/src/lib/resolve.task.ts +0 -43
- package/src/lib/resolve_specifier.ts +0 -81
- package/src/lib/run.task.ts +0 -65
- package/src/lib/run_gen.ts +0 -110
- package/src/lib/run_task.ts +0 -82
- package/src/lib/source_json.ts +0 -183
- package/src/lib/svelte_config.ts +0 -140
- package/src/lib/sveltekit_helpers.ts +0 -193
- package/src/lib/sveltekit_shim_app.ts +0 -41
- package/src/lib/sveltekit_shim_app_environment.ts +0 -16
- package/src/lib/sveltekit_shim_app_forms.ts +0 -13
- package/src/lib/sveltekit_shim_app_navigation.ts +0 -23
- package/src/lib/sveltekit_shim_app_paths.ts +0 -26
- package/src/lib/sveltekit_shim_app_state.ts +0 -35
- package/src/lib/sveltekit_shim_env.ts +0 -45
- package/src/lib/sync.task.ts +0 -47
- package/src/lib/task.ts +0 -245
- package/src/lib/task_logging.ts +0 -255
- package/src/lib/test.task.ts +0 -63
- package/src/lib/typecheck.task.ts +0 -81
- package/src/lib/upgrade.task.ts +0 -148
- package/src/lib/watch_dir.ts +0 -115
package/dist/build.task.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { styleText as st } from 'node:util';
|
|
3
|
-
import { git_check_clean_workspace, git_current_commit_hash } from '@fuzdev/fuz_util/git.js';
|
|
4
|
-
import { rm } from 'node:fs/promises';
|
|
5
|
-
import { join } from 'node:path';
|
|
6
|
-
import { fs_exists } from '@fuzdev/fuz_util/fs.js';
|
|
7
|
-
import { TaskError } from "./task.js";
|
|
8
|
-
import { Plugins } from "./plugin.js";
|
|
9
|
-
import { clean_fs } from "./clean_fs.js";
|
|
10
|
-
import { is_build_cache_valid, create_build_cache_metadata, save_build_cache_metadata, discover_build_output_dirs, } from "./build_cache.js";
|
|
11
|
-
import { paths } from "./paths.js";
|
|
12
|
-
/** @nodocs */
|
|
13
|
-
export const Args = z.strictObject({
|
|
14
|
-
sync: z.boolean().meta({ description: 'dual of no-sync' }).default(true),
|
|
15
|
-
'no-sync': z.boolean().meta({ description: 'opt out of gro sync' }).default(false),
|
|
16
|
-
gen: z.boolean().meta({ description: 'dual of no-gen' }).default(true),
|
|
17
|
-
'no-gen': z.boolean().meta({ description: 'opt out of gro gen' }).default(false),
|
|
18
|
-
install: z.boolean().meta({ description: 'dual of no-install' }).default(true),
|
|
19
|
-
'no-install': z // convenience, same as `gro build -- gro sync --no-install` but the latter takes precedence
|
|
20
|
-
.boolean()
|
|
21
|
-
.meta({ description: 'opt out of installing packages before building' })
|
|
22
|
-
.default(false),
|
|
23
|
-
force_build: z
|
|
24
|
-
.boolean()
|
|
25
|
-
.meta({ description: 'force a fresh build, ignoring the cache' })
|
|
26
|
-
.default(false),
|
|
27
|
-
});
|
|
28
|
-
/**
|
|
29
|
-
* Length of git commit hash when displayed in logs (standard git convention).
|
|
30
|
-
*/
|
|
31
|
-
export const GIT_SHORT_HASH_LENGTH = 7;
|
|
32
|
-
/**
|
|
33
|
-
* Formats a git commit hash for display in logs.
|
|
34
|
-
* Returns '[none]' if hash is null (e.g., not in a git repo).
|
|
35
|
-
*/
|
|
36
|
-
const format_commit_hash = (hash) => hash?.slice(0, GIT_SHORT_HASH_LENGTH) ?? '[none]';
|
|
37
|
-
/** @nodocs */
|
|
38
|
-
export const task = {
|
|
39
|
-
summary: 'build the project',
|
|
40
|
-
Args,
|
|
41
|
-
run: async (ctx) => {
|
|
42
|
-
const { args, invoke_task, log, config } = ctx;
|
|
43
|
-
const { sync, gen, install, force_build } = args;
|
|
44
|
-
if (sync || install) {
|
|
45
|
-
if (!sync)
|
|
46
|
-
log.warn('sync is false but install is true, so ignoring the sync option');
|
|
47
|
-
await invoke_task('sync', { install, gen: false });
|
|
48
|
-
}
|
|
49
|
-
if (gen) {
|
|
50
|
-
await invoke_task('gen');
|
|
51
|
-
}
|
|
52
|
-
// Batch git calls upfront for performance (spawning processes is expensive)
|
|
53
|
-
const [workspace_status, initial_commit] = await Promise.all([
|
|
54
|
-
git_check_clean_workspace(),
|
|
55
|
-
git_current_commit_hash(),
|
|
56
|
-
]);
|
|
57
|
-
const workspace_dirty = !!workspace_status;
|
|
58
|
-
// Discover build output directories once to avoid redundant filesystem scans
|
|
59
|
-
let build_dirs;
|
|
60
|
-
// Check build cache unless force_build is set or workspace is dirty
|
|
61
|
-
if (!workspace_dirty && !force_build) {
|
|
62
|
-
const cache_valid = await is_build_cache_valid(config, log, initial_commit);
|
|
63
|
-
if (cache_valid) {
|
|
64
|
-
log.info(st('cyan', 'skipping build, cache is valid'), st('dim', '(use --force_build to rebuild)'));
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
else if (workspace_dirty) {
|
|
69
|
-
// IMPORTANT: When workspace is dirty, we delete cache AND all outputs to prevent stale state.
|
|
70
|
-
// Rationale: Uncommitted changes could be reverted, leaving cached outputs from reverted code.
|
|
71
|
-
// This conservative approach prioritizes safety over convenience during development.
|
|
72
|
-
const cache_path = join(paths.build, 'build.json');
|
|
73
|
-
if (await fs_exists(cache_path)) {
|
|
74
|
-
await rm(cache_path, { force: true });
|
|
75
|
-
}
|
|
76
|
-
// Delete all build output directories
|
|
77
|
-
build_dirs = await discover_build_output_dirs();
|
|
78
|
-
await Promise.all(build_dirs.map((dir) => rm(dir, { recursive: true, force: true })));
|
|
79
|
-
log.info(st('yellow', 'workspace has uncommitted changes - skipping build cache'));
|
|
80
|
-
// Skip clean_fs - already manually cleaned cache and all build outputs above
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
log.info(st('yellow', 'forcing fresh build, ignoring cache'));
|
|
84
|
-
}
|
|
85
|
-
// Clean build outputs (skip if workspace was dirty - already cleaned manually above)
|
|
86
|
-
if (!workspace_dirty) {
|
|
87
|
-
await clean_fs({ build_dist: true });
|
|
88
|
-
}
|
|
89
|
-
const plugins = await Plugins.create({ ...ctx, dev: false, watch: false });
|
|
90
|
-
await plugins.setup();
|
|
91
|
-
await plugins.adapt();
|
|
92
|
-
await plugins.teardown();
|
|
93
|
-
// Verify workspace didn't become dirty during build
|
|
94
|
-
const final_workspace_status = await git_check_clean_workspace();
|
|
95
|
-
if (final_workspace_status !== workspace_status) {
|
|
96
|
-
// Workspace state changed during build - this indicates a problem
|
|
97
|
-
throw new TaskError('Build process modified tracked files or created untracked files.\n\n' +
|
|
98
|
-
'Git status after build:\n' +
|
|
99
|
-
final_workspace_status +
|
|
100
|
-
'\n\n' +
|
|
101
|
-
'Builds should only write to output directories (build/, dist/, etc.).\n' +
|
|
102
|
-
'This usually indicates a plugin or build step is incorrectly modifying source files.');
|
|
103
|
-
}
|
|
104
|
-
// Save build cache metadata after successful build (only if workspace is clean)
|
|
105
|
-
if (!workspace_dirty) {
|
|
106
|
-
// Race condition protection: verify git commit didn't change during build
|
|
107
|
-
const current_commit = await git_current_commit_hash();
|
|
108
|
-
if (current_commit !== initial_commit) {
|
|
109
|
-
log.warn(st('yellow', 'git commit changed during build'), st('dim', `(${format_commit_hash(initial_commit)} → ${format_commit_hash(current_commit)})`), '- cache not saved');
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
// Commit is stable - safe to save cache
|
|
113
|
-
const metadata = await create_build_cache_metadata(config, log, initial_commit, build_dirs);
|
|
114
|
-
await save_build_cache_metadata(metadata, log);
|
|
115
|
-
log.debug('Build cache metadata saved');
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
};
|
package/dist/build_cache.d.ts
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import type { Logger } from '@fuzdev/fuz_util/log.js';
|
|
3
|
-
import type { GroConfig } from './gro_config.ts';
|
|
4
|
-
export declare const BUILD_CACHE_METADATA_FILENAME = "build.json";
|
|
5
|
-
export declare const BUILD_CACHE_VERSION = "1";
|
|
6
|
-
/**
|
|
7
|
-
* Metadata about a single build output file.
|
|
8
|
-
* Includes cryptographic hash for validation plus filesystem stats for debugging and optimization.
|
|
9
|
-
*/
|
|
10
|
-
export declare const BuildOutputEntry: z.ZodObject<{
|
|
11
|
-
path: z.ZodString;
|
|
12
|
-
hash: z.ZodString;
|
|
13
|
-
size: z.ZodNumber;
|
|
14
|
-
mtime: z.ZodNumber;
|
|
15
|
-
ctime: z.ZodNumber;
|
|
16
|
-
mode: z.ZodNumber;
|
|
17
|
-
}, z.core.$strict>;
|
|
18
|
-
export type BuildOutputEntry = z.infer<typeof BuildOutputEntry>;
|
|
19
|
-
/**
|
|
20
|
-
* Metadata stored in .gro/ directory to track build cache validity.
|
|
21
|
-
* Schema validates structure at load time to catch corrupted cache files.
|
|
22
|
-
*/
|
|
23
|
-
export declare const BuildCacheMetadata: z.ZodObject<{
|
|
24
|
-
version: z.ZodString;
|
|
25
|
-
git_commit: z.ZodNullable<z.ZodString>;
|
|
26
|
-
build_cache_config_hash: z.ZodString;
|
|
27
|
-
timestamp: z.ZodString;
|
|
28
|
-
outputs: z.ZodArray<z.ZodObject<{
|
|
29
|
-
path: z.ZodString;
|
|
30
|
-
hash: z.ZodString;
|
|
31
|
-
size: z.ZodNumber;
|
|
32
|
-
mtime: z.ZodNumber;
|
|
33
|
-
ctime: z.ZodNumber;
|
|
34
|
-
mode: z.ZodNumber;
|
|
35
|
-
}, z.core.$strict>>;
|
|
36
|
-
}, z.core.$strict>;
|
|
37
|
-
export type BuildCacheMetadata = z.infer<typeof BuildCacheMetadata>;
|
|
38
|
-
/**
|
|
39
|
-
* Computes the cache key components for a build.
|
|
40
|
-
* This determines whether a cached build can be reused.
|
|
41
|
-
*
|
|
42
|
-
* @param config Gro config (build_cache_config_hash is already computed during config load)
|
|
43
|
-
* @param log Logger
|
|
44
|
-
* @param git_commit Optional pre-computed git commit hash (optimization to avoid re-reading)
|
|
45
|
-
*/
|
|
46
|
-
export declare const compute_build_cache_key: (config: GroConfig, log: Logger, git_commit?: string | null) => Promise<{
|
|
47
|
-
git_commit: string | null;
|
|
48
|
-
build_cache_config_hash: string;
|
|
49
|
-
}>;
|
|
50
|
-
/**
|
|
51
|
-
* Loads build cache metadata from .gro/ directory.
|
|
52
|
-
* Invalid or corrupted cache files are automatically deleted.
|
|
53
|
-
*/
|
|
54
|
-
export declare const load_build_cache_metadata: () => Promise<BuildCacheMetadata | null>;
|
|
55
|
-
/**
|
|
56
|
-
* Saves build cache metadata to .gro/ directory.
|
|
57
|
-
* Errors are logged but don't fail the build (cache is optional).
|
|
58
|
-
*/
|
|
59
|
-
export declare const save_build_cache_metadata: (metadata: BuildCacheMetadata, log?: Logger) => Promise<void>;
|
|
60
|
-
/**
|
|
61
|
-
* Validates that a cached build is still valid by checking stats and hashing outputs.
|
|
62
|
-
* Uses size as a fast negative check before expensive hashing.
|
|
63
|
-
* This is comprehensive validation to catch manual tampering or corruption.
|
|
64
|
-
*/
|
|
65
|
-
export declare const validate_build_cache: (metadata: BuildCacheMetadata) => Promise<boolean>;
|
|
66
|
-
/**
|
|
67
|
-
* Main function to check if the build cache is valid.
|
|
68
|
-
* Returns true if the cached build can be used, false if a fresh build is needed.
|
|
69
|
-
*
|
|
70
|
-
* @param config Gro config
|
|
71
|
-
* @param log Logger
|
|
72
|
-
* @param git_commit Optional pre-computed git commit hash (optimization)
|
|
73
|
-
*/
|
|
74
|
-
export declare const is_build_cache_valid: (config: GroConfig, log: Logger, git_commit?: string | null) => Promise<boolean>;
|
|
75
|
-
/**
|
|
76
|
-
* Collects information about all files in build output directories.
|
|
77
|
-
* Returns an array of entries with path, hash, size, mtime, ctime, and mode.
|
|
78
|
-
*
|
|
79
|
-
* Files are hashed in parallel for performance. For very large builds (10k+ files),
|
|
80
|
-
* this may take several seconds but ensures complete cache validation.
|
|
81
|
-
*
|
|
82
|
-
* @param build_dirs Array of output directories to scan (e.g., ['build', 'dist', 'dist_server'])
|
|
83
|
-
*/
|
|
84
|
-
export declare const collect_build_outputs: (build_dirs: Array<string>) => Promise<Array<BuildOutputEntry>>;
|
|
85
|
-
/**
|
|
86
|
-
* Discovers all build output directories in the current working directory.
|
|
87
|
-
* Returns an array of directory names that exist: build/, dist/, dist_*
|
|
88
|
-
*/
|
|
89
|
-
export declare const discover_build_output_dirs: () => Promise<Array<string>>;
|
|
90
|
-
/**
|
|
91
|
-
* Creates build cache metadata after a successful build.
|
|
92
|
-
* Automatically discovers all build output directories (build/, dist/, dist_*).
|
|
93
|
-
*
|
|
94
|
-
* @param config Gro config
|
|
95
|
-
* @param log Logger
|
|
96
|
-
* @param git_commit Optional pre-computed git commit hash (optimization)
|
|
97
|
-
* @param build_dirs Optional pre-discovered build directories (optimization to avoid redundant filesystem scans)
|
|
98
|
-
*/
|
|
99
|
-
export declare const create_build_cache_metadata: (config: GroConfig, log: Logger, git_commit?: string | null, build_dirs?: Array<string>) => Promise<BuildCacheMetadata>;
|
|
100
|
-
//# sourceMappingURL=build_cache.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build_cache.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/build_cache.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AACtB,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAMpD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAI/C,eAAO,MAAM,6BAA6B,eAAe,CAAC;AAC1D,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAEvC;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;;;kBAW3B,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;kBAU7B,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEpE;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,GACnC,QAAQ,SAAS,EACjB,KAAK,MAAM,EACX,aAAa,MAAM,GAAG,IAAI,KACxB,OAAO,CAAC;IACV,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,uBAAuB,EAAE,MAAM,CAAC;CAChC,CAYA,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,yBAAyB,QAAa,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAoCnF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,yBAAyB,GACrC,UAAU,kBAAkB,EAC5B,MAAM,MAAM,KACV,OAAO,CAAC,IAAI,CAcd,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAU,UAAU,kBAAkB,KAAG,OAAO,CAAC,OAAO,CAmCxF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,GAChC,QAAQ,SAAS,EACjB,KAAK,MAAM,EACX,aAAa,MAAM,GAAG,IAAI,KACxB,OAAO,CAAC,OAAO,CA+BjB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,GACjC,YAAY,KAAK,CAAC,MAAM,CAAC,KACvB,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAkEjC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,0BAA0B,QAAa,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAkCxE,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,GACvC,QAAQ,SAAS,EACjB,KAAK,MAAM,EACX,aAAa,MAAM,GAAG,IAAI,EAC1B,aAAa,KAAK,CAAC,MAAM,CAAC,KACxB,OAAO,CAAC,kBAAkB,CAW5B,CAAC"}
|
package/dist/build_cache.js
DELETED
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
import { mkdir, readdir, readFile, rm, stat, writeFile } from 'node:fs/promises';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { styleText as st } from 'node:util';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
import { git_current_commit_hash } from '@fuzdev/fuz_util/git.js';
|
|
6
|
-
import { fs_exists } from '@fuzdev/fuz_util/fs.js';
|
|
7
|
-
import { map_concurrent } from '@fuzdev/fuz_util/async.js';
|
|
8
|
-
import { hash_secure } from '@fuzdev/fuz_util/hash.js';
|
|
9
|
-
import { paths } from "./paths.js";
|
|
10
|
-
import { SVELTEKIT_BUILD_DIRNAME, SVELTEKIT_DIST_DIRNAME, GRO_DIST_PREFIX } from "./constants.js";
|
|
11
|
-
export const BUILD_CACHE_METADATA_FILENAME = 'build.json';
|
|
12
|
-
export const BUILD_CACHE_VERSION = '1';
|
|
13
|
-
/**
|
|
14
|
-
* Metadata about a single build output file.
|
|
15
|
-
* Includes cryptographic hash for validation plus filesystem stats for debugging and optimization.
|
|
16
|
-
*/
|
|
17
|
-
export const BuildOutputEntry = z.strictObject({
|
|
18
|
-
path: z
|
|
19
|
-
.string()
|
|
20
|
-
.meta({ description: "relative path from project root (e.g., 'build/index.html')." }),
|
|
21
|
-
hash: z.string().meta({ description: 'SHA-256 hash of file contents' }),
|
|
22
|
-
size: z.number().meta({ description: 'file size in bytes' }),
|
|
23
|
-
mtime: z.number().meta({ description: 'modification time in milliseconds since epoch' }),
|
|
24
|
-
ctime: z.number().meta({
|
|
25
|
-
description: 'POSIX change time in milliseconds since epoch',
|
|
26
|
-
}),
|
|
27
|
-
mode: z.number().meta({ description: 'unix file permission mode (e.g., 33188 = 0644)' }),
|
|
28
|
-
});
|
|
29
|
-
/**
|
|
30
|
-
* Metadata stored in .gro/ directory to track build cache validity.
|
|
31
|
-
* Schema validates structure at load time to catch corrupted cache files.
|
|
32
|
-
*/
|
|
33
|
-
export const BuildCacheMetadata = z.strictObject({
|
|
34
|
-
version: z.string().meta({ description: 'schema version for future compatibility' }),
|
|
35
|
-
git_commit: z.string().nullable().meta({ description: 'git commit hash at time of build' }),
|
|
36
|
-
build_cache_config_hash: z
|
|
37
|
-
.string()
|
|
38
|
-
.meta({ description: "hash of user's custom build_cache_config from gro.config.ts." }),
|
|
39
|
-
timestamp: z.string().meta({ description: 'timestamp when build completed' }),
|
|
40
|
-
outputs: z
|
|
41
|
-
.array(BuildOutputEntry)
|
|
42
|
-
.meta({ description: 'build output files with hashes and filesystem stats' }),
|
|
43
|
-
});
|
|
44
|
-
/**
|
|
45
|
-
* Computes the cache key components for a build.
|
|
46
|
-
* This determines whether a cached build can be reused.
|
|
47
|
-
*
|
|
48
|
-
* @param config Gro config (build_cache_config_hash is already computed during config load)
|
|
49
|
-
* @param log Logger
|
|
50
|
-
* @param git_commit Optional pre-computed git commit hash (optimization to avoid re-reading)
|
|
51
|
-
*/
|
|
52
|
-
export const compute_build_cache_key = async (config, log, git_commit) => {
|
|
53
|
-
// 1. Git commit hash - primary cache key
|
|
54
|
-
const commit = git_commit !== undefined ? git_commit : await git_current_commit_hash();
|
|
55
|
-
if (!commit) {
|
|
56
|
-
log.warn('Not in a git repository - build cache will use null git commit');
|
|
57
|
-
}
|
|
58
|
-
// 2. Build cache config hash - already computed during config normalization
|
|
59
|
-
return {
|
|
60
|
-
git_commit: commit,
|
|
61
|
-
build_cache_config_hash: config.build_cache_config_hash,
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* Loads build cache metadata from .gro/ directory.
|
|
66
|
-
* Invalid or corrupted cache files are automatically deleted.
|
|
67
|
-
*/
|
|
68
|
-
export const load_build_cache_metadata = async () => {
|
|
69
|
-
const metadata_path = join(paths.build, BUILD_CACHE_METADATA_FILENAME);
|
|
70
|
-
if (!(await fs_exists(metadata_path))) {
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
try {
|
|
74
|
-
const contents = await readFile(metadata_path, 'utf-8');
|
|
75
|
-
const parsed = JSON.parse(contents);
|
|
76
|
-
// Validate structure with Zod
|
|
77
|
-
const metadata = BuildCacheMetadata.parse(parsed);
|
|
78
|
-
// Validate version
|
|
79
|
-
if (metadata.version !== BUILD_CACHE_VERSION) {
|
|
80
|
-
// Clean up stale cache with old schema version
|
|
81
|
-
try {
|
|
82
|
-
await rm(metadata_path, { force: true });
|
|
83
|
-
}
|
|
84
|
-
catch {
|
|
85
|
-
// Ignore cleanup errors
|
|
86
|
-
}
|
|
87
|
-
return null;
|
|
88
|
-
}
|
|
89
|
-
return metadata;
|
|
90
|
-
}
|
|
91
|
-
catch {
|
|
92
|
-
// Clean up corrupted/invalid cache file
|
|
93
|
-
// (catches JSON.parse, Zod validation, and version errors)
|
|
94
|
-
try {
|
|
95
|
-
await rm(metadata_path, { force: true });
|
|
96
|
-
}
|
|
97
|
-
catch {
|
|
98
|
-
// Ignore cleanup errors
|
|
99
|
-
}
|
|
100
|
-
return null;
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
/**
|
|
104
|
-
* Saves build cache metadata to .gro/ directory.
|
|
105
|
-
* Errors are logged but don't fail the build (cache is optional).
|
|
106
|
-
*/
|
|
107
|
-
export const save_build_cache_metadata = async (metadata, log) => {
|
|
108
|
-
try {
|
|
109
|
-
// Ensure .gro directory exists
|
|
110
|
-
await mkdir(paths.build, { recursive: true });
|
|
111
|
-
const metadata_path = join(paths.build, BUILD_CACHE_METADATA_FILENAME);
|
|
112
|
-
await writeFile(metadata_path, JSON.stringify(metadata, null, '\t'), 'utf-8');
|
|
113
|
-
}
|
|
114
|
-
catch (error) {
|
|
115
|
-
// Cache writes are optional - log warning but don't fail the build
|
|
116
|
-
log?.warn(st('yellow', 'Failed to save build cache'), st('dim', `(${error instanceof Error ? error.message : String(error)})`));
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
/**
|
|
120
|
-
* Validates that a cached build is still valid by checking stats and hashing outputs.
|
|
121
|
-
* Uses size as a fast negative check before expensive hashing.
|
|
122
|
-
* This is comprehensive validation to catch manual tampering or corruption.
|
|
123
|
-
*/
|
|
124
|
-
export const validate_build_cache = async (metadata) => {
|
|
125
|
-
// Verify all tracked output files exist and have matching size
|
|
126
|
-
// Sequential checks with early return for performance
|
|
127
|
-
for (const output of metadata.outputs) {
|
|
128
|
-
// eslint-disable-next-line no-await-in-loop
|
|
129
|
-
if (!(await fs_exists(output.path))) {
|
|
130
|
-
return false;
|
|
131
|
-
}
|
|
132
|
-
// Fast negative check: size mismatch = definitely invalid
|
|
133
|
-
// This avoids expensive file reads and hashing for files that have clearly changed
|
|
134
|
-
// eslint-disable-next-line no-await-in-loop
|
|
135
|
-
const stats = await stat(output.path);
|
|
136
|
-
if (stats.size !== output.size) {
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
// Size matches for all files - now verify content with cryptographic hashing
|
|
141
|
-
// Hash files with controlled concurrency (could be 10k+ files)
|
|
142
|
-
const results = await map_concurrent(metadata.outputs, async (output) => {
|
|
143
|
-
try {
|
|
144
|
-
const contents = await readFile(output.path);
|
|
145
|
-
const actual_hash = await hash_secure(contents);
|
|
146
|
-
return actual_hash === output.hash;
|
|
147
|
-
}
|
|
148
|
-
catch {
|
|
149
|
-
// File deleted/inaccessible between checks = cache invalid
|
|
150
|
-
return false;
|
|
151
|
-
}
|
|
152
|
-
}, 20);
|
|
153
|
-
return results.every((valid) => valid);
|
|
154
|
-
};
|
|
155
|
-
/**
|
|
156
|
-
* Main function to check if the build cache is valid.
|
|
157
|
-
* Returns true if the cached build can be used, false if a fresh build is needed.
|
|
158
|
-
*
|
|
159
|
-
* @param config Gro config
|
|
160
|
-
* @param log Logger
|
|
161
|
-
* @param git_commit Optional pre-computed git commit hash (optimization)
|
|
162
|
-
*/
|
|
163
|
-
export const is_build_cache_valid = async (config, log, git_commit) => {
|
|
164
|
-
// Load existing metadata
|
|
165
|
-
const metadata = await load_build_cache_metadata();
|
|
166
|
-
if (!metadata) {
|
|
167
|
-
log.debug('No build cache metadata found');
|
|
168
|
-
return false;
|
|
169
|
-
}
|
|
170
|
-
// Compute current cache key
|
|
171
|
-
const current = await compute_build_cache_key(config, log, git_commit);
|
|
172
|
-
// Check if cache keys have changed
|
|
173
|
-
if (metadata.git_commit !== current.git_commit) {
|
|
174
|
-
log.debug('Build cache invalid: git commit changed');
|
|
175
|
-
return false;
|
|
176
|
-
}
|
|
177
|
-
if (metadata.build_cache_config_hash !== current.build_cache_config_hash) {
|
|
178
|
-
log.debug('Build cache invalid: build_cache_config changed');
|
|
179
|
-
return false;
|
|
180
|
-
}
|
|
181
|
-
// Comprehensive validation: verify output files
|
|
182
|
-
const outputs_valid = await validate_build_cache(metadata);
|
|
183
|
-
if (!outputs_valid) {
|
|
184
|
-
log.debug('Build cache invalid: output files missing or corrupted');
|
|
185
|
-
return false;
|
|
186
|
-
}
|
|
187
|
-
log.info(st('green', 'Build cache valid'), st('dim', `(from ${metadata.timestamp})`));
|
|
188
|
-
return true;
|
|
189
|
-
};
|
|
190
|
-
/**
|
|
191
|
-
* Collects information about all files in build output directories.
|
|
192
|
-
* Returns an array of entries with path, hash, size, mtime, ctime, and mode.
|
|
193
|
-
*
|
|
194
|
-
* Files are hashed in parallel for performance. For very large builds (10k+ files),
|
|
195
|
-
* this may take several seconds but ensures complete cache validation.
|
|
196
|
-
*
|
|
197
|
-
* @param build_dirs Array of output directories to scan (e.g., ['build', 'dist', 'dist_server'])
|
|
198
|
-
*/
|
|
199
|
-
export const collect_build_outputs = async (build_dirs) => {
|
|
200
|
-
const files_hash_secure = [];
|
|
201
|
-
// Recursively collect files
|
|
202
|
-
const collect_files = async (dir, relative_base, dir_prefix) => {
|
|
203
|
-
const entries = await readdir(dir, { withFileTypes: true });
|
|
204
|
-
for (const entry of entries) {
|
|
205
|
-
// Skip metadata file itself
|
|
206
|
-
if (entry.name === BUILD_CACHE_METADATA_FILENAME) {
|
|
207
|
-
continue;
|
|
208
|
-
}
|
|
209
|
-
const full_path = join(dir, entry.name);
|
|
210
|
-
const relative_path = relative_base ? join(relative_base, entry.name) : entry.name;
|
|
211
|
-
const cache_key = join(dir_prefix, relative_path);
|
|
212
|
-
if (entry.isDirectory()) {
|
|
213
|
-
// eslint-disable-next-line no-await-in-loop
|
|
214
|
-
await collect_files(full_path, relative_path, dir_prefix);
|
|
215
|
-
}
|
|
216
|
-
else if (entry.isFile()) {
|
|
217
|
-
files_hash_secure.push({ full_path, cache_key });
|
|
218
|
-
}
|
|
219
|
-
// Symlinks are intentionally ignored - we only hash regular files
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
// Collect files from all build directories sequentially
|
|
223
|
-
for (const build_dir of build_dirs) {
|
|
224
|
-
// eslint-disable-next-line no-await-in-loop
|
|
225
|
-
if (!(await fs_exists(build_dir))) {
|
|
226
|
-
continue; // Skip non-existent directories
|
|
227
|
-
}
|
|
228
|
-
// eslint-disable-next-line no-await-in-loop
|
|
229
|
-
await collect_files(build_dir, '', build_dir);
|
|
230
|
-
}
|
|
231
|
-
// Hash files with controlled concurrency and collect stats (could be 10k+ files)
|
|
232
|
-
return map_concurrent(files_hash_secure, async ({ full_path, cache_key }) => {
|
|
233
|
-
const stats = await stat(full_path);
|
|
234
|
-
const contents = await readFile(full_path);
|
|
235
|
-
const hash = await hash_secure(contents);
|
|
236
|
-
return {
|
|
237
|
-
path: cache_key,
|
|
238
|
-
hash,
|
|
239
|
-
size: stats.size,
|
|
240
|
-
mtime: stats.mtimeMs,
|
|
241
|
-
ctime: stats.ctimeMs,
|
|
242
|
-
mode: stats.mode,
|
|
243
|
-
};
|
|
244
|
-
}, 20);
|
|
245
|
-
};
|
|
246
|
-
/**
|
|
247
|
-
* Discovers all build output directories in the current working directory.
|
|
248
|
-
* Returns an array of directory names that exist: build/, dist/, dist_*
|
|
249
|
-
*/
|
|
250
|
-
export const discover_build_output_dirs = async () => {
|
|
251
|
-
const build_dirs = [];
|
|
252
|
-
// Check for SvelteKit app output (build/) and library output (dist/) in parallel
|
|
253
|
-
const [build_exists, dist_exists] = await Promise.all([
|
|
254
|
-
fs_exists(SVELTEKIT_BUILD_DIRNAME),
|
|
255
|
-
fs_exists(SVELTEKIT_DIST_DIRNAME),
|
|
256
|
-
]);
|
|
257
|
-
if (build_exists) {
|
|
258
|
-
build_dirs.push(SVELTEKIT_BUILD_DIRNAME);
|
|
259
|
-
}
|
|
260
|
-
if (dist_exists) {
|
|
261
|
-
build_dirs.push(SVELTEKIT_DIST_DIRNAME);
|
|
262
|
-
}
|
|
263
|
-
// Check for server and other plugin outputs (dist_*)
|
|
264
|
-
const root_entries = await readdir('.');
|
|
265
|
-
const dist_dir_checks = await Promise.all(root_entries
|
|
266
|
-
.filter((p) => p.startsWith(GRO_DIST_PREFIX))
|
|
267
|
-
.map(async (p) => {
|
|
268
|
-
try {
|
|
269
|
-
const s = await stat(p);
|
|
270
|
-
return s.isDirectory() ? p : null;
|
|
271
|
-
}
|
|
272
|
-
catch {
|
|
273
|
-
// File was deleted/moved during iteration - skip it
|
|
274
|
-
return null;
|
|
275
|
-
}
|
|
276
|
-
}));
|
|
277
|
-
build_dirs.push(...dist_dir_checks.filter((p) => p !== null));
|
|
278
|
-
return build_dirs;
|
|
279
|
-
};
|
|
280
|
-
/**
|
|
281
|
-
* Creates build cache metadata after a successful build.
|
|
282
|
-
* Automatically discovers all build output directories (build/, dist/, dist_*).
|
|
283
|
-
*
|
|
284
|
-
* @param config Gro config
|
|
285
|
-
* @param log Logger
|
|
286
|
-
* @param git_commit Optional pre-computed git commit hash (optimization)
|
|
287
|
-
* @param build_dirs Optional pre-discovered build directories (optimization to avoid redundant filesystem scans)
|
|
288
|
-
*/
|
|
289
|
-
export const create_build_cache_metadata = async (config, log, git_commit, build_dirs) => {
|
|
290
|
-
const cache_key = await compute_build_cache_key(config, log, git_commit);
|
|
291
|
-
const dirs = build_dirs ?? (await discover_build_output_dirs());
|
|
292
|
-
const outputs = await collect_build_outputs(dirs);
|
|
293
|
-
return {
|
|
294
|
-
version: BUILD_CACHE_VERSION,
|
|
295
|
-
...cache_key,
|
|
296
|
-
timestamp: new Date().toISOString(),
|
|
297
|
-
outputs,
|
|
298
|
-
};
|
|
299
|
-
};
|
package/dist/changelog.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Logger } from '@fuzdev/fuz_util/log.js';
|
|
2
|
-
import type { FetchValueCache } from '@fuzdev/fuz_util/fetch.js';
|
|
3
|
-
/**
|
|
4
|
-
* Updates a changelog produced by `@changesets/changelog-git` with better links and formatting.
|
|
5
|
-
* It's similar to `@changesets/changelog-github` but doesn't require a token for light usage.
|
|
6
|
-
* This may be better implemented as a standalone dependency
|
|
7
|
-
* as an alternative to `@changesets/changelog-git`.
|
|
8
|
-
* @returns boolean indicating if the changelog changed
|
|
9
|
-
*/
|
|
10
|
-
export declare const update_changelog: (owner: string, repo: string, path?: string, token?: string, log?: Logger, cache?: FetchValueCache) => Promise<boolean>;
|
|
11
|
-
//# sourceMappingURL=changelog.d.ts.map
|
package/dist/changelog.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"changelog.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/changelog.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,2BAA2B,CAAC;AAI/D;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAC5B,OAAO,MAAM,EACb,MAAM,MAAM,EACZ,aAAqB,EACrB,QAAQ,MAAM,EACd,MAAM,MAAM,EACZ,QAAO,eAA2B,KAChC,OAAO,CAAC,OAAO,CAUjB,CAAC"}
|
package/dist/changelog.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { readFile, writeFile } from 'node:fs/promises';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { github_fetch_commit_prs } from "./github.js";
|
|
4
|
-
/**
|
|
5
|
-
* Updates a changelog produced by `@changesets/changelog-git` with better links and formatting.
|
|
6
|
-
* It's similar to `@changesets/changelog-github` but doesn't require a token for light usage.
|
|
7
|
-
* This may be better implemented as a standalone dependency
|
|
8
|
-
* as an alternative to `@changesets/changelog-git`.
|
|
9
|
-
* @returns boolean indicating if the changelog changed
|
|
10
|
-
*/
|
|
11
|
-
export const update_changelog = async (owner, repo, path = 'CHANGELOG.md', token, log, cache = new Map()) => {
|
|
12
|
-
const contents = await readFile(path, 'utf8');
|
|
13
|
-
const parsed = parse_changelog(contents);
|
|
14
|
-
const mapped = await map_changelog(parsed, owner, repo, token, log, cache);
|
|
15
|
-
const updated = serialize_changelog(mapped);
|
|
16
|
-
if (contents === updated) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
await writeFile(path, updated, 'utf8');
|
|
20
|
-
return true;
|
|
21
|
-
};
|
|
22
|
-
// keeping this really simple for now, no need to parse further for our current usecases
|
|
23
|
-
const ParsedChangelog = z.array(z.string());
|
|
24
|
-
const parse_changelog = (contents) => contents.split('\n');
|
|
25
|
-
const serialize_changelog = (parsed) => parsed.join('\n');
|
|
26
|
-
const LINE_WITH_SHA_MATCHER = /^- ([a-z0-9]{7,8}): /;
|
|
27
|
-
const map_changelog = async (parsed, owner, repo, token, log, cache) => {
|
|
28
|
-
const mapped = [];
|
|
29
|
-
for (const line of parsed) {
|
|
30
|
-
const matches = LINE_WITH_SHA_MATCHER.exec(line);
|
|
31
|
-
if (matches) {
|
|
32
|
-
const commit_sha = matches[1];
|
|
33
|
-
const l = '- ' + line.substring(commit_sha.length + 4);
|
|
34
|
-
const prs = await github_fetch_commit_prs(owner, repo, commit_sha, token, log, cache); // eslint-disable-line no-await-in-loop
|
|
35
|
-
if (prs?.length) {
|
|
36
|
-
mapped.push(`${l} (${prs.map((p) => `[#${p.number}](${p.html_url})`).join(', ')})`);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
mapped.push(`${l} ([${commit_sha}](https://github.com/${owner}/${repo}/commit/${commit_sha}))`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
mapped.push(line);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return mapped;
|
|
47
|
-
};
|
package/dist/changeset.task.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { type Task } from './task.ts';
|
|
3
|
-
/** @nodocs */
|
|
4
|
-
export declare const Args: z.ZodObject<{
|
|
5
|
-
/**
|
|
6
|
-
* The optional rest args get joined with a space to form the `message`.
|
|
7
|
-
*/
|
|
8
|
-
_: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
9
|
-
minor: z.ZodDefault<z.ZodBoolean>;
|
|
10
|
-
major: z.ZodDefault<z.ZodBoolean>;
|
|
11
|
-
dir: z.ZodDefault<z.ZodString>;
|
|
12
|
-
access: z.ZodOptional<z.ZodEnum<{
|
|
13
|
-
public: "public";
|
|
14
|
-
restricted: "restricted";
|
|
15
|
-
}>>;
|
|
16
|
-
changelog: z.ZodDefault<z.ZodString>;
|
|
17
|
-
dep: z.ZodDefault<z.ZodBoolean>;
|
|
18
|
-
'no-dep': z.ZodDefault<z.ZodBoolean>;
|
|
19
|
-
origin: z.ZodDefault<z.ZodString>;
|
|
20
|
-
changeset_cli: z.ZodDefault<z.ZodString>;
|
|
21
|
-
}, z.core.$strict>;
|
|
22
|
-
export type Args = z.infer<typeof Args>;
|
|
23
|
-
/**
|
|
24
|
-
* Calls the `changeset` CLI with some simple automations.
|
|
25
|
-
* This API is designed for convenient manual usage, not clarity or normality.
|
|
26
|
-
*
|
|
27
|
-
* Usage:
|
|
28
|
-
* - gro changeset some commit message
|
|
29
|
-
* - gro changeset some commit message --minor
|
|
30
|
-
* - gro changeset "some commit message" --minor
|
|
31
|
-
*
|
|
32
|
-
* @nodocs
|
|
33
|
-
*/
|
|
34
|
-
export declare const task: Task<Args>;
|
|
35
|
-
//# sourceMappingURL=changeset.task.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"changeset.task.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/changeset.task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAatB,OAAO,EAAY,KAAK,IAAI,EAAC,MAAM,WAAW,CAAC;AAa/C,cAAc;AACd,eAAO,MAAM,IAAI;IAChB;;OAEG;;;;;;;;;;;;;;kBAuBF,CAAC;AACH,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAExC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,IAAI,EAAE,IAAI,CAAC,IAAI,CA0F3B,CAAC"}
|