@ryanatkn/gro 0.189.1 → 0.189.3

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.
@@ -14,6 +14,9 @@ export declare const Args: z.ZodObject<{
14
14
  'no-package_json': z.ZodDefault<z.ZodBoolean>;
15
15
  lint: z.ZodDefault<z.ZodBoolean>;
16
16
  'no-lint': z.ZodDefault<z.ZodBoolean>;
17
+ build: z.ZodDefault<z.ZodBoolean>;
18
+ 'no-build': z.ZodDefault<z.ZodBoolean>;
19
+ force_build: z.ZodDefault<z.ZodBoolean>;
17
20
  sync: z.ZodDefault<z.ZodBoolean>;
18
21
  'no-sync': z.ZodDefault<z.ZodBoolean>;
19
22
  install: z.ZodDefault<z.ZodBoolean>;
@@ -1 +1 @@
1
- {"version":3,"file":"check.task.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/check.task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAKtB,OAAO,EAAY,KAAK,IAAI,EAAC,MAAM,WAAW,CAAC;AAG/C,cAAc;AACd,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;kBAuBf,CAAC;AACH,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAExC,cAAc;AACd,eAAO,MAAM,IAAI,EAAE,IAAI,CAAC,IAAI,CA4D3B,CAAC"}
1
+ {"version":3,"file":"check.task.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/check.task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAKtB,OAAO,EAAY,KAAK,IAAI,EAAC,MAAM,WAAW,CAAC;AAG/C,cAAc;AACd,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;kBA6Bf,CAAC;AACH,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAExC,cAAc;AACd,eAAO,MAAM,IAAI,EAAE,IAAI,CAAC,IAAI,CA6E3B,CAAC"}
@@ -21,6 +21,12 @@ export const Args = z.strictObject({
21
21
  .default(false),
22
22
  lint: z.boolean().meta({ description: 'dual of no-lint' }).default(true),
23
23
  'no-lint': z.boolean().meta({ description: 'opt out of linting' }).default(false),
24
+ build: z.boolean().meta({ description: 'dual of no-build' }).default(false),
25
+ 'no-build': z.boolean().meta({ description: 'opt out of building' }).default(true),
26
+ force_build: z
27
+ .boolean()
28
+ .meta({ description: 'force a fresh build, ignoring the cache' })
29
+ .default(false),
24
30
  sync: z.boolean().meta({ description: 'dual of no-sync' }).default(true),
25
31
  'no-sync': z.boolean().meta({ description: 'opt out of syncing' }).default(false),
26
32
  install: z.boolean().meta({ description: 'opt into installing packages' }).default(false),
@@ -34,7 +40,7 @@ export const task = {
34
40
  summary: 'check that everything is ready to commit',
35
41
  Args,
36
42
  run: async ({ args, invoke_task, log, config }) => {
37
- const { typecheck, test, gen, format, package_json, lint, sync, install, workspace } = args;
43
+ const { typecheck, test, gen, format, package_json, lint, build, force_build, sync, install, workspace, } = args;
38
44
  // When checking the workspace, which was added for CI, never sync.
39
45
  // Setup like installing packages and `sveltekit-sync` should be done in the CI setup.
40
46
  if (!workspace) {
@@ -71,6 +77,10 @@ export const task = {
71
77
  if (lint) {
72
78
  await invoke_task('lint');
73
79
  }
80
+ if (build) {
81
+ // Skip sync/gen/install since check handles those separately
82
+ await invoke_task('build', { sync: false, gen: false, install: false, force_build });
83
+ }
74
84
  if (workspace) {
75
85
  const error_message = await git_check_clean_workspace();
76
86
  if (error_message) {
@@ -2,6 +2,7 @@ import { z } from 'zod';
2
2
  import { type Task } from './task.ts';
3
3
  /** @nodocs */
4
4
  export declare const Args: z.ZodObject<{
5
+ _: z.ZodOptional<z.ZodArray<z.ZodString>>;
5
6
  check: z.ZodDefault<z.ZodBoolean>;
6
7
  }, z.core.$strict>;
7
8
  export type Args = z.infer<typeof Args>;
@@ -1 +1 @@
1
- {"version":3,"file":"format.task.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/format.task.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,EAAY,KAAK,IAAI,EAAC,MAAM,WAAW,CAAC;AAI/C,cAAc;AACd,eAAO,MAAM,IAAI;;kBAKf,CAAC;AACH,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAExC,cAAc;AACd,eAAO,MAAM,IAAI,EAAE,IAAI,CAAC,IAAI,CAqB3B,CAAC"}
1
+ {"version":3,"file":"format.task.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/format.task.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAMtB,OAAO,EAAY,KAAK,IAAI,EAAC,MAAM,WAAW,CAAC;AAE/C,cAAc;AACd,eAAO,MAAM,IAAI;;;kBAMf,CAAC;AACH,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAExC,cAAc;AACd,eAAO,MAAM,IAAI,EAAE,IAAI,CAAC,IAAI,CAuB3B,CAAC"}
@@ -1,10 +1,13 @@
1
1
  import { print_spawn_result } from '@fuzdev/fuz_util/process.js';
2
2
  import { z } from 'zod';
3
- import { TaskError } from "./task.js";
3
+ import { to_implicit_forwarded_args } from "./args.js";
4
+ import { PRETTIER_CLI_DEFAULT } from "./constants.js";
4
5
  import { format_directory } from "./format_directory.js";
5
6
  import { paths } from "./paths.js";
7
+ import { TaskError } from "./task.js";
6
8
  /** @nodocs */
7
9
  export const Args = z.strictObject({
10
+ _: z.array(z.string()).meta({ description: 'files or directories to format' }).optional(),
8
11
  check: z
9
12
  .boolean()
10
13
  .meta({ description: 'exit with a nonzero code if any files are unformatted' })
@@ -15,9 +18,8 @@ export const task = {
15
18
  summary: 'format source files',
16
19
  Args,
17
20
  run: async ({ args, log, config }) => {
18
- const { check } = args;
19
- // TODO forward prettier args
20
- const format_result = await format_directory(log, paths.source, check, undefined, undefined, undefined, config.pm_cli);
21
+ const { _: patterns, check } = args;
22
+ const format_result = await format_directory(log, paths.source, check, undefined, undefined, undefined, config.pm_cli, to_implicit_forwarded_args(PRETTIER_CLI_DEFAULT), patterns);
21
23
  if (!format_result.ok) {
22
24
  throw new TaskError(`Failed ${check ? 'formatting check' : 'to format'}. ${print_spawn_result(format_result)}`);
23
25
  }
@@ -1,11 +1,13 @@
1
+ import { type Args } from '@fuzdev/fuz_util/args.js';
1
2
  import type { Logger } from '@fuzdev/fuz_util/log.js';
2
3
  import type { SpawnResult } from '@fuzdev/fuz_util/process.js';
3
4
  import { type Cli } from './cli.ts';
4
5
  /**
5
- * Formats a directory on the filesystem.
6
- * If the source directory is given, it also formats all of the root directory files.
6
+ * Formats files on the filesystem.
7
+ * When `patterns` is provided, formats those specific files/patterns.
8
+ * Otherwise formats `dir` with default extensions, plus root files if `dir` is `paths.source`.
7
9
  * This is separated from `./format_file` to avoid importing all of the `prettier` code
8
10
  * inside modules that import this one. (which has a nontrivial cost)
9
11
  */
10
- export declare const format_directory: (log: Logger, dir: string, check?: boolean, extensions?: string, root_paths?: string, prettier_cli?: string | Cli, pm_cli?: string) => Promise<SpawnResult>;
12
+ export declare const format_directory: (log: Logger, dir: string, check?: boolean, extensions?: string, root_paths?: string, prettier_cli?: string | Cli, pm_cli?: string, additional_args?: Args, patterns?: Array<string>) => Promise<SpawnResult>;
11
13
  //# sourceMappingURL=format_directory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"format_directory.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/format_directory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,6BAA6B,CAAC;AAG7D,OAAO,EAAyB,KAAK,GAAG,EAAC,MAAM,UAAU,CAAC;AAuB1D;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAC5B,KAAK,MAAM,EACX,KAAK,MAAM,EACX,eAAa,EACb,mBAA+B,EAC/B,mBAA+B,EAC/B,eAAc,MAAM,GAAG,GAA0B,EACjD,SAAQ,MAAuB,KAC7B,OAAO,CAAC,WAAW,CAcrB,CAAC"}
1
+ {"version":3,"file":"format_directory.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/format_directory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,IAAI,EAAC,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EAAyB,KAAK,GAAG,EAAC,MAAM,UAAU,CAAC;AAuB1D;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAC5B,KAAK,MAAM,EACX,KAAK,MAAM,EACX,eAAa,EACb,mBAA+B,EAC/B,mBAA+B,EAC/B,eAAc,MAAM,GAAG,GAA0B,EACjD,SAAQ,MAAuB,EAC/B,kBAAkB,IAAI,EACtB,WAAW,KAAK,CAAC,MAAM,CAAC,KACtB,OAAO,CAAC,WAAW,CAoBrB,CAAC"}
@@ -1,5 +1,4 @@
1
1
  import { args_serialize } from '@fuzdev/fuz_util/args.js';
2
- import { to_forwarded_args } from "./args.js";
3
2
  import { spawn_cli, to_cli_name } from "./cli.js";
4
3
  import { GITHUB_DIRNAME, README_FILENAME, SVELTE_CONFIG_FILENAME, VITE_CONFIG_FILENAME, TSCONFIG_FILENAME, GRO_CONFIG_FILENAME, PM_CLI_DEFAULT, PRETTIER_CLI_DEFAULT, } from "./constants.js";
5
4
  import { paths } from "./paths.js";
@@ -13,18 +12,26 @@ const ROOT_PATHS_DEFAULT = `${[
13
12
  GITHUB_DIRNAME,
14
13
  ].join(',')}/**/*`;
15
14
  /**
16
- * Formats a directory on the filesystem.
17
- * If the source directory is given, it also formats all of the root directory files.
15
+ * Formats files on the filesystem.
16
+ * When `patterns` is provided, formats those specific files/patterns.
17
+ * Otherwise formats `dir` with default extensions, plus root files if `dir` is `paths.source`.
18
18
  * This is separated from `./format_file` to avoid importing all of the `prettier` code
19
19
  * inside modules that import this one. (which has a nontrivial cost)
20
20
  */
21
- export const format_directory = async (log, dir, check = false, extensions = EXTENSIONS_DEFAULT, root_paths = ROOT_PATHS_DEFAULT, prettier_cli = PRETTIER_CLI_DEFAULT, pm_cli = PM_CLI_DEFAULT) => {
22
- const forwarded_args = to_forwarded_args(to_cli_name(prettier_cli));
23
- forwarded_args[check ? 'check' : 'write'] = true;
21
+ export const format_directory = async (log, dir, check = false, extensions = EXTENSIONS_DEFAULT, root_paths = ROOT_PATHS_DEFAULT, prettier_cli = PRETTIER_CLI_DEFAULT, pm_cli = PM_CLI_DEFAULT, additional_args, patterns) => {
22
+ const forwarded_args = { ...additional_args };
23
+ if (forwarded_args.check === undefined && forwarded_args.write === undefined) {
24
+ forwarded_args[check ? 'check' : 'write'] = true;
25
+ }
24
26
  const serialized_args = args_serialize(forwarded_args);
25
- serialized_args.push(`${dir}**/*.{${extensions}}`);
26
- if (dir === paths.source) {
27
- serialized_args.push(`${paths.root}{${root_paths}}`);
27
+ if (patterns?.length) {
28
+ serialized_args.push(...patterns);
29
+ }
30
+ else {
31
+ serialized_args.push(`${dir}**/*.{${extensions}}`);
32
+ if (dir === paths.source) {
33
+ serialized_args.push(`${paths.root}{${root_paths}}`);
34
+ }
28
35
  }
29
36
  const spawned = await spawn_cli(prettier_cli, serialized_args, log);
30
37
  if (!spawned)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ryanatkn/gro",
3
- "version": "0.189.1",
3
+ "version": "0.189.3",
4
4
  "description": "task runner and toolkit extending SvelteKit",
5
5
  "motto": "generate, run, optimize",
6
6
  "glyph": "🌰",
@@ -23,6 +23,12 @@ export const Args = z.strictObject({
23
23
  .default(false),
24
24
  lint: z.boolean().meta({description: 'dual of no-lint'}).default(true),
25
25
  'no-lint': z.boolean().meta({description: 'opt out of linting'}).default(false),
26
+ build: z.boolean().meta({description: 'dual of no-build'}).default(false),
27
+ 'no-build': z.boolean().meta({description: 'opt out of building'}).default(true),
28
+ force_build: z
29
+ .boolean()
30
+ .meta({description: 'force a fresh build, ignoring the cache'})
31
+ .default(false),
26
32
  sync: z.boolean().meta({description: 'dual of no-sync'}).default(true),
27
33
  'no-sync': z.boolean().meta({description: 'opt out of syncing'}).default(false),
28
34
  install: z.boolean().meta({description: 'opt into installing packages'}).default(false),
@@ -38,7 +44,19 @@ export const task: Task<Args> = {
38
44
  summary: 'check that everything is ready to commit',
39
45
  Args,
40
46
  run: async ({args, invoke_task, log, config}) => {
41
- const {typecheck, test, gen, format, package_json, lint, sync, install, workspace} = args;
47
+ const {
48
+ typecheck,
49
+ test,
50
+ gen,
51
+ format,
52
+ package_json,
53
+ lint,
54
+ build,
55
+ force_build,
56
+ sync,
57
+ install,
58
+ workspace,
59
+ } = args;
42
60
 
43
61
  // When checking the workspace, which was added for CI, never sync.
44
62
  // Setup like installing packages and `sveltekit-sync` should be done in the CI setup.
@@ -81,6 +99,11 @@ export const task: Task<Args> = {
81
99
  await invoke_task('lint');
82
100
  }
83
101
 
102
+ if (build) {
103
+ // Skip sync/gen/install since check handles those separately
104
+ await invoke_task('build', {sync: false, gen: false, install: false, force_build});
105
+ }
106
+
84
107
  if (workspace) {
85
108
  const error_message = await git_check_clean_workspace();
86
109
  if (error_message) {
@@ -1,12 +1,15 @@
1
1
  import {print_spawn_result} from '@fuzdev/fuz_util/process.js';
2
2
  import {z} from 'zod';
3
3
 
4
- import {TaskError, type Task} from './task.ts';
4
+ import {to_implicit_forwarded_args} from './args.ts';
5
+ import {PRETTIER_CLI_DEFAULT} from './constants.ts';
5
6
  import {format_directory} from './format_directory.ts';
6
7
  import {paths} from './paths.ts';
8
+ import {TaskError, type Task} from './task.ts';
7
9
 
8
10
  /** @nodocs */
9
11
  export const Args = z.strictObject({
12
+ _: z.array(z.string()).meta({description: 'files or directories to format'}).optional(),
10
13
  check: z
11
14
  .boolean()
12
15
  .meta({description: 'exit with a nonzero code if any files are unformatted'})
@@ -19,8 +22,8 @@ export const task: Task<Args> = {
19
22
  summary: 'format source files',
20
23
  Args,
21
24
  run: async ({args, log, config}) => {
22
- const {check} = args;
23
- // TODO forward prettier args
25
+ const {_: patterns, check} = args;
26
+
24
27
  const format_result = await format_directory(
25
28
  log,
26
29
  paths.source,
@@ -29,6 +32,8 @@ export const task: Task<Args> = {
29
32
  undefined,
30
33
  undefined,
31
34
  config.pm_cli,
35
+ to_implicit_forwarded_args(PRETTIER_CLI_DEFAULT),
36
+ patterns,
32
37
  );
33
38
  if (!format_result.ok) {
34
39
  throw new TaskError(
@@ -1,8 +1,7 @@
1
- import {args_serialize} from '@fuzdev/fuz_util/args.js';
1
+ import {args_serialize, type Args} from '@fuzdev/fuz_util/args.js';
2
2
  import type {Logger} from '@fuzdev/fuz_util/log.js';
3
3
  import type {SpawnResult} from '@fuzdev/fuz_util/process.js';
4
4
 
5
- import {to_forwarded_args} from './args.ts';
6
5
  import {spawn_cli, to_cli_name, type Cli} from './cli.ts';
7
6
  import {
8
7
  GITHUB_DIRNAME,
@@ -27,8 +26,9 @@ const ROOT_PATHS_DEFAULT = `${[
27
26
  ].join(',')}/**/*`;
28
27
 
29
28
  /**
30
- * Formats a directory on the filesystem.
31
- * If the source directory is given, it also formats all of the root directory files.
29
+ * Formats files on the filesystem.
30
+ * When `patterns` is provided, formats those specific files/patterns.
31
+ * Otherwise formats `dir` with default extensions, plus root files if `dir` is `paths.source`.
32
32
  * This is separated from `./format_file` to avoid importing all of the `prettier` code
33
33
  * inside modules that import this one. (which has a nontrivial cost)
34
34
  */
@@ -40,13 +40,21 @@ export const format_directory = async (
40
40
  root_paths = ROOT_PATHS_DEFAULT,
41
41
  prettier_cli: string | Cli = PRETTIER_CLI_DEFAULT,
42
42
  pm_cli: string = PM_CLI_DEFAULT,
43
+ additional_args?: Args,
44
+ patterns?: Array<string>,
43
45
  ): Promise<SpawnResult> => {
44
- const forwarded_args = to_forwarded_args(to_cli_name(prettier_cli));
45
- forwarded_args[check ? 'check' : 'write'] = true;
46
+ const forwarded_args = {...additional_args};
47
+ if (forwarded_args.check === undefined && forwarded_args.write === undefined) {
48
+ forwarded_args[check ? 'check' : 'write'] = true;
49
+ }
46
50
  const serialized_args = args_serialize(forwarded_args);
47
- serialized_args.push(`${dir}**/*.{${extensions}}`);
48
- if (dir === paths.source) {
49
- serialized_args.push(`${paths.root}{${root_paths}}`);
51
+ if (patterns?.length) {
52
+ serialized_args.push(...patterns);
53
+ } else {
54
+ serialized_args.push(`${dir}**/*.{${extensions}}`);
55
+ if (dir === paths.source) {
56
+ serialized_args.push(`${paths.root}{${root_paths}}`);
57
+ }
50
58
  }
51
59
  const spawned = await spawn_cli(prettier_cli, serialized_args, log);
52
60
  if (!spawned)