@ryanatkn/gro 0.127.1 → 0.129.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 CHANGED
@@ -1,6 +1,6 @@
1
- # gro <img src="static/favicon.png" width="32" height="32">
1
+ # gro <img src="static/logo.svg" alt="a pixelated green oak acorn with a glint of sun" width="32" height="32">
2
2
 
3
- <img src="static/favicon.png" align="right" width="192" height="192">
3
+ [<img src="static/logo.svg" alt="a pixelated green oak acorn with a glint of sun" align="right" width="192" height="192">](https://gro.ryanatkn.com/)
4
4
 
5
5
  > task runner and toolkit extending SvelteKit 🌰 generate, run, optimize
6
6
 
package/dist/changelog.js CHANGED
@@ -1,4 +1,4 @@
1
- import { readFile, writeFile } from 'fs/promises';
1
+ import { readFile, writeFile } from 'node:fs/promises';
2
2
  import { z } from 'zod';
3
3
  import { github_fetch_commit_prs } from './github.js';
4
4
  /**
@@ -1,7 +1,7 @@
1
1
  import { test } from 'uvu';
2
2
  import * as assert from 'uvu/assert';
3
3
  import { Logger } from '@ryanatkn/belt/log.js';
4
- import { readFile, writeFile } from 'fs/promises';
4
+ import { readFile, writeFile } from 'node:fs/promises';
5
5
  import { update_changelog } from './changelog.js';
6
6
  import { load_from_env } from './env.js';
7
7
  const log = new Logger();
package/dist/docs/dev.md CHANGED
@@ -35,6 +35,6 @@ See [plugin.md](plugin.md) to learn more.
35
35
 
36
36
  <p align="center">
37
37
  <a href="https://github.com/ryanatkn/gro">
38
- <img src="static/favicon.png" width="192" height="192">
38
+ <img src="static/logo.svg" alt="a pixelated green oak acorn with a glint of sun" width="192" height="192">
39
39
  </a>
40
40
  </p>
package/dist/git.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { SpawnOptions } from 'child_process';
1
+ import type { SpawnOptions } from 'node:child_process';
2
2
  import { z } from 'zod';
3
3
  export declare const Git_Origin: z.ZodBranded<z.ZodString, "Git_Origin">;
4
4
  export type Git_Origin = z.infer<typeof Git_Origin>;
package/dist/gro.js CHANGED
@@ -11,7 +11,7 @@ and it also provides special handling for the case
11
11
  where we're running Gro inside Gro's own repo for development.
12
12
 
13
13
  */
14
- const invoke_path = await resolve_gro_module_path('invoke.js');
14
+ const invoke_path = resolve_gro_module_path('invoke.js');
15
15
  const loader_path = join(invoke_path, '../loader.js');
16
16
  const spawned = await spawn_with_loader(loader_path, invoke_path, process.argv.slice(2));
17
17
  if (!spawned.ok) {
@@ -33,10 +33,15 @@ import { type Spawn_Result } from '@ryanatkn/belt/process.js';
33
33
  * When using the global CLI, this uses the global Gro installation.
34
34
  *
35
35
  */
36
- export declare const resolve_gro_module_path: (path?: string) => Promise<string>;
36
+ export declare const resolve_gro_module_path: (path?: string) => string;
37
37
  /**
38
38
  * Runs a file using the Gro loader.
39
39
  *
40
+ * Uses conditional exports to correctly set up `esm-env` as development by default,
41
+ * so if you want production set `NODE_ENV=production`.
42
+ *
43
+ * @see https://nodejs.org/api/packages.html#conditional-exports
44
+ *
40
45
  * @param loader_path path to loader
41
46
  * @param invoke_path path to file to spawn with `node`
42
47
  */
@@ -1,4 +1,4 @@
1
- import { realpath } from 'node:fs/promises';
1
+ import { realpathSync } from 'node:fs';
2
2
  import { join, resolve } from 'node:path';
3
3
  import { fileURLToPath } from 'node:url';
4
4
  import { spawn } from '@ryanatkn/belt/process.js';
@@ -43,12 +43,12 @@ This module is intended to have minimal dependencies to avoid over-imports in th
43
43
  * When using the global CLI, this uses the global Gro installation.
44
44
  *
45
45
  */
46
- export const resolve_gro_module_path = async (path = '') => {
46
+ export const resolve_gro_module_path = (path = '') => {
47
47
  const gro_bin_path = resolve(NODE_MODULES_DIRNAME, '.bin/gro');
48
48
  // case 1
49
49
  // Prefer any locally installed version of Gro.
50
50
  if (existsSync(gro_bin_path)) {
51
- return join(await realpath(gro_bin_path), '..', path);
51
+ return join(realpathSync(gro_bin_path), '..', path);
52
52
  }
53
53
  // case 2
54
54
  // If running Gro inside its own repo, require the local dist.
@@ -65,16 +65,28 @@ export const resolve_gro_module_path = async (path = '') => {
65
65
  /**
66
66
  * Runs a file using the Gro loader.
67
67
  *
68
+ * Uses conditional exports to correctly set up `esm-env` as development by default,
69
+ * so if you want production set `NODE_ENV=production`.
70
+ *
71
+ * @see https://nodejs.org/api/packages.html#conditional-exports
72
+ *
68
73
  * @param loader_path path to loader
69
74
  * @param invoke_path path to file to spawn with `node`
70
75
  */
71
- export const spawn_with_loader = async (loader_path, invoke_path, argv) => spawn('node', [
72
- '--import',
73
- `data:text/javascript,
76
+ export const spawn_with_loader = (loader_path, invoke_path, argv) => {
77
+ const args = [
78
+ '--import',
79
+ // This does the same as `$lib/register.ts` but without the cost of importing another file.
80
+ `data:text/javascript,
74
81
  import {register} from "node:module";
75
82
  import {pathToFileURL} from "node:url";
76
83
  register("${loader_path}", pathToFileURL("./"));`,
77
- '--enable-source-maps',
78
- invoke_path,
79
- ...argv,
80
- ]);
84
+ '--enable-source-maps', // because TypeScript
85
+ ];
86
+ // In almost all cases we want the exports condition to be `"development"`.
87
+ if (process.env.NODE_ENV !== 'production') {
88
+ args.push('-C', 'development'); // same as `--conditions`
89
+ }
90
+ args.push(invoke_path, ...argv);
91
+ return spawn('node', args);
92
+ };
@@ -1,3 +1,4 @@
1
+ import { Timings } from '@ryanatkn/belt/timings.js';
1
2
  import { type Args } from './args.js';
2
3
  import { Raw_Input_Path } from './input_path.js';
3
4
  import type { Gro_Config } from './config.js';
@@ -17,5 +18,10 @@ import type { Gro_Config } from './config.js';
17
18
  * Precise error messages are especially difficult and
18
19
  * there are some subtle differences in the complex logical branches.
19
20
  * The comments describe each condition.
21
+ *
22
+ * @param task_name - The name of the task to invoke.
23
+ * @param args - The CLI args to pass to the task.
24
+ * @param config - The Gro configuration.
25
+ * @param initial_timings - The timings to use for the top-level task, `null` for composed tasks.
20
26
  */
21
- export declare const invoke_task: (task_name: Raw_Input_Path, args: Args | undefined, config: Gro_Config, timings?: any) => Promise<void>;
27
+ export declare const invoke_task: (task_name: Raw_Input_Path, args: Args | undefined, config: Gro_Config, initial_timings?: Timings | null) => Promise<void>;
@@ -24,12 +24,20 @@ import { log_tasks, log_error_reasons } from './task_logging.js';
24
24
  * Precise error messages are especially difficult and
25
25
  * there are some subtle differences in the complex logical branches.
26
26
  * The comments describe each condition.
27
+ *
28
+ * @param task_name - The name of the task to invoke.
29
+ * @param args - The CLI args to pass to the task.
30
+ * @param config - The Gro configuration.
31
+ * @param initial_timings - The timings to use for the top-level task, `null` for composed tasks.
27
32
  */
28
- export const invoke_task = async (task_name, args, config, timings = new Timings()) => {
33
+ export const invoke_task = async (task_name, args, config, initial_timings = null) => {
29
34
  const log = new System_Logger(print_log_label(task_name || 'gro'));
30
35
  log.info('invoking', task_name ? cyan(task_name) : 'gro');
36
+ const timings = initial_timings ?? new Timings();
31
37
  const total_timing = create_stopwatch();
32
38
  const finish = () => {
39
+ if (!initial_timings)
40
+ return; // print timings only for the top-level task
33
41
  print_timings(timings, log);
34
42
  log.info(`🕒 ${print_ms(total_timing())}`);
35
43
  };
package/dist/package.d.ts CHANGED
@@ -38,6 +38,7 @@ export declare const package_json: {
38
38
  chokidar: string;
39
39
  dotenv: string;
40
40
  'es-module-lexer': string;
41
+ 'esm-env': string;
41
42
  mri: string;
42
43
  prettier: string;
43
44
  'prettier-plugin-svelte': string;
package/dist/package.js CHANGED
@@ -1,11 +1,11 @@
1
1
  // generated by src/lib/package.gen.ts
2
2
  export const package_json = {
3
3
  name: '@ryanatkn/gro',
4
- version: '0.127.1',
4
+ version: '0.129.0',
5
5
  description: 'task runner and toolkit extending SvelteKit',
6
6
  motto: 'generate, run, optimize',
7
7
  glyph: '🌰',
8
- logo: 'favicon.png',
8
+ logo: 'logo.svg',
9
9
  logo_alt: 'a pixelated green oak acorn with a glint of sun',
10
10
  public: true,
11
11
  license: 'MIT',
@@ -34,10 +34,11 @@ export const package_json = {
34
34
  'typescript',
35
35
  ],
36
36
  dependencies: {
37
- '@ryanatkn/belt': '^0.23.0',
37
+ '@ryanatkn/belt': '^0.24.1',
38
38
  chokidar: '^3.6.0',
39
39
  dotenv: '^16.4.5',
40
40
  'es-module-lexer': '^1.5.4',
41
+ 'esm-env': '^1.0.0',
41
42
  mri: '^1.2.0',
42
43
  prettier: '^3.3.2',
43
44
  'prettier-plugin-svelte': '^3.2.5',
@@ -50,8 +51,8 @@ export const package_json = {
50
51
  '@changesets/changelog-git': '^0.2.0',
51
52
  '@changesets/types': '^6.0.0',
52
53
  '@ryanatkn/eslint-config': '^0.1.3',
53
- '@ryanatkn/fuz': '^0.105.2',
54
- '@ryanatkn/moss': '^0.6.2',
54
+ '@ryanatkn/fuz': '^0.107.0',
55
+ '@ryanatkn/moss': '^0.6.3',
55
56
  '@sveltejs/adapter-static': '^3.0.2',
56
57
  '@sveltejs/kit': '^2.5.18',
57
58
  '@sveltejs/package': '^2.3.2',
@@ -262,7 +263,7 @@ export const package_json = {
262
263
  };
263
264
  export const src_json = {
264
265
  name: '@ryanatkn/gro',
265
- version: '0.127.1',
266
+ version: '0.129.0',
266
267
  modules: {
267
268
  '.': {
268
269
  path: 'index.ts',
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { spawn } from '@ryanatkn/belt/process.js';
3
- import { rm } from 'fs/promises';
3
+ import { rm } from 'node:fs/promises';
4
4
  import { Task_Error } from './task.js';
5
5
  import { LOCKFILE_FILENAME, NODE_MODULES_DIRNAME } from './path_constants.js';
6
6
  export const Args = z.object({}).strict();
package/dist/run.task.js CHANGED
@@ -22,7 +22,7 @@ export const task = {
22
22
  if (!existsSync(path)) {
23
23
  throw new Task_Error('Cannot find file to run at path: ' + path);
24
24
  }
25
- const loader_path = await resolve_gro_module_path('loader.js');
25
+ const loader_path = resolve_gro_module_path('loader.js');
26
26
  const spawned = await spawn_with_loader(loader_path, path, argv);
27
27
  if (!spawned.ok) {
28
28
  throw new Task_Error(`\`gro run ${path}\` failed with exit code ${spawned.code}`);
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@ryanatkn/gro",
3
- "version": "0.127.1",
3
+ "version": "0.129.0",
4
4
  "description": "task runner and toolkit extending SvelteKit",
5
5
  "motto": "generate, run, optimize",
6
6
  "glyph": "🌰",
7
- "logo": "favicon.png",
7
+ "logo": "logo.svg",
8
8
  "logo_alt": "a pixelated green oak acorn with a glint of sun",
9
9
  "public": true,
10
10
  "license": "MIT",
@@ -44,10 +44,11 @@
44
44
  "typescript"
45
45
  ],
46
46
  "dependencies": {
47
- "@ryanatkn/belt": "^0.23.0",
47
+ "@ryanatkn/belt": "^0.24.1",
48
48
  "chokidar": "^3.6.0",
49
49
  "dotenv": "^16.4.5",
50
50
  "es-module-lexer": "^1.5.4",
51
+ "esm-env": "^1.0.0",
51
52
  "mri": "^1.2.0",
52
53
  "prettier": "^3.3.2",
53
54
  "prettier-plugin-svelte": "^3.2.5",
@@ -63,8 +64,8 @@
63
64
  "@changesets/changelog-git": "^0.2.0",
64
65
  "@changesets/types": "^6.0.0",
65
66
  "@ryanatkn/eslint-config": "^0.1.3",
66
- "@ryanatkn/fuz": "^0.105.2",
67
- "@ryanatkn/moss": "^0.6.2",
67
+ "@ryanatkn/fuz": "^0.107.0",
68
+ "@ryanatkn/moss": "^0.6.3",
68
69
  "@sveltejs/adapter-static": "^3.0.2",
69
70
  "@sveltejs/kit": "^2.5.18",
70
71
  "@sveltejs/package": "^2.3.2",