@ryanatkn/gro 0.112.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/LICENSE +21 -0
- package/README.md +257 -0
- package/dist/args.d.ts +59 -0
- package/dist/args.js +132 -0
- package/dist/args.test.d.ts +1 -0
- package/dist/args.test.js +43 -0
- package/dist/build.task.d.ts +11 -0
- package/dist/build.task.js +24 -0
- package/dist/changelog.d.ts +8 -0
- package/dist/changelog.js +47 -0
- package/dist/changelog.test.d.ts +1 -0
- package/dist/changelog.test.js +118 -0
- package/dist/changeset.task.d.ts +49 -0
- package/dist/changeset.task.js +141 -0
- package/dist/check.task.d.ts +47 -0
- package/dist/check.task.js +77 -0
- package/dist/clean.task.d.ts +26 -0
- package/dist/clean.task.js +41 -0
- package/dist/clean_fs.d.ts +9 -0
- package/dist/clean_fs.js +27 -0
- package/dist/cli.d.ts +11 -0
- package/dist/cli.js +25 -0
- package/dist/commit.task.d.ts +11 -0
- package/dist/commit.task.js +22 -0
- package/dist/config.d.ts +21 -0
- package/dist/config.js +42 -0
- package/dist/config.test.d.ts +1 -0
- package/dist/config.test.js +8 -0
- package/dist/deploy.task.d.ts +47 -0
- package/dist/deploy.task.js +198 -0
- package/dist/dev.task.d.ts +22 -0
- package/dist/dev.task.js +32 -0
- package/dist/docs/README.gen.md.d.ts +5 -0
- package/dist/docs/README.gen.md.js +53 -0
- package/dist/docs/README.md +20 -0
- package/dist/docs/build.md +41 -0
- package/dist/docs/config.md +162 -0
- package/dist/docs/deploy.md +32 -0
- package/dist/docs/dev.md +40 -0
- package/dist/docs/gen.md +241 -0
- package/dist/docs/gro_plugin_sveltekit_frontend.md +97 -0
- package/dist/docs/package_json.md +29 -0
- package/dist/docs/plugin.md +50 -0
- package/dist/docs/publish.md +144 -0
- package/dist/docs/task.md +377 -0
- package/dist/docs/tasks.gen.md.d.ts +2 -0
- package/dist/docs/tasks.gen.md.js +60 -0
- package/dist/docs/tasks.md +35 -0
- package/dist/docs/test.md +52 -0
- package/dist/env.d.ts +10 -0
- package/dist/env.js +47 -0
- package/dist/esbuild_helpers.d.ts +14 -0
- package/dist/esbuild_helpers.js +36 -0
- package/dist/esbuild_plugin_external_worker.d.ts +22 -0
- package/dist/esbuild_plugin_external_worker.js +49 -0
- package/dist/esbuild_plugin_svelte.d.ts +9 -0
- package/dist/esbuild_plugin_svelte.js +49 -0
- package/dist/esbuild_plugin_sveltekit_local_imports.d.ts +7 -0
- package/dist/esbuild_plugin_sveltekit_local_imports.js +30 -0
- package/dist/esbuild_plugin_sveltekit_shim_alias.d.ts +6 -0
- package/dist/esbuild_plugin_sveltekit_shim_alias.js +16 -0
- package/dist/esbuild_plugin_sveltekit_shim_app.d.ts +8 -0
- package/dist/esbuild_plugin_sveltekit_shim_app.js +23 -0
- package/dist/esbuild_plugin_sveltekit_shim_env.d.ts +10 -0
- package/dist/esbuild_plugin_sveltekit_shim_env.js +18 -0
- package/dist/format.task.d.ts +11 -0
- package/dist/format.task.js +24 -0
- package/dist/format_directory.d.ts +2 -0
- package/dist/format_directory.js +27 -0
- package/dist/format_file.d.ts +8 -0
- package/dist/format_file.js +42 -0
- package/dist/format_file.test.d.ts +1 -0
- package/dist/format_file.test.js +16 -0
- package/dist/fs.d.ts +7 -0
- package/dist/fs.js +19 -0
- package/dist/fs.test.d.ts +1 -0
- package/dist/fs.test.js +16 -0
- package/dist/gen.d.ts +57 -0
- package/dist/gen.js +81 -0
- package/dist/gen.task.d.ts +14 -0
- package/dist/gen.task.js +103 -0
- package/dist/gen.test.d.ts +1 -0
- package/dist/gen.test.js +239 -0
- package/dist/gen_module.d.ts +46 -0
- package/dist/gen_module.js +54 -0
- package/dist/gen_module.test.d.ts +1 -0
- package/dist/gen_module.test.js +30 -0
- package/dist/git.d.ts +76 -0
- package/dist/git.js +200 -0
- package/dist/git.test.d.ts +1 -0
- package/dist/git.test.js +18 -0
- package/dist/github.d.ts +35 -0
- package/dist/github.js +32 -0
- package/dist/gro.config.default.d.ts +12 -0
- package/dist/gro.config.default.js +31 -0
- package/dist/gro.d.ts +2 -0
- package/dist/gro.js +19 -0
- package/dist/gro_helpers.d.ts +43 -0
- package/dist/gro_helpers.js +79 -0
- package/dist/gro_plugin_gen.d.ts +6 -0
- package/dist/gro_plugin_gen.js +80 -0
- package/dist/gro_plugin_server.d.ts +77 -0
- package/dist/gro_plugin_server.js +152 -0
- package/dist/gro_plugin_sveltekit_app.d.ts +27 -0
- package/dist/gro_plugin_sveltekit_app.js +180 -0
- package/dist/gro_plugin_sveltekit_library.d.ts +4 -0
- package/dist/gro_plugin_sveltekit_library.js +42 -0
- package/dist/hash.d.ts +5 -0
- package/dist/hash.js +14 -0
- package/dist/hash.test.d.ts +1 -0
- package/dist/hash.test.js +25 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/dist/input_path.d.ts +48 -0
- package/dist/input_path.js +161 -0
- package/dist/input_path.test.d.ts +1 -0
- package/dist/input_path.test.js +106 -0
- package/dist/invoke.d.ts +1 -0
- package/dist/invoke.js +18 -0
- package/dist/invoke_task.d.ts +20 -0
- package/dist/invoke_task.js +140 -0
- package/dist/lint.task.d.ts +11 -0
- package/dist/lint.task.js +29 -0
- package/dist/loader.d.ts +4 -0
- package/dist/loader.js +153 -0
- package/dist/module.d.ts +3 -0
- package/dist/module.js +6 -0
- package/dist/module.test.d.ts +1 -0
- package/dist/module.test.js +41 -0
- package/dist/modules.d.ts +60 -0
- package/dist/modules.js +103 -0
- package/dist/modules.test.d.ts +1 -0
- package/dist/modules.test.js +182 -0
- package/dist/package.d.ts +939 -0
- package/dist/package.gen.d.ts +7 -0
- package/dist/package.gen.js +26 -0
- package/dist/package.js +887 -0
- package/dist/package_json.d.ts +342 -0
- package/dist/package_json.js +212 -0
- package/dist/package_json.test.d.ts +1 -0
- package/dist/package_json.test.js +77 -0
- package/dist/path.d.ts +12 -0
- package/dist/path.js +8 -0
- package/dist/paths.d.ts +60 -0
- package/dist/paths.js +128 -0
- package/dist/paths.test.d.ts +1 -0
- package/dist/paths.test.js +49 -0
- package/dist/plugin.d.ts +36 -0
- package/dist/plugin.js +80 -0
- package/dist/plugin.test.d.ts +1 -0
- package/dist/plugin.test.js +54 -0
- package/dist/print_task.d.ts +4 -0
- package/dist/print_task.js +124 -0
- package/dist/publish.task.d.ts +32 -0
- package/dist/publish.task.js +125 -0
- package/dist/release.task.d.ts +5 -0
- package/dist/release.task.js +18 -0
- package/dist/resolve_node_specifier.d.ts +8 -0
- package/dist/resolve_node_specifier.js +39 -0
- package/dist/resolve_node_specifier.test.d.ts +1 -0
- package/dist/resolve_node_specifier.test.js +21 -0
- package/dist/resolve_specifier.d.ts +15 -0
- package/dist/resolve_specifier.js +51 -0
- package/dist/resolve_specifier.test.d.ts +1 -0
- package/dist/resolve_specifier.test.js +66 -0
- package/dist/run.task.d.ts +11 -0
- package/dist/run.task.js +31 -0
- package/dist/run_gen.d.ts +6 -0
- package/dist/run_gen.js +74 -0
- package/dist/run_gen.test.d.ts +1 -0
- package/dist/run_gen.test.js +182 -0
- package/dist/run_task.d.ts +13 -0
- package/dist/run_task.js +44 -0
- package/dist/run_task.test.d.ts +1 -0
- package/dist/run_task.test.js +63 -0
- package/dist/search_fs.d.ts +11 -0
- package/dist/search_fs.js +22 -0
- package/dist/search_fs.test.d.ts +1 -0
- package/dist/search_fs.test.js +46 -0
- package/dist/src_json.d.ts +256 -0
- package/dist/src_json.js +110 -0
- package/dist/src_json.test.d.ts +1 -0
- package/dist/src_json.test.js +52 -0
- package/dist/sveltekit_config.d.ts +36 -0
- package/dist/sveltekit_config.js +51 -0
- package/dist/sveltekit_shim_app.d.ts +10 -0
- package/dist/sveltekit_shim_app.js +31 -0
- package/dist/sveltekit_shim_app_environment.d.ts +10 -0
- package/dist/sveltekit_shim_app_environment.js +12 -0
- package/dist/sveltekit_shim_app_forms.d.ts +5 -0
- package/dist/sveltekit_shim_app_forms.js +13 -0
- package/dist/sveltekit_shim_app_navigation.d.ts +10 -0
- package/dist/sveltekit_shim_app_navigation.js +11 -0
- package/dist/sveltekit_shim_app_paths.d.ts +11 -0
- package/dist/sveltekit_shim_app_paths.js +6 -0
- package/dist/sveltekit_shim_app_stores.d.ts +6 -0
- package/dist/sveltekit_shim_app_stores.js +17 -0
- package/dist/sveltekit_shim_env.d.ts +4 -0
- package/dist/sveltekit_shim_env.js +23 -0
- package/dist/sync.task.d.ts +30 -0
- package/dist/sync.task.js +45 -0
- package/dist/task.d.ts +29 -0
- package/dist/task.js +17 -0
- package/dist/task.test.d.ts +1 -0
- package/dist/task.test.js +22 -0
- package/dist/task_module.d.ts +14 -0
- package/dist/task_module.js +19 -0
- package/dist/task_module.test.d.ts +1 -0
- package/dist/task_module.test.js +70 -0
- package/dist/test.task.d.ts +20 -0
- package/dist/test.task.js +43 -0
- package/dist/throttle.d.ts +16 -0
- package/dist/throttle.js +59 -0
- package/dist/throttle.test.d.ts +1 -0
- package/dist/throttle.test.js +49 -0
- package/dist/typecheck.task.d.ts +5 -0
- package/dist/typecheck.task.js +38 -0
- package/dist/upgrade.task.d.ts +14 -0
- package/dist/upgrade.task.js +37 -0
- package/dist/watch_dir.d.ts +30 -0
- package/dist/watch_dir.js +59 -0
- package/package.json +422 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { test } from 'uvu';
|
|
2
|
+
import * as assert from 'uvu/assert';
|
|
3
|
+
import { Logger } from '@ryanatkn/belt/log.js';
|
|
4
|
+
import { readFile, writeFile } from 'fs/promises';
|
|
5
|
+
import { update_changelog } from './changelog.js';
|
|
6
|
+
import { load_from_env } from './env.js';
|
|
7
|
+
const log = new Logger();
|
|
8
|
+
const token = await load_from_env('GITHUB_TOKEN_SECRET');
|
|
9
|
+
if (!token) {
|
|
10
|
+
log.warn('the env var GITHUB_TOKEN_SECRET was not found, so API calls with be unauthorized');
|
|
11
|
+
}
|
|
12
|
+
const fixture_path = 'src/fixtures/changelog_example.md';
|
|
13
|
+
// TODO ideally this is just a ts file, but there's a problem where building outputs a `.d.ts` file
|
|
14
|
+
// when importing from src/fixtures (fix in SvelteKit/Vite/tsconfig?) and I want to keep it in src/fixtures
|
|
15
|
+
const changelog_cache_fixture = new Map(JSON.parse(await readFile('src/fixtures/changelog_cache.json', 'utf8')));
|
|
16
|
+
test('update_changelog', async () => {
|
|
17
|
+
const original = await readFile(fixture_path, 'utf8');
|
|
18
|
+
const result = await update_changelog('ryanatkn', 'gro', fixture_path, token, log, changelog_cache_fixture);
|
|
19
|
+
const updated = await readFile(fixture_path, 'utf8');
|
|
20
|
+
await writeFile(fixture_path, original, 'utf8');
|
|
21
|
+
assert.ok(result);
|
|
22
|
+
assert.is(updated, `# @ryanatkn/gro
|
|
23
|
+
|
|
24
|
+
## 0.6.0
|
|
25
|
+
|
|
26
|
+
### Minor Changes
|
|
27
|
+
|
|
28
|
+
- duplicate 1 ([#429](https://github.com/ryanatkn/gro/pull/429))
|
|
29
|
+
- duplicate 2 ([#429](https://github.com/ryanatkn/gro/pull/429))
|
|
30
|
+
- abc ([#437](https://github.com/ryanatkn/gro/pull/437))
|
|
31
|
+
|
|
32
|
+
- 123
|
|
33
|
+
- 123
|
|
34
|
+
- 123
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- abc ([5e94cd4](https://github.com/ryanatkn/gro/commit/5e94cd4))
|
|
39
|
+
|
|
40
|
+
## 0.5.2
|
|
41
|
+
|
|
42
|
+
### Patch Changes
|
|
43
|
+
|
|
44
|
+
- abc ([e345eaa](https://github.com/ryanatkn/gro/commit/e345eaa))
|
|
45
|
+
|
|
46
|
+
## 0.5.1
|
|
47
|
+
|
|
48
|
+
### Patch Changes
|
|
49
|
+
|
|
50
|
+
- abc ([094279d](https://github.com/ryanatkn/gro/commit/094279d))
|
|
51
|
+
|
|
52
|
+
## 0.5.0
|
|
53
|
+
|
|
54
|
+
### Minor Changes
|
|
55
|
+
|
|
56
|
+
- abc ([f6133f7](https://github.com/ryanatkn/gro/commit/f6133f7))
|
|
57
|
+
|
|
58
|
+
## 0.4.3
|
|
59
|
+
|
|
60
|
+
### Patch Changes
|
|
61
|
+
|
|
62
|
+
- abc ([54b65ec](https://github.com/ryanatkn/gro/commit/54b65ec))
|
|
63
|
+
|
|
64
|
+
## 0.4.2
|
|
65
|
+
|
|
66
|
+
### Patch Changes
|
|
67
|
+
|
|
68
|
+
- abc ([80365d0](https://github.com/ryanatkn/gro/commit/80365d0))
|
|
69
|
+
|
|
70
|
+
## 0.4.1
|
|
71
|
+
|
|
72
|
+
### Patch Changes
|
|
73
|
+
|
|
74
|
+
- abc ([3d84dfd](https://github.com/ryanatkn/gro/commit/3d84dfd))
|
|
75
|
+
- abc ([fc64b77](https://github.com/ryanatkn/gro/commit/fc64b77))
|
|
76
|
+
|
|
77
|
+
## 0.4.0
|
|
78
|
+
|
|
79
|
+
### Minor Changes
|
|
80
|
+
|
|
81
|
+
- abc ([#434](https://github.com/ryanatkn/gro/pull/434))
|
|
82
|
+
- 123
|
|
83
|
+
- 123
|
|
84
|
+
|
|
85
|
+
### Patch Changes
|
|
86
|
+
|
|
87
|
+
- abc ([#434](https://github.com/ryanatkn/gro/pull/434))
|
|
88
|
+
|
|
89
|
+
## 0.3.1
|
|
90
|
+
|
|
91
|
+
- e
|
|
92
|
+
|
|
93
|
+
## 0.3.0
|
|
94
|
+
|
|
95
|
+
- b2
|
|
96
|
+
- c2
|
|
97
|
+
- d2
|
|
98
|
+
|
|
99
|
+
## 0.2.0
|
|
100
|
+
|
|
101
|
+
- a2
|
|
102
|
+
|
|
103
|
+
## 0.1.2
|
|
104
|
+
|
|
105
|
+
- e
|
|
106
|
+
|
|
107
|
+
## 0.1.1
|
|
108
|
+
|
|
109
|
+
- b
|
|
110
|
+
- c
|
|
111
|
+
- d
|
|
112
|
+
|
|
113
|
+
## 0.1.0
|
|
114
|
+
|
|
115
|
+
- a
|
|
116
|
+
`);
|
|
117
|
+
});
|
|
118
|
+
test.run();
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type Task } from './task.js';
|
|
3
|
+
export declare const Changeset_Bump: z.ZodEnum<["patch", "minor", "major"]>;
|
|
4
|
+
export type Changeset_Bump = z.infer<typeof Changeset_Bump>;
|
|
5
|
+
export declare const Args: z.ZodObject<{
|
|
6
|
+
/**
|
|
7
|
+
* The optional rest args get joined with a space to form the `message`.
|
|
8
|
+
*/
|
|
9
|
+
_: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
10
|
+
minor: z.ZodDefault<z.ZodBoolean>;
|
|
11
|
+
major: z.ZodDefault<z.ZodBoolean>;
|
|
12
|
+
dir: z.ZodDefault<z.ZodString>;
|
|
13
|
+
access: z.ZodOptional<z.ZodEnum<["restricted", "public"]>>;
|
|
14
|
+
changelog: z.ZodDefault<z.ZodString>;
|
|
15
|
+
install: z.ZodDefault<z.ZodBoolean>;
|
|
16
|
+
'no-install': z.ZodDefault<z.ZodBoolean>;
|
|
17
|
+
origin: z.ZodDefault<z.ZodString>;
|
|
18
|
+
}, "strict", z.ZodTypeAny, {
|
|
19
|
+
_: string[];
|
|
20
|
+
dir: string;
|
|
21
|
+
install: boolean;
|
|
22
|
+
origin: string;
|
|
23
|
+
minor: boolean;
|
|
24
|
+
major: boolean;
|
|
25
|
+
changelog: string;
|
|
26
|
+
'no-install': boolean;
|
|
27
|
+
access?: "public" | "restricted" | undefined;
|
|
28
|
+
}, {
|
|
29
|
+
_?: string[] | undefined;
|
|
30
|
+
minor?: boolean | undefined;
|
|
31
|
+
major?: boolean | undefined;
|
|
32
|
+
dir?: string | undefined;
|
|
33
|
+
access?: "public" | "restricted" | undefined;
|
|
34
|
+
changelog?: string | undefined;
|
|
35
|
+
install?: boolean | undefined;
|
|
36
|
+
'no-install'?: boolean | undefined;
|
|
37
|
+
origin?: string | undefined;
|
|
38
|
+
}>;
|
|
39
|
+
export type Args = z.infer<typeof Args>;
|
|
40
|
+
/**
|
|
41
|
+
* Calls the `changeset` CLI with some simple automations.
|
|
42
|
+
* This API is designed for convenient manual usage, not clarity or normality.
|
|
43
|
+
*
|
|
44
|
+
* Usage:
|
|
45
|
+
* - gro changeset some commit message
|
|
46
|
+
* - gro changeset some commit message --minor
|
|
47
|
+
* - gro changeset "some commit message" --minor
|
|
48
|
+
*/
|
|
49
|
+
export declare const task: Task<Args>;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { spawn } from '@ryanatkn/belt/process.js';
|
|
3
|
+
import { red, blue } from 'kleur/colors';
|
|
4
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import { readdir } from 'node:fs/promises';
|
|
7
|
+
import { Task_Error } from './task.js';
|
|
8
|
+
import { exists } from './fs.js';
|
|
9
|
+
import { load_package_json } from './package_json.js';
|
|
10
|
+
import { find_cli, spawn_cli } from './cli.js';
|
|
11
|
+
import { Git_Origin, git_push_to_create } from './git.js';
|
|
12
|
+
const RESTRICTED_ACCESS = 'restricted';
|
|
13
|
+
const PUBLIC_ACCESS = 'public';
|
|
14
|
+
const CHANGESET_DIR = '.changeset';
|
|
15
|
+
export const Changeset_Bump = z.enum(['patch', 'minor', 'major']);
|
|
16
|
+
export const Args = z
|
|
17
|
+
.object({
|
|
18
|
+
/**
|
|
19
|
+
* The optional rest args get joined with a space to form the `message`.
|
|
20
|
+
*/
|
|
21
|
+
_: z.array(z.string(), { description: 'the message for the changeset and commit' }).default([]),
|
|
22
|
+
minor: z.boolean({ description: 'bump the minor version' }).default(false),
|
|
23
|
+
major: z.boolean({ description: 'bump the major version' }).default(false),
|
|
24
|
+
dir: z.string({ description: 'changeset dir' }).default(CHANGESET_DIR),
|
|
25
|
+
access: z
|
|
26
|
+
.enum([RESTRICTED_ACCESS, PUBLIC_ACCESS], {
|
|
27
|
+
description: `changeset 'access' config value, the default depends on package.json#private`,
|
|
28
|
+
})
|
|
29
|
+
.optional(),
|
|
30
|
+
changelog: z
|
|
31
|
+
.string({ description: 'changeset "changelog" config value' })
|
|
32
|
+
.default('@changesets/changelog-git'),
|
|
33
|
+
install: z.boolean({ description: 'dual of no-install' }).default(true),
|
|
34
|
+
'no-install': z
|
|
35
|
+
.boolean({ description: 'opt out of npm installing the changelog package' })
|
|
36
|
+
.default(false),
|
|
37
|
+
origin: Git_Origin.describe('git origin to deploy to').default('origin'),
|
|
38
|
+
})
|
|
39
|
+
.strict();
|
|
40
|
+
/**
|
|
41
|
+
* Calls the `changeset` CLI with some simple automations.
|
|
42
|
+
* This API is designed for convenient manual usage, not clarity or normality.
|
|
43
|
+
*
|
|
44
|
+
* Usage:
|
|
45
|
+
* - gro changeset some commit message
|
|
46
|
+
* - gro changeset some commit message --minor
|
|
47
|
+
* - gro changeset "some commit message" --minor
|
|
48
|
+
*/
|
|
49
|
+
export const task = {
|
|
50
|
+
summary: 'call changeset with gro patterns',
|
|
51
|
+
Args,
|
|
52
|
+
run: async (ctx) => {
|
|
53
|
+
const { invoke_task, args: { _, minor, major, dir, access: access_arg, changelog, install, origin }, log, } = ctx;
|
|
54
|
+
const message = _.join(' ');
|
|
55
|
+
if (!message && (minor || major))
|
|
56
|
+
throw new Task_Error('cannot bump version without a message');
|
|
57
|
+
if (minor && major)
|
|
58
|
+
throw new Task_Error('cannot bump both minor and major');
|
|
59
|
+
const bump = minor ? 'minor' : major ? 'major' : 'patch';
|
|
60
|
+
if (!(await find_cli('changeset'))) {
|
|
61
|
+
throw new Task_Error('changeset command not found: install @changesets/cli locally or globally');
|
|
62
|
+
}
|
|
63
|
+
const path = join(dir, 'config.json');
|
|
64
|
+
const inited = await exists(path);
|
|
65
|
+
const package_json = await load_package_json();
|
|
66
|
+
if (!inited) {
|
|
67
|
+
await spawn_cli('changeset', ['init']);
|
|
68
|
+
const access = access_arg ?? package_json.private ? RESTRICTED_ACCESS : PUBLIC_ACCESS;
|
|
69
|
+
const access_color = access === RESTRICTED_ACCESS ? blue : red;
|
|
70
|
+
log.info('initing changeset with ' + access_color(access) + ' access');
|
|
71
|
+
if (access !== RESTRICTED_ACCESS) {
|
|
72
|
+
await update_changeset_config(path, (config) => {
|
|
73
|
+
const updated = { ...config };
|
|
74
|
+
updated.access = access;
|
|
75
|
+
updated.changelog = changelog;
|
|
76
|
+
return updated;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
await spawn('git', ['add', dir]);
|
|
80
|
+
if (install) {
|
|
81
|
+
await spawn('npm', ['i', '-D', changelog]);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
await invoke_task('sync'); // after the `npm i` above, and in all cases
|
|
85
|
+
if (message) {
|
|
86
|
+
// TODO see the helper below, simplify this to CLI flags when support is added to Changesets
|
|
87
|
+
const changeset_adder = await create_changeset_adder(package_json.name, dir, message, bump);
|
|
88
|
+
await spawn_cli('changeset', ['add', '--empty']);
|
|
89
|
+
await changeset_adder();
|
|
90
|
+
await spawn('git', ['commit', '-m', message]);
|
|
91
|
+
await git_push_to_create(origin);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
await spawn_cli('changeset');
|
|
95
|
+
await spawn('git', ['add', dir]);
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* TODO ideally this wouldn't exist and we'd use CLI flags, but they doesn't exist yet
|
|
101
|
+
* @see https://github.com/changesets/changesets/pull/1121
|
|
102
|
+
*/
|
|
103
|
+
const create_changeset_adder = async (repo_name, dir, message, bump) => {
|
|
104
|
+
const filenames_before = await readdir(dir);
|
|
105
|
+
return async () => {
|
|
106
|
+
const filenames_after = await readdir(dir);
|
|
107
|
+
const filenames_added = filenames_after.filter((p) => !filenames_before.includes(p));
|
|
108
|
+
if (!filenames_added.length) {
|
|
109
|
+
throw Error('expected to find a new changeset file');
|
|
110
|
+
}
|
|
111
|
+
if (filenames_added.length !== 1) {
|
|
112
|
+
throw Error('expected to find exactly one new changeset file');
|
|
113
|
+
}
|
|
114
|
+
const path = join(dir, filenames_added[0]);
|
|
115
|
+
const contents = create_new_changeset(repo_name, message, bump);
|
|
116
|
+
await writeFile(path, contents, 'utf8');
|
|
117
|
+
await spawn('git', ['add', path]);
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
const create_new_changeset = (repo_name, message, bump) => `---
|
|
121
|
+
"${repo_name}": ${bump}
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
${message}
|
|
125
|
+
`;
|
|
126
|
+
// TODO refactor all of this with zod and package_json helpers - util file helper? JSON parse pluggable
|
|
127
|
+
const update_changeset_config = async (path, cb) => {
|
|
128
|
+
const config_contents = await load_changeset_config_contents(path);
|
|
129
|
+
const config = parse_changeset_config(config_contents);
|
|
130
|
+
const updated = await cb(config);
|
|
131
|
+
const serialized = serialize_changeset_config(updated);
|
|
132
|
+
if (serialized === config_contents) {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
await write_changeset_config(path, serialized);
|
|
136
|
+
return true;
|
|
137
|
+
};
|
|
138
|
+
const load_changeset_config_contents = (path) => readFile(path, 'utf8');
|
|
139
|
+
const write_changeset_config = (path, serialized) => writeFile(path, serialized);
|
|
140
|
+
const serialize_changeset_config = (config) => JSON.stringify(config, null, '\t') + '\n';
|
|
141
|
+
const parse_changeset_config = (contents) => JSON.parse(contents);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type Task } from './task.js';
|
|
3
|
+
export declare const Args: z.ZodObject<{
|
|
4
|
+
typecheck: z.ZodDefault<z.ZodBoolean>;
|
|
5
|
+
'no-typecheck': z.ZodDefault<z.ZodBoolean>;
|
|
6
|
+
test: z.ZodDefault<z.ZodBoolean>;
|
|
7
|
+
'no-test': z.ZodDefault<z.ZodBoolean>;
|
|
8
|
+
gen: z.ZodDefault<z.ZodBoolean>;
|
|
9
|
+
'no-gen': z.ZodDefault<z.ZodBoolean>;
|
|
10
|
+
format: z.ZodDefault<z.ZodBoolean>;
|
|
11
|
+
'no-format': z.ZodDefault<z.ZodBoolean>;
|
|
12
|
+
package_json: z.ZodDefault<z.ZodBoolean>;
|
|
13
|
+
'no-package_json': z.ZodDefault<z.ZodBoolean>;
|
|
14
|
+
lint: z.ZodDefault<z.ZodBoolean>;
|
|
15
|
+
'no-lint': z.ZodDefault<z.ZodBoolean>;
|
|
16
|
+
workspace: z.ZodDefault<z.ZodBoolean>;
|
|
17
|
+
}, "strict", z.ZodTypeAny, {
|
|
18
|
+
package_json: boolean;
|
|
19
|
+
format: boolean;
|
|
20
|
+
typecheck: boolean;
|
|
21
|
+
'no-typecheck': boolean;
|
|
22
|
+
test: boolean;
|
|
23
|
+
'no-test': boolean;
|
|
24
|
+
gen: boolean;
|
|
25
|
+
'no-gen': boolean;
|
|
26
|
+
'no-format': boolean;
|
|
27
|
+
'no-package_json': boolean;
|
|
28
|
+
lint: boolean;
|
|
29
|
+
'no-lint': boolean;
|
|
30
|
+
workspace: boolean;
|
|
31
|
+
}, {
|
|
32
|
+
typecheck?: boolean | undefined;
|
|
33
|
+
'no-typecheck'?: boolean | undefined;
|
|
34
|
+
test?: boolean | undefined;
|
|
35
|
+
'no-test'?: boolean | undefined;
|
|
36
|
+
gen?: boolean | undefined;
|
|
37
|
+
'no-gen'?: boolean | undefined;
|
|
38
|
+
format?: boolean | undefined;
|
|
39
|
+
'no-format'?: boolean | undefined;
|
|
40
|
+
package_json?: boolean | undefined;
|
|
41
|
+
'no-package_json'?: boolean | undefined;
|
|
42
|
+
lint?: boolean | undefined;
|
|
43
|
+
'no-lint'?: boolean | undefined;
|
|
44
|
+
workspace?: boolean | undefined;
|
|
45
|
+
}>;
|
|
46
|
+
export type Args = z.infer<typeof Args>;
|
|
47
|
+
export declare const task: Task<Args>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { spawn } from '@ryanatkn/belt/process.js';
|
|
3
|
+
import { red } from 'kleur/colors';
|
|
4
|
+
import { Task_Error } from './task.js';
|
|
5
|
+
import { git_check_clean_workspace } from './git.js';
|
|
6
|
+
import { sync_package_json } from './package_json.js';
|
|
7
|
+
export const Args = z
|
|
8
|
+
.object({
|
|
9
|
+
typecheck: z.boolean({ description: 'dual of no-typecheck' }).default(true),
|
|
10
|
+
'no-typecheck': z.boolean({ description: 'opt out of typechecking' }).default(false),
|
|
11
|
+
test: z.boolean({ description: 'dual of no-test' }).default(true),
|
|
12
|
+
'no-test': z.boolean({ description: 'opt out of running tests' }).default(false),
|
|
13
|
+
gen: z.boolean({ description: 'dual of no-gen' }).default(true),
|
|
14
|
+
'no-gen': z.boolean({ description: 'opt out of gen check' }).default(false),
|
|
15
|
+
format: z.boolean({ description: 'dual of no-format' }).default(true),
|
|
16
|
+
'no-format': z.boolean({ description: 'opt out of format check' }).default(false),
|
|
17
|
+
package_json: z.boolean({ description: 'dual of no-package_json' }).default(true),
|
|
18
|
+
'no-package_json': z.boolean({ description: 'opt out of package.json check' }).default(false),
|
|
19
|
+
lint: z.boolean({ description: 'dual of no-lint' }).default(true),
|
|
20
|
+
'no-lint': z.boolean({ description: 'opt out of linting' }).default(false),
|
|
21
|
+
workspace: z
|
|
22
|
+
.boolean({ description: 'ensure a clean git workspace, useful for CI' })
|
|
23
|
+
.default(false),
|
|
24
|
+
})
|
|
25
|
+
.strict();
|
|
26
|
+
export const task = {
|
|
27
|
+
summary: 'check that everything is ready to commit',
|
|
28
|
+
Args,
|
|
29
|
+
run: async ({ args, invoke_task, log, config }) => {
|
|
30
|
+
const { typecheck, test, gen, format, package_json, lint, workspace } = args;
|
|
31
|
+
// When checking the workspace, which was added for CI,
|
|
32
|
+
// don't sync, because the check will fail with misleading errors.
|
|
33
|
+
// For example it would cause the gen check to be a false negative,
|
|
34
|
+
// and then the workspace check would fail with the new files.
|
|
35
|
+
const sync = !workspace;
|
|
36
|
+
if (sync) {
|
|
37
|
+
await invoke_task('sync');
|
|
38
|
+
}
|
|
39
|
+
if (typecheck) {
|
|
40
|
+
await invoke_task('typecheck');
|
|
41
|
+
}
|
|
42
|
+
if (test) {
|
|
43
|
+
await invoke_task('test');
|
|
44
|
+
}
|
|
45
|
+
if (gen) {
|
|
46
|
+
await invoke_task('gen', { check: true });
|
|
47
|
+
}
|
|
48
|
+
if (package_json && config.map_package_json) {
|
|
49
|
+
const { changed } = await sync_package_json(config.map_package_json, log, true);
|
|
50
|
+
if (changed) {
|
|
51
|
+
throw new Task_Error('package.json is out of date, run `gro sync` to update it');
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
log.info('check passed for package.json');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (format) {
|
|
58
|
+
await invoke_task('format', { check: true });
|
|
59
|
+
}
|
|
60
|
+
// Run the linter last to surface every other kind of problem first.
|
|
61
|
+
// It's not the ideal order when the linter would catch errors that cause failing tests,
|
|
62
|
+
// but it's better for most usage.
|
|
63
|
+
if (lint) {
|
|
64
|
+
await invoke_task('lint');
|
|
65
|
+
}
|
|
66
|
+
if (workspace) {
|
|
67
|
+
const error_message = await git_check_clean_workspace();
|
|
68
|
+
if (error_message) {
|
|
69
|
+
log.error(red('git status'));
|
|
70
|
+
await spawn('git', ['status']);
|
|
71
|
+
throw new Task_Error('failed check for git_check_clean_workspace:' +
|
|
72
|
+
error_message +
|
|
73
|
+
' - do you need to run `gro sync` or commit some files?');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Task } from './task.js';
|
|
3
|
+
export declare const Args: z.ZodObject<{
|
|
4
|
+
build_dev: z.ZodDefault<z.ZodBoolean>;
|
|
5
|
+
build_dist: z.ZodDefault<z.ZodBoolean>;
|
|
6
|
+
sveltekit: z.ZodDefault<z.ZodBoolean>;
|
|
7
|
+
nodemodules: z.ZodDefault<z.ZodBoolean>;
|
|
8
|
+
git: z.ZodDefault<z.ZodBoolean>;
|
|
9
|
+
git_origin: z.ZodDefault<z.ZodString>;
|
|
10
|
+
}, "strict", z.ZodTypeAny, {
|
|
11
|
+
build_dev: boolean;
|
|
12
|
+
build_dist: boolean;
|
|
13
|
+
sveltekit: boolean;
|
|
14
|
+
nodemodules: boolean;
|
|
15
|
+
git: boolean;
|
|
16
|
+
git_origin: string;
|
|
17
|
+
}, {
|
|
18
|
+
build_dev?: boolean | undefined;
|
|
19
|
+
build_dist?: boolean | undefined;
|
|
20
|
+
sveltekit?: boolean | undefined;
|
|
21
|
+
nodemodules?: boolean | undefined;
|
|
22
|
+
git?: boolean | undefined;
|
|
23
|
+
git_origin?: string | undefined;
|
|
24
|
+
}>;
|
|
25
|
+
export type Args = z.infer<typeof Args>;
|
|
26
|
+
export declare const task: Task<Args>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { spawn } from '@ryanatkn/belt/process.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { clean_fs } from './clean_fs.js';
|
|
4
|
+
export const Args = z
|
|
5
|
+
.object({
|
|
6
|
+
build_dev: z.boolean({ description: 'delete the Gro build dev directory' }).default(false),
|
|
7
|
+
build_dist: z.boolean({ description: 'delete the Gro build dist directory' }).default(false),
|
|
8
|
+
sveltekit: z
|
|
9
|
+
.boolean({ description: 'delete the SvelteKit directory and Vite cache' })
|
|
10
|
+
.default(false),
|
|
11
|
+
nodemodules: z.boolean({ description: 'delete the node_modules directory' }).default(false),
|
|
12
|
+
git: z
|
|
13
|
+
.boolean({
|
|
14
|
+
description: 'run "git remote prune" to delete local branches referencing nonexistent remote branches',
|
|
15
|
+
})
|
|
16
|
+
.default(false),
|
|
17
|
+
git_origin: z
|
|
18
|
+
.string({
|
|
19
|
+
description: 'the origin to "git remote prune"',
|
|
20
|
+
})
|
|
21
|
+
.default('origin'),
|
|
22
|
+
})
|
|
23
|
+
.strict();
|
|
24
|
+
export const task = {
|
|
25
|
+
summary: 'remove temporary dev and build files, and optionally prune git branches',
|
|
26
|
+
Args,
|
|
27
|
+
run: async ({ args }) => {
|
|
28
|
+
const { build_dev, build_dist, sveltekit, nodemodules, git, git_origin } = args;
|
|
29
|
+
await clean_fs({
|
|
30
|
+
build: !build_dev && !build_dist,
|
|
31
|
+
build_dev,
|
|
32
|
+
build_dist,
|
|
33
|
+
sveltekit,
|
|
34
|
+
nodemodules,
|
|
35
|
+
});
|
|
36
|
+
// lop off stale git branches
|
|
37
|
+
if (git) {
|
|
38
|
+
await spawn('git', ['remote', 'prune', git_origin]);
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { RmOptions } from 'node:fs';
|
|
3
|
+
export declare const clean_fs: ({ build, build_dev, build_dist, sveltekit, nodemodules, }: {
|
|
4
|
+
build?: boolean | undefined;
|
|
5
|
+
build_dev?: boolean | undefined;
|
|
6
|
+
build_dist?: boolean | undefined;
|
|
7
|
+
sveltekit?: boolean | undefined;
|
|
8
|
+
nodemodules?: boolean | undefined;
|
|
9
|
+
}, rm_options?: RmOptions) => Promise<void>;
|
package/dist/clean_fs.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { rm, readdir } from 'node:fs/promises';
|
|
2
|
+
import { NODE_MODULES_DIRNAME, paths, SVELTEKIT_DEV_DIRNAME, SVELTEKIT_BUILD_DIRNAME, SVELTEKIT_VITE_CACHE_PATH, GRO_DIST_PREFIX, SVELTEKIT_DIST_DIRNAME, } from './paths.js';
|
|
3
|
+
export const clean_fs = async ({ build = false, build_dev = false, build_dist = false, sveltekit = false, nodemodules = false, }, rm_options = { force: true, recursive: true }) => {
|
|
4
|
+
const promises = [];
|
|
5
|
+
if (build) {
|
|
6
|
+
promises.push(rm(paths.build, rm_options));
|
|
7
|
+
}
|
|
8
|
+
else if (build_dev) {
|
|
9
|
+
promises.push(rm(paths.build_dev, rm_options));
|
|
10
|
+
}
|
|
11
|
+
if (build || build_dist) {
|
|
12
|
+
const paths = (await readdir('.')).filter((p) => p.startsWith(GRO_DIST_PREFIX));
|
|
13
|
+
for (const path of paths) {
|
|
14
|
+
promises.push(rm(path, rm_options));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
if (sveltekit) {
|
|
18
|
+
promises.push(rm(SVELTEKIT_DEV_DIRNAME, rm_options));
|
|
19
|
+
promises.push(rm(SVELTEKIT_BUILD_DIRNAME, rm_options));
|
|
20
|
+
promises.push(rm(SVELTEKIT_DIST_DIRNAME, rm_options));
|
|
21
|
+
promises.push(rm(SVELTEKIT_VITE_CACHE_PATH, rm_options));
|
|
22
|
+
}
|
|
23
|
+
if (nodemodules) {
|
|
24
|
+
promises.push(rm(NODE_MODULES_DIRNAME, rm_options));
|
|
25
|
+
}
|
|
26
|
+
await Promise.all(promises);
|
|
27
|
+
};
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { SpawnOptions } from 'node:child_process';
|
|
3
|
+
import { type Spawn_Result } from '@ryanatkn/belt/process.js';
|
|
4
|
+
/**
|
|
5
|
+
* Looks for the CLI `name`, first local to the cwd and then globally.
|
|
6
|
+
*/
|
|
7
|
+
export declare const find_cli: (name: string) => Promise<'local' | 'global' | null>;
|
|
8
|
+
/**
|
|
9
|
+
* Calls the CLI `name` if available, first local to the cwd and then globally.
|
|
10
|
+
*/
|
|
11
|
+
export declare const spawn_cli: (name: string, args?: any[], options?: SpawnOptions | undefined) => Promise<Spawn_Result | undefined>;
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { spawn, spawn_out } from '@ryanatkn/belt/process.js';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { exists } from './fs.js';
|
|
4
|
+
import { NODE_MODULES_DIRNAME } from './paths.js';
|
|
5
|
+
/**
|
|
6
|
+
* Looks for the CLI `name`, first local to the cwd and then globally.
|
|
7
|
+
*/
|
|
8
|
+
export const find_cli = async (name) => {
|
|
9
|
+
if (await exists(join(NODE_MODULES_DIRNAME, `.bin/${name}`))) {
|
|
10
|
+
return 'local';
|
|
11
|
+
}
|
|
12
|
+
const { stdout } = await spawn_out('which', [name]);
|
|
13
|
+
return stdout === null ? null : 'global';
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Calls the CLI `name` if available, first local to the cwd and then globally.
|
|
17
|
+
*/
|
|
18
|
+
export const spawn_cli = async (name, args = [], options) => {
|
|
19
|
+
const found = await find_cli(name);
|
|
20
|
+
if (!found)
|
|
21
|
+
return;
|
|
22
|
+
const command = found === 'local' ? 'npx' : name;
|
|
23
|
+
const final_args = found === 'local' ? [name].concat(args) : args;
|
|
24
|
+
return spawn(command, final_args, options);
|
|
25
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Task } from './task.js';
|
|
3
|
+
export declare const Args: z.ZodObject<{
|
|
4
|
+
_: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
5
|
+
}, "strict", z.ZodTypeAny, {
|
|
6
|
+
_: string[];
|
|
7
|
+
}, {
|
|
8
|
+
_?: string[] | undefined;
|
|
9
|
+
}>;
|
|
10
|
+
export type Args = z.infer<typeof Args>;
|
|
11
|
+
export declare const task: Task<Args>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { spawn } from '@ryanatkn/belt/process.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { git_current_branch_name } from './git.js';
|
|
4
|
+
export const Args = z
|
|
5
|
+
.object({
|
|
6
|
+
_: z
|
|
7
|
+
.array(z.string(), {
|
|
8
|
+
description: 'the git commit message, the same as git commit -m or --message',
|
|
9
|
+
})
|
|
10
|
+
.default([]),
|
|
11
|
+
})
|
|
12
|
+
.strict();
|
|
13
|
+
export const task = {
|
|
14
|
+
summary: 'commit and push to a new branch',
|
|
15
|
+
Args,
|
|
16
|
+
run: async ({ args }) => {
|
|
17
|
+
const { _: [message], } = args;
|
|
18
|
+
const branch = await git_current_branch_name();
|
|
19
|
+
await spawn('git', ['commit', '-a', '-m', message]);
|
|
20
|
+
await spawn(`git push -u origin ${branch}`, [], { shell: true });
|
|
21
|
+
},
|
|
22
|
+
};
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Create_Config_Plugins } from './plugin.js';
|
|
2
|
+
import type { Map_Package_Json } from './package_json.js';
|
|
3
|
+
export interface Gro_Config {
|
|
4
|
+
plugins: Create_Config_Plugins;
|
|
5
|
+
/**
|
|
6
|
+
* Maps the project's `package.json` before writing it to the filesystem.
|
|
7
|
+
* The `package_json` argument may be mutated, but the return value is what's used by the caller.
|
|
8
|
+
* Returning `null` is a no-op for the caller.
|
|
9
|
+
*/
|
|
10
|
+
map_package_json: Map_Package_Json | null;
|
|
11
|
+
}
|
|
12
|
+
export interface Create_Gro_Config {
|
|
13
|
+
(base_config: Gro_Config): Gro_Config | Promise<Gro_Config>;
|
|
14
|
+
}
|
|
15
|
+
export declare const create_empty_config: () => Gro_Config;
|
|
16
|
+
export declare const DEFAULT_EXPORTS_EXCLUDER: RegExp;
|
|
17
|
+
export interface Gro_Config_Module {
|
|
18
|
+
readonly default: Gro_Config | Create_Gro_Config;
|
|
19
|
+
}
|
|
20
|
+
export declare const load_config: (dir?: string) => Promise<Gro_Config>;
|
|
21
|
+
export declare const validate_config_module: (config_module: any, config_path: string) => asserts config_module is Gro_Config_Module;
|