@ryanatkn/gro 0.142.0 → 0.143.1
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/dist/build.task.js +1 -1
- package/dist/changeset.task.js +3 -3
- package/dist/check.task.d.ts.map +1 -1
- package/dist/check.task.js +4 -2
- package/dist/clean_fs.js +1 -1
- package/dist/cli.js +1 -1
- package/dist/{path_constants.d.ts → constants.d.ts} +4 -1
- package/dist/constants.d.ts.map +1 -0
- package/dist/{path_constants.js → constants.js} +3 -0
- package/dist/deploy.task.js +1 -1
- package/dist/dev.task.js +1 -1
- package/dist/esbuild_plugin_svelte.js +1 -1
- package/dist/esbuild_plugin_sveltekit_local_imports.js +1 -1
- package/dist/esbuild_plugin_sveltekit_shim_app.js +1 -1
- package/dist/esbuild_plugin_sveltekit_shim_env.js +1 -1
- package/dist/format.task.d.ts.map +1 -1
- package/dist/format.task.js +2 -2
- package/dist/format_directory.d.ts +1 -1
- package/dist/format_directory.d.ts.map +1 -1
- package/dist/format_directory.js +5 -6
- package/dist/gen.task.js +1 -1
- package/dist/gro_config.d.ts +7 -2
- package/dist/gro_config.d.ts.map +1 -1
- package/dist/gro_config.js +9 -7
- package/dist/gro_helpers.d.ts +1 -1
- package/dist/gro_helpers.d.ts.map +1 -1
- package/dist/gro_helpers.js +3 -3
- package/dist/gro_plugin_server.js +4 -4
- package/dist/gro_plugin_sveltekit_app.d.ts.map +1 -1
- package/dist/gro_plugin_sveltekit_app.js +5 -5
- package/dist/gro_plugin_sveltekit_library.js +3 -3
- package/dist/loader.js +1 -1
- package/dist/module.js +1 -1
- package/dist/moss_helpers.d.ts +1 -1
- package/dist/moss_helpers.d.ts.map +1 -1
- package/dist/moss_helpers.js +3 -3
- package/dist/package.d.ts +11 -11
- package/dist/package.d.ts.map +1 -1
- package/dist/package.js +39 -39
- package/dist/package_json.js +2 -2
- package/dist/package_meta.d.ts +1 -1
- package/dist/parse_imports.js +1 -1
- package/dist/paths.js +1 -1
- package/dist/publish.task.d.ts.map +1 -1
- package/dist/publish.task.js +4 -12
- package/dist/reinstall.task.js +10 -10
- package/dist/resolve_node_specifier.js +2 -2
- package/dist/run_task.js +1 -1
- package/dist/sveltekit_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 +7 -7
- package/dist/sync.task.js +5 -5
- package/package.json +6 -6
- package/src/lib/build.task.ts +1 -1
- package/src/lib/changeset.task.ts +3 -3
- package/src/lib/check.task.ts +4 -2
- package/src/lib/clean_fs.ts +1 -1
- package/src/lib/cli.ts +1 -1
- package/src/lib/{path_constants.ts → constants.ts} +4 -0
- package/src/lib/deploy.task.ts +1 -1
- package/src/lib/dev.task.ts +1 -1
- package/src/lib/esbuild_plugin_svelte.ts +1 -1
- package/src/lib/esbuild_plugin_sveltekit_local_imports.ts +1 -1
- package/src/lib/esbuild_plugin_sveltekit_shim_app.ts +1 -1
- package/src/lib/esbuild_plugin_sveltekit_shim_env.ts +1 -1
- package/src/lib/format.task.ts +10 -2
- package/src/lib/format_directory.ts +10 -9
- package/src/lib/gen.task.ts +1 -1
- package/src/lib/gro_config.ts +16 -6
- package/src/lib/gro_helpers.ts +3 -2
- package/src/lib/gro_plugin_server.ts +4 -4
- package/src/lib/gro_plugin_sveltekit_app.ts +7 -5
- package/src/lib/gro_plugin_sveltekit_library.ts +3 -3
- package/src/lib/loader.ts +1 -1
- package/src/lib/module.ts +1 -1
- package/src/lib/moss_helpers.ts +3 -2
- package/src/lib/package.ts +39 -39
- package/src/lib/package_json.ts +2 -2
- package/src/lib/package_meta.ts +1 -1
- package/src/lib/parse_imports.ts +1 -1
- package/src/lib/paths.ts +1 -1
- package/src/lib/publish.task.ts +4 -13
- package/src/lib/reinstall.task.ts +10 -10
- package/src/lib/resolve_node_specifier.ts +2 -2
- package/src/lib/run_task.ts +1 -1
- package/src/lib/sveltekit_config.ts +1 -1
- package/src/lib/sveltekit_helpers.ts +7 -4
- package/src/lib/sync.task.ts +5 -5
- package/dist/path_constants.d.ts.map +0 -1
package/src/lib/format.task.ts
CHANGED
|
@@ -17,10 +17,18 @@ export type Args = z.infer<typeof Args>;
|
|
|
17
17
|
export const task: Task<Args> = {
|
|
18
18
|
summary: 'format source files',
|
|
19
19
|
Args,
|
|
20
|
-
run: async ({args, log}) => {
|
|
20
|
+
run: async ({args, log, config}) => {
|
|
21
21
|
const {check} = args;
|
|
22
22
|
// TODO forward prettier args
|
|
23
|
-
const format_result = await format_directory(
|
|
23
|
+
const format_result = await format_directory(
|
|
24
|
+
log,
|
|
25
|
+
paths.source,
|
|
26
|
+
check,
|
|
27
|
+
undefined,
|
|
28
|
+
undefined,
|
|
29
|
+
undefined,
|
|
30
|
+
config.pm_cli,
|
|
31
|
+
);
|
|
24
32
|
if (!format_result.ok) {
|
|
25
33
|
throw new Task_Error(
|
|
26
34
|
`Failed ${check ? 'formatting check' : 'to format'}. ${print_spawn_result(format_result)}`,
|
|
@@ -9,14 +9,14 @@ import {
|
|
|
9
9
|
VITE_CONFIG_FILENAME,
|
|
10
10
|
TSCONFIG_FILENAME,
|
|
11
11
|
GRO_CONFIG_PATH,
|
|
12
|
-
|
|
12
|
+
PM_CLI_DEFAULT,
|
|
13
|
+
PRETTIER_CLI_DEFAULT,
|
|
14
|
+
} from './constants.js';
|
|
13
15
|
import {serialize_args, to_forwarded_args} from './args.js';
|
|
14
16
|
import {spawn_cli, to_cli_name, type Cli} from './cli.js';
|
|
15
17
|
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
const DEFAULT_EXTENSIONS = 'ts,js,json,svelte,html,css,md,yml';
|
|
19
|
-
const DEFAULT_ROOT_PATHS = `${[
|
|
18
|
+
const EXTENSIONS_DEFAULT = 'ts,js,json,svelte,html,css,md,yml';
|
|
19
|
+
const ROOT_PATHS_DEFAULT = `${[
|
|
20
20
|
README_FILENAME,
|
|
21
21
|
GRO_CONFIG_PATH,
|
|
22
22
|
SVELTEKIT_CONFIG_FILENAME,
|
|
@@ -35,9 +35,10 @@ export const format_directory = async (
|
|
|
35
35
|
log: Logger,
|
|
36
36
|
dir: string,
|
|
37
37
|
check = false,
|
|
38
|
-
extensions =
|
|
39
|
-
root_paths =
|
|
40
|
-
prettier_cli: string | Cli =
|
|
38
|
+
extensions = EXTENSIONS_DEFAULT,
|
|
39
|
+
root_paths = ROOT_PATHS_DEFAULT,
|
|
40
|
+
prettier_cli: string | Cli = PRETTIER_CLI_DEFAULT,
|
|
41
|
+
pm_cli: string = PM_CLI_DEFAULT,
|
|
41
42
|
): Promise<Spawn_Result> => {
|
|
42
43
|
const forwarded_args = to_forwarded_args(to_cli_name(prettier_cli));
|
|
43
44
|
forwarded_args[check ? 'check' : 'write'] = true;
|
|
@@ -49,7 +50,7 @@ export const format_directory = async (
|
|
|
49
50
|
const spawned = await spawn_cli(prettier_cli, serialized_args, log);
|
|
50
51
|
if (!spawned)
|
|
51
52
|
throw new Error(
|
|
52
|
-
`failed to find \`${to_cli_name(prettier_cli)}\` CLI locally or globally, do you need to run
|
|
53
|
+
`failed to find \`${to_cli_name(prettier_cli)}\` CLI locally or globally, do you need to run \`${pm_cli} install\`?`,
|
|
53
54
|
);
|
|
54
55
|
return spawned;
|
|
55
56
|
};
|
package/src/lib/gen.task.ts
CHANGED
|
@@ -10,7 +10,7 @@ import {format_file} from './format_file.js';
|
|
|
10
10
|
import {print_path} from './paths.js';
|
|
11
11
|
import {log_error_reasons} from './task_logging.js';
|
|
12
12
|
import {write_gen_results, analyze_gen_results, find_genfiles, load_genfiles} from './gen.js';
|
|
13
|
-
import {SOURCE_DIRNAME} from './
|
|
13
|
+
import {SOURCE_DIRNAME} from './constants.js';
|
|
14
14
|
|
|
15
15
|
export const Args = z
|
|
16
16
|
.object({
|
package/src/lib/gro_config.ts
CHANGED
|
@@ -4,11 +4,13 @@ import {existsSync} from 'node:fs';
|
|
|
4
4
|
import {GRO_DIST_DIR, IS_THIS_GRO, paths} from './paths.js';
|
|
5
5
|
import {
|
|
6
6
|
GRO_CONFIG_PATH,
|
|
7
|
+
JS_CLI_DEFAULT,
|
|
7
8
|
NODE_MODULES_DIRNAME,
|
|
9
|
+
PM_CLI_DEFAULT,
|
|
8
10
|
SERVER_DIST_PATH,
|
|
9
11
|
SVELTEKIT_BUILD_DIRNAME,
|
|
10
12
|
SVELTEKIT_DIST_DIRNAME,
|
|
11
|
-
} from './
|
|
13
|
+
} from './constants.js';
|
|
12
14
|
import create_default_config from './gro.config.default.js';
|
|
13
15
|
import type {Create_Config_Plugins} from './plugin.js';
|
|
14
16
|
import type {Map_Package_Json} from './package_json.js';
|
|
@@ -40,6 +42,10 @@ export interface Gro_Config {
|
|
|
40
42
|
* directories and files are included if they pass all of these filters.
|
|
41
43
|
*/
|
|
42
44
|
search_filters: Path_Filter[];
|
|
45
|
+
/**
|
|
46
|
+
* The CLI to use that's compatible with `node`.
|
|
47
|
+
*/
|
|
48
|
+
js_cli: string;
|
|
43
49
|
/**
|
|
44
50
|
* The CLI to use that's compatible with `npm install` and `npm link`. Defaults to `'npm'`.
|
|
45
51
|
*/
|
|
@@ -56,6 +62,7 @@ export interface Raw_Gro_Config {
|
|
|
56
62
|
map_package_json?: Map_Package_Json | null;
|
|
57
63
|
task_root_dirs?: string[];
|
|
58
64
|
search_filters?: Path_Filter | Path_Filter[] | null;
|
|
65
|
+
js_cli?: string;
|
|
59
66
|
pm_cli?: string;
|
|
60
67
|
}
|
|
61
68
|
|
|
@@ -72,8 +79,9 @@ export const create_empty_gro_config = (): Gro_Config => ({
|
|
|
72
79
|
IS_THIS_GRO ? null : paths.root,
|
|
73
80
|
IS_THIS_GRO ? null : GRO_DIST_DIR,
|
|
74
81
|
].filter((v) => v !== null),
|
|
75
|
-
search_filters: [(id) => !
|
|
76
|
-
|
|
82
|
+
search_filters: [(id) => !SEARCH_EXCLUDER_DEFAULT.test(id)],
|
|
83
|
+
js_cli: JS_CLI_DEFAULT,
|
|
84
|
+
pm_cli: PM_CLI_DEFAULT,
|
|
77
85
|
});
|
|
78
86
|
|
|
79
87
|
/**
|
|
@@ -82,7 +90,7 @@ export const create_empty_gro_config = (): Gro_Config => ({
|
|
|
82
90
|
* Customize via `search_filters` in the `Gro_Config`.
|
|
83
91
|
* See the test cases for the exact behavior.
|
|
84
92
|
*/
|
|
85
|
-
export const
|
|
93
|
+
export const SEARCH_EXCLUDER_DEFAULT = new RegExp(
|
|
86
94
|
`(${
|
|
87
95
|
'(^|/)\\.[^/]+' + // exclude all `.`-prefixed directories
|
|
88
96
|
// TODO probably change to `pkg.name` instead of this catch-all (also `gro` below)
|
|
@@ -97,13 +105,13 @@ export const DEFAULT_SEARCH_EXCLUDER = new RegExp(
|
|
|
97
105
|
const default_map_package_json: Map_Package_Json = (package_json) => {
|
|
98
106
|
if (package_json.exports) {
|
|
99
107
|
package_json.exports = Object.fromEntries(
|
|
100
|
-
Object.entries(package_json.exports).filter(([k]) => !
|
|
108
|
+
Object.entries(package_json.exports).filter(([k]) => !EXPORTS_EXCLUDER_DEFAULT.test(k)),
|
|
101
109
|
);
|
|
102
110
|
}
|
|
103
111
|
return package_json;
|
|
104
112
|
};
|
|
105
113
|
|
|
106
|
-
export const
|
|
114
|
+
export const EXPORTS_EXCLUDER_DEFAULT = /(\.md|\.(test|ignore)\.|\/(test|fixtures|ignore)\/)/;
|
|
107
115
|
|
|
108
116
|
/**
|
|
109
117
|
* Transforms a `Raw_Gro_Config` to the more strict `Gro_Config`.
|
|
@@ -118,6 +126,7 @@ export const normalize_gro_config = (raw_config: Raw_Gro_Config): Gro_Config =>
|
|
|
118
126
|
map_package_json = empty_config.map_package_json,
|
|
119
127
|
task_root_dirs = empty_config.task_root_dirs,
|
|
120
128
|
search_filters = empty_config.search_filters,
|
|
129
|
+
js_cli = empty_config.js_cli,
|
|
121
130
|
pm_cli = empty_config.pm_cli,
|
|
122
131
|
} = raw_config;
|
|
123
132
|
return {
|
|
@@ -129,6 +138,7 @@ export const normalize_gro_config = (raw_config: Raw_Gro_Config): Gro_Config =>
|
|
|
129
138
|
: search_filters
|
|
130
139
|
? [search_filters]
|
|
131
140
|
: [],
|
|
141
|
+
js_cli,
|
|
132
142
|
pm_cli,
|
|
133
143
|
};
|
|
134
144
|
};
|
package/src/lib/gro_helpers.ts
CHANGED
|
@@ -3,7 +3,7 @@ import {join, resolve} from 'node:path';
|
|
|
3
3
|
import {fileURLToPath} from 'node:url';
|
|
4
4
|
import {spawn, type Spawn_Result} from '@ryanatkn/belt/process.js';
|
|
5
5
|
|
|
6
|
-
import {NODE_MODULES_DIRNAME, SVELTEKIT_DIST_DIRNAME} from './
|
|
6
|
+
import {JS_CLI_DEFAULT, NODE_MODULES_DIRNAME, SVELTEKIT_DIST_DIRNAME} from './constants.js';
|
|
7
7
|
|
|
8
8
|
/*
|
|
9
9
|
|
|
@@ -84,6 +84,7 @@ export const spawn_with_loader = (
|
|
|
84
84
|
loader_path: string,
|
|
85
85
|
invoke_path: string,
|
|
86
86
|
argv: string[],
|
|
87
|
+
js_cli = JS_CLI_DEFAULT, // TODO source from config when possible
|
|
87
88
|
): Promise<Spawn_Result> => {
|
|
88
89
|
const args = [
|
|
89
90
|
'--import',
|
|
@@ -99,5 +100,5 @@ export const spawn_with_loader = (
|
|
|
99
100
|
args.push('-C', 'development'); // same as `--conditions`
|
|
100
101
|
}
|
|
101
102
|
args.push(invoke_path, ...argv);
|
|
102
|
-
return spawn(
|
|
103
|
+
return spawn(js_cli, args);
|
|
103
104
|
};
|
|
@@ -11,7 +11,7 @@ import {throttle} from '@ryanatkn/belt/throttle.js';
|
|
|
11
11
|
import type {Plugin} from './plugin.js';
|
|
12
12
|
import {base_path_to_path_id, LIB_DIRNAME, paths} from './paths.js';
|
|
13
13
|
import type {Path_Id} from './path.js';
|
|
14
|
-
import {GRO_DEV_DIRNAME, SERVER_DIST_PATH} from './
|
|
14
|
+
import {GRO_DEV_DIRNAME, SERVER_DIST_PATH} from './constants.js';
|
|
15
15
|
import {watch_dir, type Watch_Node_Fs} from './watch_dir.js';
|
|
16
16
|
import {init_sveltekit_config, default_sveltekit_config} from './sveltekit_config.js';
|
|
17
17
|
import {esbuild_plugin_sveltekit_shim_app} from './esbuild_plugin_sveltekit_shim_app.js';
|
|
@@ -119,7 +119,7 @@ export const gro_plugin_server = ({
|
|
|
119
119
|
target = 'esnext',
|
|
120
120
|
esbuild_build_options = identity,
|
|
121
121
|
rebuild_throttle_delay = 1000,
|
|
122
|
-
cli_command
|
|
122
|
+
cli_command,
|
|
123
123
|
run, // `dev` default is not available in this scope
|
|
124
124
|
}: Options = {}): Plugin => {
|
|
125
125
|
let build_ctx: esbuild.BuildContext | null = null;
|
|
@@ -129,7 +129,7 @@ export const gro_plugin_server = ({
|
|
|
129
129
|
|
|
130
130
|
return {
|
|
131
131
|
name: 'gro_plugin_server',
|
|
132
|
-
setup: async ({dev, watch, timings, log}) => {
|
|
132
|
+
setup: async ({dev, watch, timings, log, config}) => {
|
|
133
133
|
const parsed_sveltekit_config =
|
|
134
134
|
!sveltekit_config && strip_end(dir, '/') === process.cwd()
|
|
135
135
|
? default_sveltekit_config
|
|
@@ -256,7 +256,7 @@ export const gro_plugin_server = ({
|
|
|
256
256
|
cli_args.push('-C', 'development'); // same as `--conditions`
|
|
257
257
|
}
|
|
258
258
|
cli_args.push(server_outpath);
|
|
259
|
-
server_process = spawn_restartable_process(cli_command, cli_args);
|
|
259
|
+
server_process = spawn_restartable_process(cli_command ?? config.js_cli, cli_args);
|
|
260
260
|
}
|
|
261
261
|
},
|
|
262
262
|
teardown: async () => {
|
|
@@ -8,9 +8,9 @@ import {serialize_package_json, type Map_Package_Json, load_package_json} from '
|
|
|
8
8
|
import {Task_Error} from './task.js';
|
|
9
9
|
import {find_cli, spawn_cli, spawn_cli_process} from './cli.js';
|
|
10
10
|
import {type Map_Src_Json, serialize_src_json, create_src_json} from './src_json.js';
|
|
11
|
-
import {
|
|
11
|
+
import {EXPORTS_EXCLUDER_DEFAULT} from './gro_config.js';
|
|
12
12
|
import {default_sveltekit_config} from './sveltekit_config.js';
|
|
13
|
-
import {SOURCE_DIRNAME} from './
|
|
13
|
+
import {SOURCE_DIRNAME} from './constants.js';
|
|
14
14
|
import {VITE_CLI} from './sveltekit_helpers.js';
|
|
15
15
|
|
|
16
16
|
export interface Options {
|
|
@@ -57,10 +57,12 @@ export const gro_plugin_sveltekit_app = ({
|
|
|
57
57
|
let sveltekit_process: Spawned_Process | undefined = undefined;
|
|
58
58
|
return {
|
|
59
59
|
name: 'gro_plugin_sveltekit_app',
|
|
60
|
-
setup: async ({dev, watch, log}) => {
|
|
60
|
+
setup: async ({dev, watch, log, config}) => {
|
|
61
61
|
const found_vite_cli = find_cli(vite_cli);
|
|
62
62
|
if (!found_vite_cli)
|
|
63
|
-
throw new Error(
|
|
63
|
+
throw new Error(
|
|
64
|
+
`Failed to find Vite CLI \`${vite_cli}\`, do you need to run \`${config.pm_cli} i\`?`,
|
|
65
|
+
);
|
|
64
66
|
if (dev) {
|
|
65
67
|
// `vite dev` in development mode
|
|
66
68
|
if (watch) {
|
|
@@ -123,7 +125,7 @@ export const gro_plugin_sveltekit_app = ({
|
|
|
123
125
|
assets_path,
|
|
124
126
|
'.well-known',
|
|
125
127
|
well_known_src_files === true
|
|
126
|
-
? (file_path) => !
|
|
128
|
+
? (file_path) => !EXPORTS_EXCLUDER_DEFAULT.test(file_path)
|
|
127
129
|
: well_known_src_files,
|
|
128
130
|
)
|
|
129
131
|
: null,
|
|
@@ -28,15 +28,15 @@ export const gro_plugin_sveltekit_library = ({
|
|
|
28
28
|
}: Options = {}): Plugin => {
|
|
29
29
|
return {
|
|
30
30
|
name: 'gro_plugin_sveltekit_library',
|
|
31
|
-
setup: async ({dev, log}) => {
|
|
31
|
+
setup: async ({dev, log, config}) => {
|
|
32
32
|
if (!dev) {
|
|
33
|
-
await run_svelte_package(svelte_package_options, svelte_package_cli, log);
|
|
33
|
+
await run_svelte_package(svelte_package_options, svelte_package_cli, log, config.pm_cli);
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
adapt: async ({log, timings, config}) => {
|
|
37
37
|
const package_json = load_package_json();
|
|
38
38
|
|
|
39
|
-
//
|
|
39
|
+
// link the CLI binaries if they exist
|
|
40
40
|
if (package_json.bin) {
|
|
41
41
|
const timing_to_link = timings.start(`${config.pm_cli} link`);
|
|
42
42
|
await Promise.all(
|
package/src/lib/loader.ts
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
import {default_sveltekit_config} from './sveltekit_config.js';
|
|
18
18
|
import {SVELTE_MATCHER, SVELTE_RUNES_MATCHER} from './svelte_helpers.js';
|
|
19
19
|
import {IS_THIS_GRO, paths} from './paths.js';
|
|
20
|
-
import {JSON_MATCHER, NODE_MODULES_DIRNAME, TS_MATCHER} from './
|
|
20
|
+
import {JSON_MATCHER, NODE_MODULES_DIRNAME, TS_MATCHER} from './constants.js';
|
|
21
21
|
import {to_define_import_meta_env, default_ts_transform_options} from './esbuild_helpers.js';
|
|
22
22
|
import {resolve_specifier} from './resolve_specifier.js';
|
|
23
23
|
import {resolve_node_specifier} from './resolve_node_specifier.js';
|
package/src/lib/module.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {LIB_DIRNAME} from './paths.js';
|
|
2
|
-
import {SOURCE_DIR, SOURCE_DIRNAME} from './
|
|
2
|
+
import {SOURCE_DIR, SOURCE_DIRNAME} from './constants.js';
|
|
3
3
|
|
|
4
4
|
export const MODULE_PATH_SRC_PREFIX = SOURCE_DIR;
|
|
5
5
|
export const MODULE_PATH_LIB_PREFIX = `$${LIB_DIRNAME}/`;
|
package/src/lib/moss_helpers.ts
CHANGED
|
@@ -3,7 +3,7 @@ import {existsSync} from 'node:fs';
|
|
|
3
3
|
import {resolve} from 'node:path';
|
|
4
4
|
|
|
5
5
|
import {has_dep, type Package_Json} from './package_json.js';
|
|
6
|
-
import {NODE_MODULES_DIRNAME} from './
|
|
6
|
+
import {NODE_MODULES_DIRNAME, PM_CLI_DEFAULT} from './constants.js';
|
|
7
7
|
|
|
8
8
|
export const MOSS_PACKAGE_DEP_NAME = '@ryanatkn/moss';
|
|
9
9
|
|
|
@@ -13,11 +13,12 @@ export const load_moss_plugin = async (
|
|
|
13
13
|
dep_name = MOSS_PACKAGE_DEP_NAME,
|
|
14
14
|
plugin_path = `${NODE_MODULES_DIRNAME}/${dep_name}/dist/gro_plugin_moss.js`, // TODO maybe lookup from its `package_json.exports`? kinda unnecessary
|
|
15
15
|
local_plugin_path = 'src/lib/gro_plugin_moss.ts',
|
|
16
|
+
pm_cli = PM_CLI_DEFAULT, // TODO source from config when possible, is just needed for error messages
|
|
16
17
|
): Promise<Result<{gro_plugin_moss: any}, {message: string}>> => {
|
|
17
18
|
if (!has_dep(dep_name, package_json)) {
|
|
18
19
|
return {
|
|
19
20
|
ok: false,
|
|
20
|
-
message: `no dependency found in package.json for ${dep_name}, install it with
|
|
21
|
+
message: `no dependency found in package.json for ${dep_name}, install it with \`${pm_cli} install -D ${dep_name}\``,
|
|
21
22
|
};
|
|
22
23
|
}
|
|
23
24
|
|
package/src/lib/package.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type {Src_Json} from './src_json.js';
|
|
|
5
5
|
|
|
6
6
|
export const package_json = {
|
|
7
7
|
name: '@ryanatkn/gro',
|
|
8
|
-
version: '0.
|
|
8
|
+
version: '0.143.1',
|
|
9
9
|
description: 'task runner and toolkit extending SvelteKit',
|
|
10
10
|
motto: 'generate, run, optimize',
|
|
11
11
|
glyph: '🌰',
|
|
@@ -56,7 +56,7 @@ export const package_json = {
|
|
|
56
56
|
tslib: '^2.8.0',
|
|
57
57
|
zod: '^3.23.8',
|
|
58
58
|
},
|
|
59
|
-
peerDependencies: {esbuild: '^0.21.0', svelte: '^5
|
|
59
|
+
peerDependencies: {esbuild: '^0.21.0', svelte: '^5'},
|
|
60
60
|
devDependencies: {
|
|
61
61
|
'@changesets/changelog-git': '^0.2.0',
|
|
62
62
|
'@changesets/types': '^6.0.0',
|
|
@@ -107,6 +107,7 @@ export const package_json = {
|
|
|
107
107
|
'./clean.task.js': {types: './dist/clean.task.d.ts', default: './dist/clean.task.js'},
|
|
108
108
|
'./cli.js': {types: './dist/cli.d.ts', default: './dist/cli.js'},
|
|
109
109
|
'./commit.task.js': {types: './dist/commit.task.d.ts', default: './dist/commit.task.js'},
|
|
110
|
+
'./constants.js': {types: './dist/constants.d.ts', default: './dist/constants.js'},
|
|
110
111
|
'./deploy.task.js': {types: './dist/deploy.task.d.ts', default: './dist/deploy.task.js'},
|
|
111
112
|
'./dev.task.js': {types: './dist/dev.task.d.ts', default: './dist/dev.task.js'},
|
|
112
113
|
'./env.js': {types: './dist/env.d.ts', default: './dist/env.js'},
|
|
@@ -187,10 +188,6 @@ export const package_json = {
|
|
|
187
188
|
'./package.gen.js': {types: './dist/package.gen.d.ts', default: './dist/package.gen.js'},
|
|
188
189
|
'./package.js': {types: './dist/package.d.ts', default: './dist/package.js'},
|
|
189
190
|
'./parse_imports.js': {types: './dist/parse_imports.d.ts', default: './dist/parse_imports.js'},
|
|
190
|
-
'./path_constants.js': {
|
|
191
|
-
types: './dist/path_constants.d.ts',
|
|
192
|
-
default: './dist/path_constants.js',
|
|
193
|
-
},
|
|
194
191
|
'./path.js': {types: './dist/path.d.ts', default: './dist/path.js'},
|
|
195
192
|
'./paths.js': {types: './dist/paths.d.ts', default: './dist/paths.js'},
|
|
196
193
|
'./plugin.js': {types: './dist/plugin.d.ts', default: './dist/plugin.js'},
|
|
@@ -270,7 +267,7 @@ export const package_json = {
|
|
|
270
267
|
|
|
271
268
|
export const src_json = {
|
|
272
269
|
name: '@ryanatkn/gro',
|
|
273
|
-
version: '0.
|
|
270
|
+
version: '0.143.1',
|
|
274
271
|
modules: {
|
|
275
272
|
'.': {
|
|
276
273
|
path: 'index.ts',
|
|
@@ -365,6 +362,39 @@ export const src_json = {
|
|
|
365
362
|
{name: 'task', kind: 'variable'},
|
|
366
363
|
],
|
|
367
364
|
},
|
|
365
|
+
'./constants.js': {
|
|
366
|
+
path: 'constants.ts',
|
|
367
|
+
declarations: [
|
|
368
|
+
{name: 'SOURCE_DIRNAME', kind: 'variable'},
|
|
369
|
+
{name: 'GRO_DIRNAME', kind: 'variable'},
|
|
370
|
+
{name: 'GRO_DIST_PREFIX', kind: 'variable'},
|
|
371
|
+
{name: 'SERVER_DIST_PATH', kind: 'variable'},
|
|
372
|
+
{name: 'GRO_DEV_DIRNAME', kind: 'variable'},
|
|
373
|
+
{name: 'SOURCE_DIR', kind: 'variable'},
|
|
374
|
+
{name: 'GRO_DIR', kind: 'variable'},
|
|
375
|
+
{name: 'GRO_DEV_DIR', kind: 'variable'},
|
|
376
|
+
{name: 'GRO_CONFIG_PATH', kind: 'variable'},
|
|
377
|
+
{name: 'README_FILENAME', kind: 'variable'},
|
|
378
|
+
{name: 'SVELTEKIT_CONFIG_FILENAME', kind: 'variable'},
|
|
379
|
+
{name: 'VITE_CONFIG_FILENAME', kind: 'variable'},
|
|
380
|
+
{name: 'NODE_MODULES_DIRNAME', kind: 'variable'},
|
|
381
|
+
{name: 'LOCKFILE_FILENAME', kind: 'variable'},
|
|
382
|
+
{name: 'SVELTEKIT_DEV_DIRNAME', kind: 'variable'},
|
|
383
|
+
{name: 'SVELTEKIT_BUILD_DIRNAME', kind: 'variable'},
|
|
384
|
+
{name: 'SVELTEKIT_DIST_DIRNAME', kind: 'variable'},
|
|
385
|
+
{name: 'SVELTEKIT_VITE_CACHE_PATH', kind: 'variable'},
|
|
386
|
+
{name: 'GITHUB_DIRNAME', kind: 'variable'},
|
|
387
|
+
{name: 'GIT_DIRNAME', kind: 'variable'},
|
|
388
|
+
{name: 'TSCONFIG_FILENAME', kind: 'variable'},
|
|
389
|
+
{name: 'TS_MATCHER', kind: 'variable'},
|
|
390
|
+
{name: 'JS_MATCHER', kind: 'variable'},
|
|
391
|
+
{name: 'JSON_MATCHER', kind: 'variable'},
|
|
392
|
+
{name: 'EVERYTHING_MATCHER', kind: 'variable'},
|
|
393
|
+
{name: 'JS_CLI_DEFAULT', kind: 'variable'},
|
|
394
|
+
{name: 'PM_CLI_DEFAULT', kind: 'variable'},
|
|
395
|
+
{name: 'PRETTIER_CLI_DEFAULT', kind: 'variable'},
|
|
396
|
+
],
|
|
397
|
+
},
|
|
368
398
|
'./deploy.task.js': {
|
|
369
399
|
path: 'deploy.task.ts',
|
|
370
400
|
declarations: [
|
|
@@ -545,8 +575,8 @@ export const src_json = {
|
|
|
545
575
|
{name: 'Raw_Gro_Config', kind: 'type'},
|
|
546
576
|
{name: 'Create_Gro_Config', kind: 'type'},
|
|
547
577
|
{name: 'create_empty_gro_config', kind: 'function'},
|
|
548
|
-
{name: '
|
|
549
|
-
{name: '
|
|
578
|
+
{name: 'SEARCH_EXCLUDER_DEFAULT', kind: 'variable'},
|
|
579
|
+
{name: 'EXPORTS_EXCLUDER_DEFAULT', kind: 'variable'},
|
|
550
580
|
{name: 'normalize_gro_config', kind: 'function'},
|
|
551
581
|
{name: 'Gro_Config_Module', kind: 'type'},
|
|
552
582
|
{name: 'load_gro_config', kind: 'function'},
|
|
@@ -716,36 +746,6 @@ export const src_json = {
|
|
|
716
746
|
{name: 'parse_imports', kind: 'function'},
|
|
717
747
|
],
|
|
718
748
|
},
|
|
719
|
-
'./path_constants.js': {
|
|
720
|
-
path: 'path_constants.ts',
|
|
721
|
-
declarations: [
|
|
722
|
-
{name: 'SOURCE_DIRNAME', kind: 'variable'},
|
|
723
|
-
{name: 'GRO_DIRNAME', kind: 'variable'},
|
|
724
|
-
{name: 'GRO_DIST_PREFIX', kind: 'variable'},
|
|
725
|
-
{name: 'SERVER_DIST_PATH', kind: 'variable'},
|
|
726
|
-
{name: 'GRO_DEV_DIRNAME', kind: 'variable'},
|
|
727
|
-
{name: 'SOURCE_DIR', kind: 'variable'},
|
|
728
|
-
{name: 'GRO_DIR', kind: 'variable'},
|
|
729
|
-
{name: 'GRO_DEV_DIR', kind: 'variable'},
|
|
730
|
-
{name: 'GRO_CONFIG_PATH', kind: 'variable'},
|
|
731
|
-
{name: 'README_FILENAME', kind: 'variable'},
|
|
732
|
-
{name: 'SVELTEKIT_CONFIG_FILENAME', kind: 'variable'},
|
|
733
|
-
{name: 'VITE_CONFIG_FILENAME', kind: 'variable'},
|
|
734
|
-
{name: 'NODE_MODULES_DIRNAME', kind: 'variable'},
|
|
735
|
-
{name: 'LOCKFILE_FILENAME', kind: 'variable'},
|
|
736
|
-
{name: 'SVELTEKIT_DEV_DIRNAME', kind: 'variable'},
|
|
737
|
-
{name: 'SVELTEKIT_BUILD_DIRNAME', kind: 'variable'},
|
|
738
|
-
{name: 'SVELTEKIT_DIST_DIRNAME', kind: 'variable'},
|
|
739
|
-
{name: 'SVELTEKIT_VITE_CACHE_PATH', kind: 'variable'},
|
|
740
|
-
{name: 'GITHUB_DIRNAME', kind: 'variable'},
|
|
741
|
-
{name: 'GIT_DIRNAME', kind: 'variable'},
|
|
742
|
-
{name: 'TSCONFIG_FILENAME', kind: 'variable'},
|
|
743
|
-
{name: 'TS_MATCHER', kind: 'variable'},
|
|
744
|
-
{name: 'JS_MATCHER', kind: 'variable'},
|
|
745
|
-
{name: 'JSON_MATCHER', kind: 'variable'},
|
|
746
|
-
{name: 'EVERYTHING_MATCHER', kind: 'variable'},
|
|
747
|
-
],
|
|
748
|
-
},
|
|
749
749
|
'./path.js': {
|
|
750
750
|
path: 'path.ts',
|
|
751
751
|
declarations: [
|
package/src/lib/package_json.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type {Flavored} from '@ryanatkn/belt/types.js';
|
|
|
7
7
|
import {styleText as st} from 'node:util';
|
|
8
8
|
|
|
9
9
|
import {paths, gro_paths, IS_THIS_GRO, replace_extension} from './paths.js';
|
|
10
|
-
import {SVELTEKIT_DIST_DIRNAME} from './
|
|
10
|
+
import {SVELTEKIT_DIST_DIRNAME} from './constants.js';
|
|
11
11
|
import {search_fs} from './search_fs.js';
|
|
12
12
|
import {has_sveltekit_library} from './sveltekit_helpers.js';
|
|
13
13
|
import {GITHUB_REPO_MATCHER} from './github.js';
|
|
@@ -87,7 +87,7 @@ export const Package_Json = z
|
|
|
87
87
|
// according to the npm docs, `name` and `version` are the only required properties
|
|
88
88
|
name: z.string(),
|
|
89
89
|
version: z.string(),
|
|
90
|
-
private: z.boolean({description: 'disallow
|
|
90
|
+
private: z.boolean({description: 'disallow publishing to the configured registry'}).optional(),
|
|
91
91
|
public: z
|
|
92
92
|
.boolean({
|
|
93
93
|
description:
|
package/src/lib/package_meta.ts
CHANGED
|
@@ -11,7 +11,7 @@ export interface Package_Meta {
|
|
|
11
11
|
name: string; // '@ryanatkn/fuz_library'
|
|
12
12
|
repo_name: string; // fuz_library
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* The github user/org.
|
|
15
15
|
*/
|
|
16
16
|
owner_name: string | null; // 'fuz-dev'
|
|
17
17
|
homepage_url: Url | null; // 'https://www.fuz.dev/'
|
package/src/lib/parse_imports.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type {Flavored} from '@ryanatkn/belt/types.js';
|
|
|
3
3
|
|
|
4
4
|
import type {Path_Id} from './path.js';
|
|
5
5
|
import {SVELTE_MATCHER} from './svelte_helpers.js';
|
|
6
|
-
import {JS_MATCHER, TS_MATCHER} from './
|
|
6
|
+
import {JS_MATCHER, TS_MATCHER} from './constants.js';
|
|
7
7
|
|
|
8
8
|
export const init_lexer = (): Promise<void> => init;
|
|
9
9
|
|
package/src/lib/paths.ts
CHANGED
package/src/lib/publish.task.ts
CHANGED
|
@@ -19,13 +19,6 @@ import {
|
|
|
19
19
|
} from './git.js';
|
|
20
20
|
import {CHANGESET_CLI} from './changeset_helpers.js';
|
|
21
21
|
|
|
22
|
-
// publish.task.ts
|
|
23
|
-
// - usage: `gro publish patch`
|
|
24
|
-
// - forwards args to `npm version`: https://docs.npmjs.com/v6/commands/npm-version
|
|
25
|
-
// - runs the production build
|
|
26
|
-
// - publishes to npm from the `main` branch, configurable with `--branch`
|
|
27
|
-
// - syncs commits and tags to the configured main branch
|
|
28
|
-
|
|
29
22
|
export const Args = z
|
|
30
23
|
.object({
|
|
31
24
|
branch: Git_Branch.describe('branch to publish from').default('main'),
|
|
@@ -44,9 +37,7 @@ export const Args = z
|
|
|
44
37
|
.boolean({description: 'build and prepare to publish without actually publishing'})
|
|
45
38
|
.default(false),
|
|
46
39
|
check: z.boolean({description: 'dual of no-check'}).default(true),
|
|
47
|
-
'no-check': z
|
|
48
|
-
.boolean({description: 'opt out of npm checking before publishing'})
|
|
49
|
-
.default(false),
|
|
40
|
+
'no-check': z.boolean({description: 'opt out of checking before publishing'}).default(false),
|
|
50
41
|
build: z.boolean({description: 'dual of no-build'}).default(true),
|
|
51
42
|
'no-build': z.boolean({description: 'opt out of building'}).default(false),
|
|
52
43
|
pull: z.boolean({description: 'dual of no-pull'}).default(true),
|
|
@@ -57,7 +48,7 @@ export const Args = z
|
|
|
57
48
|
export type Args = z.infer<typeof Args>;
|
|
58
49
|
|
|
59
50
|
export const task: Task<Args> = {
|
|
60
|
-
summary: 'bump version, publish to
|
|
51
|
+
summary: 'bump version, publish to the configured registry, and git push',
|
|
61
52
|
Args,
|
|
62
53
|
run: async ({args, log, invoke_task}): Promise<void> => {
|
|
63
54
|
const {
|
|
@@ -179,8 +170,8 @@ export const task: Task<Args> = {
|
|
|
179
170
|
return;
|
|
180
171
|
}
|
|
181
172
|
|
|
182
|
-
const
|
|
183
|
-
if (!
|
|
173
|
+
const changeset_publish_result = await spawn_cli(found_changeset_cli, ['publish'], log);
|
|
174
|
+
if (!changeset_publish_result?.ok) {
|
|
184
175
|
throw new Task_Error(
|
|
185
176
|
`\`${changeset_cli} publish\` failed - continue manually or try again after running \`git reset --hard\``,
|
|
186
177
|
);
|
|
@@ -3,7 +3,7 @@ import {spawn} from '@ryanatkn/belt/process.js';
|
|
|
3
3
|
import {rm} from 'node:fs/promises';
|
|
4
4
|
|
|
5
5
|
import {Task_Error, type Task} from './task.js';
|
|
6
|
-
import {LOCKFILE_FILENAME, NODE_MODULES_DIRNAME} from './
|
|
6
|
+
import {LOCKFILE_FILENAME, NODE_MODULES_DIRNAME} from './constants.js';
|
|
7
7
|
|
|
8
8
|
export const Args = z.object({}).strict();
|
|
9
9
|
export type Args = z.infer<typeof Args>;
|
|
@@ -12,31 +12,31 @@ export const task: Task<Args> = {
|
|
|
12
12
|
summary: `refreshes ${LOCKFILE_FILENAME} with the latest and cleanest deps`,
|
|
13
13
|
Args,
|
|
14
14
|
run: async ({log, config}): Promise<void> => {
|
|
15
|
-
log.info(
|
|
16
|
-
const initial_install_result = await spawn(config.pm_cli, ['
|
|
15
|
+
log.info(`running the initial \`${config.pm_cli} install\``);
|
|
16
|
+
const initial_install_result = await spawn(config.pm_cli, ['install']);
|
|
17
17
|
if (!initial_install_result.ok) {
|
|
18
|
-
throw new Task_Error(
|
|
18
|
+
throw new Task_Error(`Failed initial \`${config.pm_cli} install\``);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
// Deleting both the lockfile and node_modules upgrades to the latest minor/patch versions.
|
|
22
22
|
await Promise.all([rm(LOCKFILE_FILENAME), rm(NODE_MODULES_DIRNAME, {recursive: true})]);
|
|
23
23
|
log.info(
|
|
24
|
-
`running
|
|
24
|
+
`running \`${config.pm_cli} install\` after deleting ${LOCKFILE_FILENAME} and ${NODE_MODULES_DIRNAME}, this can take a while...`,
|
|
25
25
|
);
|
|
26
|
-
const second_install_result = await spawn(config.pm_cli, ['
|
|
26
|
+
const second_install_result = await spawn(config.pm_cli, ['install']);
|
|
27
27
|
if (!second_install_result.ok) {
|
|
28
28
|
throw new Task_Error(
|
|
29
|
-
`Failed
|
|
29
|
+
`Failed \`${config.pm_cli} install\` after deleting ${LOCKFILE_FILENAME} and ${NODE_MODULES_DIRNAME}`,
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
// Deleting the lockfile and reinstalling cleans the lockfile of unnecessary dep noise,
|
|
34
34
|
// like esbuild's many packages for each platform.
|
|
35
35
|
await rm(LOCKFILE_FILENAME);
|
|
36
|
-
log.info(`running
|
|
37
|
-
const final_install_result = await spawn(config.pm_cli, ['
|
|
36
|
+
log.info(`running \`${config.pm_cli} install\` one last time to clean ${LOCKFILE_FILENAME}`);
|
|
37
|
+
const final_install_result = await spawn(config.pm_cli, ['install']);
|
|
38
38
|
if (!final_install_result.ok) {
|
|
39
|
-
throw new Task_Error(
|
|
39
|
+
throw new Task_Error(`Failed \`${config.pm_cli} install\``);
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
42
|
};
|
|
@@ -4,7 +4,7 @@ import {DEV} from 'esm-env';
|
|
|
4
4
|
|
|
5
5
|
import {Package_Json, Package_Json_Exports, load_package_json} from './package_json.js';
|
|
6
6
|
import {paths} from './paths.js';
|
|
7
|
-
import {NODE_MODULES_DIRNAME} from './
|
|
7
|
+
import {NODE_MODULES_DIRNAME} from './constants.js';
|
|
8
8
|
import type {Resolved_Specifier} from './resolve_specifier.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -48,7 +48,7 @@ export const resolve_node_specifier = (
|
|
|
48
48
|
if (!existsSync(package_dir)) {
|
|
49
49
|
if (throw_on_missing_package) {
|
|
50
50
|
throw Error(
|
|
51
|
-
`Package not found at ${package_dir} for specifier ${specifier}, you may need to
|
|
51
|
+
`Package not found at ${package_dir} for specifier ${specifier}, you may need to install packages or fix the path` +
|
|
52
52
|
(parent_path ? ` imported from ${parent_path}` : ''),
|
|
53
53
|
);
|
|
54
54
|
} else {
|
package/src/lib/run_task.ts
CHANGED
|
@@ -72,7 +72,7 @@ export const run_task = async (
|
|
|
72
72
|
: `Unexpected error running task ${st(
|
|
73
73
|
'cyan',
|
|
74
74
|
task_meta.name,
|
|
75
|
-
)}. If this is unexpected try running
|
|
75
|
+
)}. If this is unexpected try running \`${config.pm_cli} install\` and \`gro clean\`.`,
|
|
76
76
|
),
|
|
77
77
|
error: err,
|
|
78
78
|
};
|
|
@@ -2,7 +2,7 @@ import type {Config as SveltekitConfig} from '@sveltejs/kit';
|
|
|
2
2
|
import type {CompileOptions, ModuleCompileOptions, PreprocessorGroup} from 'svelte/compiler';
|
|
3
3
|
import {join} from 'node:path';
|
|
4
4
|
|
|
5
|
-
import {SVELTEKIT_CONFIG_FILENAME} from './
|
|
5
|
+
import {SVELTEKIT_CONFIG_FILENAME} from './constants.js';
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
8
|
|