@textmode/release 0.2.0 → 0.3.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 -121
- package/README.md +13 -34
- package/dist/cli/textmode-release.d.ts +3 -0
- package/dist/cli/textmode-release.d.ts.map +1 -0
- package/dist/cli/textmode-release.js +150 -0
- package/dist/cli/textmode-release.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/engines.d.ts +5 -0
- package/dist/internal/engines.d.ts.map +1 -0
- package/dist/internal/engines.js +22 -0
- package/dist/internal/engines.js.map +1 -0
- package/dist/internal/hooks.d.ts +11 -0
- package/dist/internal/hooks.d.ts.map +1 -0
- package/dist/internal/hooks.js +78 -0
- package/dist/internal/hooks.js.map +1 -0
- package/dist/lib/commitlint-config.d.ts +10 -0
- package/dist/lib/commitlint-config.d.ts.map +1 -0
- package/dist/lib/commitlint-config.js +8 -0
- package/dist/lib/commitlint-config.js.map +1 -0
- package/dist/lib/lint-staged.d.ts +10 -0
- package/dist/lib/lint-staged.d.ts.map +1 -0
- package/dist/lib/lint-staged.js +8 -0
- package/dist/lib/lint-staged.js.map +1 -0
- package/dist/lib/release-config-cli.d.ts +3 -0
- package/dist/lib/release-config-cli.d.ts.map +1 -0
- package/dist/lib/release-config-cli.js +3 -0
- package/dist/lib/release-config-cli.js.map +1 -0
- package/dist/lib/release-config.d.ts +82 -0
- package/dist/lib/release-config.d.ts.map +1 -0
- package/dist/lib/release-config.js +153 -0
- package/dist/lib/release-config.js.map +1 -0
- package/lint-staged.config.cjs +1 -1
- package/package.json +67 -74
- package/index.d.ts +0 -31
- package/index.js +0 -7
- package/src/cli/textmode-release.mjs +0 -139
- package/src/husky/pre-push +0 -6
- package/src/internal/engines.mjs +0 -55
- package/src/internal/hooks.mjs +0 -94
- package/src/lib/commitlint-config.js +0 -4
- package/src/lib/lint-staged.js +0 -4
- package/src/lib/release-config.js +0 -139
package/LICENSE
CHANGED
|
@@ -1,121 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
the purpose of contributing to a commons of creative, cultural and
|
|
23
|
-
scientific works ("Commons") that the public can reliably and without fear
|
|
24
|
-
of later claims of infringement build upon, modify, incorporate in other
|
|
25
|
-
works, reuse and redistribute as freely as possible in any form whatsoever
|
|
26
|
-
and for any purposes, including without limitation commercial purposes.
|
|
27
|
-
These owners may contribute to the Commons to promote the ideal of a free
|
|
28
|
-
culture and the further production of creative, cultural and scientific
|
|
29
|
-
works, or to gain reputation or greater distribution for their Work in
|
|
30
|
-
part through the use and efforts of others.
|
|
31
|
-
|
|
32
|
-
For these and/or other purposes and motivations, and without any
|
|
33
|
-
expectation of additional consideration or compensation, the person
|
|
34
|
-
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
|
35
|
-
is an owner of Copyright and Related Rights in the Work, voluntarily
|
|
36
|
-
elects to apply CC0 to the Work and publicly distribute the Work under its
|
|
37
|
-
terms, with knowledge of his or her Copyright and Related Rights in the
|
|
38
|
-
Work and the meaning and intended legal effect of CC0 on those rights.
|
|
39
|
-
|
|
40
|
-
1. Copyright and Related Rights. A Work made available under CC0 may be
|
|
41
|
-
protected by copyright and related or neighboring rights ("Copyright and
|
|
42
|
-
Related Rights"). Copyright and Related Rights include, but are not
|
|
43
|
-
limited to, the following:
|
|
44
|
-
|
|
45
|
-
i. the right to reproduce, adapt, distribute, perform, display,
|
|
46
|
-
communicate, and translate a Work;
|
|
47
|
-
ii. moral rights retained by the original author(s) and/or performer(s);
|
|
48
|
-
iii. publicity and privacy rights pertaining to a person's image or
|
|
49
|
-
likeness depicted in a Work;
|
|
50
|
-
iv. rights protecting against unfair competition in regards to a Work,
|
|
51
|
-
subject to the limitations in paragraph 4(a), below;
|
|
52
|
-
v. rights protecting the extraction, dissemination, use and reuse of data
|
|
53
|
-
in a Work;
|
|
54
|
-
vi. database rights (such as those arising under Directive 96/9/EC of the
|
|
55
|
-
European Parliament and of the Council of 11 March 1996 on the legal
|
|
56
|
-
protection of databases, and under any national implementation
|
|
57
|
-
thereof, including any amended or successor version of such
|
|
58
|
-
directive); and
|
|
59
|
-
vii. other similar, equivalent or corresponding rights throughout the
|
|
60
|
-
world based on applicable law or treaty, and any national
|
|
61
|
-
implementations thereof.
|
|
62
|
-
|
|
63
|
-
2. Waiver. To the greatest extent permitted by, but not in contravention
|
|
64
|
-
of, applicable law, Affirmer hereby overtly, fully, permanently,
|
|
65
|
-
irrevocably and unconditionally waives, abandons, and surrenders all of
|
|
66
|
-
Affirmer's Copyright and Related Rights and associated claims and causes
|
|
67
|
-
of action, whether now known or unknown (including existing as well as
|
|
68
|
-
future claims and causes of action), in the Work (i) in all territories
|
|
69
|
-
worldwide, (ii) for the maximum duration provided by applicable law or
|
|
70
|
-
treaty (including future time extensions), (iii) in any current or future
|
|
71
|
-
medium and for any number of copies, and (iv) for any purpose whatsoever,
|
|
72
|
-
including without limitation commercial, advertising or promotional
|
|
73
|
-
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
|
74
|
-
member of the public at large and to the detriment of Affirmer's heirs and
|
|
75
|
-
successors, fully intending that such Waiver shall not be subject to
|
|
76
|
-
revocation, rescission, cancellation, termination, or any other legal or
|
|
77
|
-
equitable action to disrupt the quiet enjoyment of the Work by the public
|
|
78
|
-
as contemplated by Affirmer's express Statement of Purpose.
|
|
79
|
-
|
|
80
|
-
3. Public License Fallback. Should any part of the Waiver for any reason
|
|
81
|
-
be judged legally invalid or ineffective under applicable law, then the
|
|
82
|
-
Waiver shall be preserved to the maximum extent permitted taking into
|
|
83
|
-
account Affirmer's express Statement of Purpose. In addition, to the
|
|
84
|
-
extent the Waiver is so judged Affirmer hereby grants to each affected
|
|
85
|
-
person a royalty-free, non transferable, non sublicensable, non exclusive,
|
|
86
|
-
irrevocable and unconditional license to exercise Affirmer's Copyright and
|
|
87
|
-
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
|
88
|
-
maximum duration provided by applicable law or treaty (including future
|
|
89
|
-
time extensions), (iii) in any current or future medium and for any number
|
|
90
|
-
of copies, and (iv) for any purpose whatsoever, including without
|
|
91
|
-
limitation commercial, advertising or promotional purposes (the
|
|
92
|
-
"License"). The License shall be deemed effective as of the date CC0 was
|
|
93
|
-
applied by Affirmer to the Work. Should any part of the License for any
|
|
94
|
-
reason be judged legally invalid or ineffective under applicable law, such
|
|
95
|
-
partial invalidity or ineffectiveness shall not invalidate the remainder
|
|
96
|
-
of the License, and in such case Affirmer hereby affirms that he or she
|
|
97
|
-
will not (i) exercise any of his or her remaining Copyright and Related
|
|
98
|
-
Rights in the Work or (ii) assert any associated claims and causes of
|
|
99
|
-
action with respect to the Work, in either case contrary to Affirmer's
|
|
100
|
-
express Statement of Purpose.
|
|
101
|
-
|
|
102
|
-
4. Limitations and Disclaimers.
|
|
103
|
-
|
|
104
|
-
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
|
105
|
-
surrendered, licensed or otherwise affected by this document.
|
|
106
|
-
b. Affirmer offers the Work as-is and makes no representations or
|
|
107
|
-
warranties of any kind concerning the Work, express, implied,
|
|
108
|
-
statutory or otherwise, including without limitation warranties of
|
|
109
|
-
title, merchantability, fitness for a particular purpose, non
|
|
110
|
-
infringement, or the absence of latent or other defects, accuracy, or
|
|
111
|
-
the present or absence of errors, whether or not discoverable, all to
|
|
112
|
-
the greatest extent permissible under applicable law.
|
|
113
|
-
c. Affirmer disclaims responsibility for clearing rights of other persons
|
|
114
|
-
that may apply to the Work or any use thereof, including without
|
|
115
|
-
limitation any person's Copyright and Related Rights in the Work.
|
|
116
|
-
Further, Affirmer disclaims responsibility for obtaining any necessary
|
|
117
|
-
consents, permissions or other rights required for any use of the
|
|
118
|
-
Work.
|
|
119
|
-
d. Affirmer understands and acknowledges that Creative Commons is not a
|
|
120
|
-
party to this document and has no duty or obligation with respect to
|
|
121
|
-
this CC0 or use of the Work.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 humanbydefinition
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
4
|
|
|
5
|
-
<img alt="@textmode/release — release textmode from one command" src="
|
|
5
|
+
<img alt="@textmode/release — release textmode from one command" src="../../.github/assets/readme-og-release.png" />
|
|
6
6
|
|
|
7
|
-
| [](https://www.typescriptlang.org/) [](https://semantic-release.gitbook.io/) | [](https://code.textmode.art/) [](https://discord.gg/sjrw8QXNks) | [](https://ko-fi.com/V7V8JG2FY) [](https://github.com/sponsors/humanbydefinition) |
|
|
8
8
|
| :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
9
9
|
|
|
10
10
|
</div>
|
|
@@ -18,7 +18,6 @@ Use it to release every package the same way and install the same managed Git ho
|
|
|
18
18
|
- **One package, multiple engines** - semantic-release and its plugins, commitlint, and lint-staged are implementation dependencies, not peer dependencies. Consumers install only `@textmode/release`.
|
|
19
19
|
- **Managed Git hooks** - `textmode-release hooks` installs commitlint, lint-staged, and push-guard hooks directly into Git's hooks directory, invoking the engines from the package itself.
|
|
20
20
|
- **pnpm-safe staged formatting** - The `pre-commit` hook formats staged files through an internal `format-staged` command, so it works without `textmode-lint` being exposed at the consumer root.
|
|
21
|
-
- **Stable release and hook behavior** - The release flow, commit rules, and hook behavior remain compatible with the previous `@textmode/release-config`, `@textmode/commitlint-config`, and `@textmode/tooling-scripts` packages.
|
|
22
21
|
|
|
23
22
|
## Installation
|
|
24
23
|
|
|
@@ -57,12 +56,13 @@ textmode-release release [args...]
|
|
|
57
56
|
textmode-release hooks
|
|
58
57
|
```
|
|
59
58
|
|
|
60
|
-
|
|
61
|
-
`textmode-release
|
|
59
|
+
The `release` command forwards engine options such as `--dry-run` and `--help`
|
|
60
|
+
to semantic-release. Use `textmode-release --help` or
|
|
61
|
+
`textmode-release --version` for the wrapper, and `--cwd <directory>` to set the
|
|
62
|
+
working directory.
|
|
62
63
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
the invocation was invalid.
|
|
64
|
+
Exit status `0` means success, `1` means an engine or hook reported a problem,
|
|
65
|
+
and `2` means the invocation was invalid or the engine could not start.
|
|
66
66
|
|
|
67
67
|
The managed pre-commit hook also invokes the internal `format-staged` command.
|
|
68
68
|
It is an implementation detail of the hook interface, not a project workflow.
|
|
@@ -119,7 +119,7 @@ and publishes directly.
|
|
|
119
119
|
| --- | --- |
|
|
120
120
|
| `commit-msg` | Validates the message with the shared commitlint config |
|
|
121
121
|
| `pre-commit` | Runs the shared lint-staged config (formats staged files with `textmode-release format-staged`) |
|
|
122
|
-
| `pre-push` | Blocks
|
|
122
|
+
| `pre-push` | Blocks pushes while the local `dev`, `beta`, or `main` branch is checked out |
|
|
123
123
|
|
|
124
124
|
### commitlint
|
|
125
125
|
|
|
@@ -132,39 +132,18 @@ The shared config ships at `@textmode/release/lint-staged` (a `.cjs` config
|
|
|
132
132
|
file) and formats staged files through `textmode-release format-staged`, which
|
|
133
133
|
resolves the `textmode-lint` binary from this package's own dependency graph.
|
|
134
134
|
|
|
135
|
-
## Configuration ownership
|
|
136
|
-
|
|
137
|
-
- `@textmode/release` owns the semantic-release config, commitlint rules,
|
|
138
|
-
lint-staged config, Git hooks, and command behavior.
|
|
139
|
-
- Each consumer's `package.json` owns its package metadata, release/hook
|
|
140
|
-
delegates, its `textmodeRelease` release-mode field, and its explicit
|
|
141
|
-
`check`, `build`, and `prepack` composition.
|
|
142
|
-
|
|
143
|
-
Consumers should not declare `semantic-release`, `@commitlint/cli`,
|
|
144
|
-
`lint-staged`, or the former `@textmode/release-config`,
|
|
145
|
-
`@textmode/commitlint-config`, and `@textmode/tooling-scripts` packages.
|
|
146
|
-
|
|
147
|
-
## Deprecations
|
|
148
|
-
|
|
149
|
-
`@textmode/release` replaces the release, commitlint, and hook responsibilities
|
|
150
|
-
of `@textmode/release-config`, `@textmode/commitlint-config`, and
|
|
151
|
-
`@textmode/tooling-scripts`, which are deprecated and removed from this
|
|
152
|
-
workspace. Project-level `check` and `prepack` orchestration from the former
|
|
153
|
-
tooling scripts belongs in consumer manifests. The older packages remain
|
|
154
|
-
published on npm for projects that have not migrated yet.
|
|
155
|
-
|
|
156
135
|
## Related packages
|
|
157
136
|
|
|
158
137
|
`@textmode/lint` remains an implementation dependency because the managed
|
|
159
138
|
`pre-commit` hook formats staged files through it:
|
|
160
139
|
|
|
161
|
-
| Package
|
|
162
|
-
|
|
|
163
|
-
| [`@textmode/lint`](
|
|
140
|
+
| Package | Relationship |
|
|
141
|
+
| --- | --- |
|
|
142
|
+
| [`@textmode/lint`](https://github.com/textmode-art/tooling/tree/main/packages/lint) | Powers `textmode-release format-staged` for the lint-staged hook |
|
|
164
143
|
|
|
165
144
|
## License
|
|
166
145
|
|
|
167
|
-
The `@textmode/release` package is licensed under the [
|
|
146
|
+
The `@textmode/release` package is licensed under the [MIT License](https://github.com/textmode-art/tooling/blob/main/LICENSE).
|
|
168
147
|
|
|
169
148
|
## Acknowledgements
|
|
170
149
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textmode-release.d.ts","sourceRoot":"","sources":["../../src/cli/textmode-release.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import process from 'node:process';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { runEngine } from '../internal/engines.js';
|
|
7
|
+
import { installGitHooks } from '../internal/hooks.js';
|
|
8
|
+
const PACKAGE_JSON = JSON.parse(fs.readFileSync(new URL('../../package.json', import.meta.url), 'utf8'));
|
|
9
|
+
const PACKAGE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..');
|
|
10
|
+
const COMMANDS = new Set(['release', 'hooks', 'format-staged', 'hook']);
|
|
11
|
+
function printGeneralHelp() {
|
|
12
|
+
console.log(`@textmode/release ${PACKAGE_JSON.version}`);
|
|
13
|
+
console.log('');
|
|
14
|
+
console.log('Usage: textmode-release <command> [options]');
|
|
15
|
+
console.log('');
|
|
16
|
+
console.log('Commands:');
|
|
17
|
+
console.log(' release [args...] Run semantic-release with the shared config');
|
|
18
|
+
console.log(' hooks Install managed Git hooks (commitlint, lint-staged, push guard)');
|
|
19
|
+
console.log(' format-staged [files...] Format staged files with the shared Prettier config (internal)');
|
|
20
|
+
console.log('');
|
|
21
|
+
console.log('Common options:');
|
|
22
|
+
console.log(' --cwd <directory> Directory to run in');
|
|
23
|
+
console.log(' --help, -h Show help');
|
|
24
|
+
console.log(' --version, -v Show version');
|
|
25
|
+
console.log('');
|
|
26
|
+
console.log('Every argument after the release command is forwarded to semantic-release.');
|
|
27
|
+
}
|
|
28
|
+
function printCommandHelp(command) {
|
|
29
|
+
const usage = {
|
|
30
|
+
release: 'textmode-release release [args...]',
|
|
31
|
+
hooks: 'textmode-release hooks',
|
|
32
|
+
'format-staged': 'textmode-release format-staged [files...]',
|
|
33
|
+
hook: 'textmode-release hook <commit-msg|pre-commit> [args...]',
|
|
34
|
+
};
|
|
35
|
+
console.log(`Usage: ${usage[command]}`);
|
|
36
|
+
}
|
|
37
|
+
function parseArgv(argv) {
|
|
38
|
+
const values = {
|
|
39
|
+
cwd: undefined,
|
|
40
|
+
help: false,
|
|
41
|
+
version: false,
|
|
42
|
+
};
|
|
43
|
+
const rest = [];
|
|
44
|
+
let commandSeen = false;
|
|
45
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
46
|
+
const arg = argv[index];
|
|
47
|
+
if (arg === '--cwd') {
|
|
48
|
+
if (index + 1 >= argv.length || argv[index + 1].startsWith('-')) {
|
|
49
|
+
throw new Error('--cwd requires a directory value.');
|
|
50
|
+
}
|
|
51
|
+
values.cwd = argv[index + 1];
|
|
52
|
+
index += 1;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (!commandSeen) {
|
|
56
|
+
if (arg === '--help' || arg === '-h') {
|
|
57
|
+
values.help = true;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (arg === '--version' || arg === '-v') {
|
|
61
|
+
values.version = true;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (!arg.startsWith('-')) {
|
|
65
|
+
commandSeen = true;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
rest.push(arg);
|
|
69
|
+
}
|
|
70
|
+
const [rawCommand, ...forwarded] = rest;
|
|
71
|
+
if (rawCommand !== undefined && !COMMANDS.has(rawCommand)) {
|
|
72
|
+
throw new Error(`Unknown command "${rawCommand}".`);
|
|
73
|
+
}
|
|
74
|
+
const command = rawCommand;
|
|
75
|
+
if (command === 'hooks' && forwarded.length > 0) {
|
|
76
|
+
throw new Error(`The ${command} command does not accept arguments.`);
|
|
77
|
+
}
|
|
78
|
+
return { command, forwarded, values };
|
|
79
|
+
}
|
|
80
|
+
function runRelease(forwarded, cwd) {
|
|
81
|
+
const releaseConfig = path.join(PACKAGE_ROOT, 'dist', 'lib', 'release-config-cli.js');
|
|
82
|
+
return runEngine('semantic-release', 'semantic-release', ['--extends', releaseConfig, ...forwarded], { cwd });
|
|
83
|
+
}
|
|
84
|
+
function runFormatStaged(files, cwd) {
|
|
85
|
+
if (files.length === 0) {
|
|
86
|
+
console.error('format-staged requires at least one staged file.');
|
|
87
|
+
return 2;
|
|
88
|
+
}
|
|
89
|
+
return runEngine('@textmode/lint', 'textmode-lint', ['format', ...files], { cwd });
|
|
90
|
+
}
|
|
91
|
+
function runManagedHook(args, cwd) {
|
|
92
|
+
const [hookName, ...hookArgs] = args;
|
|
93
|
+
if (hookName === 'commit-msg') {
|
|
94
|
+
const commitlintConfig = path.join(PACKAGE_ROOT, 'commitlint.config.cjs');
|
|
95
|
+
const messageFile = hookArgs[0];
|
|
96
|
+
if (!messageFile) {
|
|
97
|
+
console.error('commit-msg hook requires a commit message file path.');
|
|
98
|
+
return 2;
|
|
99
|
+
}
|
|
100
|
+
return runEngine('@commitlint/cli', 'commitlint', ['--config', commitlintConfig, '--edit', messageFile], {
|
|
101
|
+
cwd,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
if (hookName === 'pre-commit') {
|
|
105
|
+
const lintStagedConfig = path.join(PACKAGE_ROOT, 'lint-staged.config.cjs');
|
|
106
|
+
return runEngine('lint-staged', 'lint-staged', ['--config', lintStagedConfig, ...hookArgs], { cwd });
|
|
107
|
+
}
|
|
108
|
+
console.error(`Unknown hook "${hookName ?? ''}". Expected "commit-msg" or "pre-commit".`);
|
|
109
|
+
return 2;
|
|
110
|
+
}
|
|
111
|
+
function main(argv) {
|
|
112
|
+
let parsed;
|
|
113
|
+
try {
|
|
114
|
+
parsed = parseArgv(argv);
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
118
|
+
return 2;
|
|
119
|
+
}
|
|
120
|
+
const { command, forwarded, values } = parsed;
|
|
121
|
+
const cwd = values.cwd ? path.resolve(values.cwd) : process.cwd();
|
|
122
|
+
if (values.version && command === undefined) {
|
|
123
|
+
console.log(PACKAGE_JSON.version);
|
|
124
|
+
return 0;
|
|
125
|
+
}
|
|
126
|
+
if (values.help && command === undefined) {
|
|
127
|
+
printGeneralHelp();
|
|
128
|
+
return 0;
|
|
129
|
+
}
|
|
130
|
+
if (command === undefined) {
|
|
131
|
+
console.error('Missing command. Run textmode-release --help for usage.');
|
|
132
|
+
return 2;
|
|
133
|
+
}
|
|
134
|
+
if (values.help) {
|
|
135
|
+
printCommandHelp(command);
|
|
136
|
+
return 0;
|
|
137
|
+
}
|
|
138
|
+
switch (command) {
|
|
139
|
+
case 'release':
|
|
140
|
+
return runRelease(forwarded, cwd);
|
|
141
|
+
case 'hooks':
|
|
142
|
+
return installGitHooks({ cwd }) ? 0 : 1;
|
|
143
|
+
case 'format-staged':
|
|
144
|
+
return runFormatStaged(forwarded, cwd);
|
|
145
|
+
case 'hook':
|
|
146
|
+
return runManagedHook(forwarded, cwd);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
process.exitCode = main(process.argv.slice(2));
|
|
150
|
+
//# sourceMappingURL=textmode-release.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textmode-release.js","sourceRoot":"","sources":["../../src/cli/textmode-release.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,oBAAoB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAEtG,CAAC;AACF,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AAIzF,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAU,CAAC,SAAS,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,CAAC,CAAC,CAAC;AAEjF,SAAS,gBAAgB;IACxB,OAAO,CAAC,GAAG,CAAC,qBAAqB,YAAY,CAAC,OAAO,EAAE,CAAC,CAAC;IACzD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,6CAA6C,CAAC,CAAC;IAC3D,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACzB,OAAO,CAAC,GAAG,C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,EAAE,CAAC;QAC3B,OAAO,CAAC,KAAK,CAAC,yDAAyD,CAAC,CAAC;QACzE,OAAO,CAAC,CAAC;IACV,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;QACjB,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAC1B,OAAO,CAAC,CAAC;IACV,CAAC;IAED,QAAQ,OAAO,EAAE,CAAC;QACjB,KAAK,SAAS;YACb,OAAO,UAAU,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;QACnC,KAAK,OAAO;YACX,OAAO,eAAe,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACzC,KAAK,eAAe;YACnB,OAAO,eAAe,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;QACxC,KAAK,MAAM;YACV,OAAO,cAAc,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IACxC,CAAC;AACF,CAAC;AAED,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared semantic-release, commitlint, lint-staged, and managed Git-hook tooling for the `textmode.js` ecosystem.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
export { createReleaseConfig, githubAssetsFromPackageJson, releaseConfig, type GitHubReleaseMode, type PackageExportsSource, type ReleaseBranch, type ReleaseConfig, type ReleaseConfigOptions, } from './lib/release-config.js';
|
|
7
|
+
export { commitlintConfig, type CommitlintConfig } from './lib/commitlint-config.js';
|
|
8
|
+
export { lintStagedConfig, type LintStagedConfig } from './lib/lint-staged.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACN,mBAAmB,EACnB,2BAA2B,EAC3B,aAAa,EACb,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,oBAAoB,GACzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EAAE,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared semantic-release, commitlint, lint-staged, and managed Git-hook tooling for the `textmode.js` ecosystem.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
export { createReleaseConfig, githubAssetsFromPackageJson, releaseConfig, } from './lib/release-config.js';
|
|
7
|
+
export { commitlintConfig } from './lib/commitlint-config.js';
|
|
8
|
+
export { lintStagedConfig } from './lib/lint-staged.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACN,mBAAmB,EACnB,2BAA2B,EAC3B,aAAa,GAMb,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAyB,MAAM,4BAA4B,CAAC;AACrF,OAAO,EAAE,gBAAgB,EAAyB,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engines.d.ts","sourceRoot":"","sources":["../../src/internal/engines.ts"],"names":[],"mappings":"AAKA,sFAAsF;AACtF,wBAAgB,SAAS,CACxB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,EAAE,GAAmB,EAAE,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAO,GAC5C,MAAM,CAiBR"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import { findPackageJSON } from 'node:module';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
/** Run the package-owned engine with the supplied arguments and working directory. */
|
|
6
|
+
export function runEngine(name, binName, args, { cwd = process.cwd() } = {}) {
|
|
7
|
+
const manifestPath = findPackageJSON(name, import.meta.url);
|
|
8
|
+
if (!manifestPath)
|
|
9
|
+
throw new Error(`Cannot resolve ${name}.`);
|
|
10
|
+
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
|
11
|
+
const bin = typeof manifest.bin === 'string' ? manifest.bin : manifest.bin?.[binName];
|
|
12
|
+
if (typeof bin !== 'string')
|
|
13
|
+
throw new Error(`Cannot resolve ${name} binary ${binName}.`);
|
|
14
|
+
const entry = path.resolve(path.dirname(manifestPath), bin);
|
|
15
|
+
const result = spawnSync(process.execPath, [entry, ...args], { cwd, stdio: 'inherit' });
|
|
16
|
+
if (result.error) {
|
|
17
|
+
console.error(`Unable to run ${name}: ${result.error.message}`);
|
|
18
|
+
return 2;
|
|
19
|
+
}
|
|
20
|
+
return result.status ?? 1;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=engines.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engines.js","sourceRoot":"","sources":["../../src/internal/engines.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,sFAAsF;AACtF,MAAM,UAAU,S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install portable managed Git hooks (`commit-msg`, `pre-commit`, and `pre-push`) in a Git repository.
|
|
3
|
+
*
|
|
4
|
+
* @param options - Working directory options.
|
|
5
|
+
* @param options.cwd - Git repository directory.
|
|
6
|
+
* @returns `true` when hooks were installed or intentionally skipped outside Git; `false` when blocked by an external `core.hooksPath`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function installGitHooks(options?: {
|
|
9
|
+
cwd?: string;
|
|
10
|
+
}): boolean;
|
|
11
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/internal/hooks.ts"],"names":[],"mappings":"AAgEA;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,OAAO,CAoBvE"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import process from 'node:process';
|
|
5
|
+
const MANAGED_MARKER = '# textmode-tooling managed hook';
|
|
6
|
+
const PRE_PUSH_BODY = `branch="$(git rev-parse --abbrev-ref HEAD)"
|
|
7
|
+
|
|
8
|
+
if [ "$branch" = "dev" ] || [ "$branch" = "beta" ] || [ "$branch" = "main" ]; then
|
|
9
|
+
echo "Direct pushes to '$branch' are not allowed. Open a pull request to dev, then promote dev -> beta -> main."
|
|
10
|
+
exit 1
|
|
11
|
+
fi
|
|
12
|
+
`;
|
|
13
|
+
function runGit(args, cwd) {
|
|
14
|
+
return spawnSync('git', args, {
|
|
15
|
+
cwd,
|
|
16
|
+
encoding: 'utf8',
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function removeLegacyHuskyHookPath(cwd) {
|
|
20
|
+
const configuredHookPath = runGit(['config', '--local', '--get', 'core.hooksPath'], cwd);
|
|
21
|
+
if (configuredHookPath.status !== 0) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
const hookPath = configuredHookPath.stdout.trim().replace(/\\/g, '/');
|
|
25
|
+
if (!hookPath.endsWith('/.husky/_') && hookPath !== '.husky/_') {
|
|
26
|
+
console.warn(`Skipping Git hook installation because core.hooksPath is managed externally: ${hookPath}`);
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
const unsetResult = runGit(['config', '--local', '--unset-all', 'core.hooksPath'], cwd);
|
|
30
|
+
if (unsetResult.status !== 0) {
|
|
31
|
+
throw new Error('Unable to remove the legacy Husky core.hooksPath setting.');
|
|
32
|
+
}
|
|
33
|
+
console.log('Removed legacy Husky core.hooksPath setting.');
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
function resolveSharedGitHooksDirectory(cwd) {
|
|
37
|
+
// Linked worktrees share hooks through Git's common directory.
|
|
38
|
+
const result = runGit(['rev-parse', '--git-common-dir'], cwd);
|
|
39
|
+
if (result.status !== 0) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
return path.resolve(cwd, result.stdout.trim(), 'hooks');
|
|
43
|
+
}
|
|
44
|
+
function writeManagedHook(hooksDir, hookName, source) {
|
|
45
|
+
const targetPath = path.join(hooksDir, hookName);
|
|
46
|
+
if (fs.existsSync(targetPath) && !fs.readFileSync(targetPath, 'utf8').includes(MANAGED_MARKER)) {
|
|
47
|
+
console.warn(`Skipping existing unmanaged Git hook: ${targetPath}`);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
fs.writeFileSync(targetPath, `#!/bin/sh\n${MANAGED_MARKER}\n${source}`);
|
|
51
|
+
fs.chmodSync(targetPath, 0o755);
|
|
52
|
+
console.log(`Installed Git hook: ${hookName}`);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Install portable managed Git hooks (`commit-msg`, `pre-commit`, and `pre-push`) in a Git repository.
|
|
56
|
+
*
|
|
57
|
+
* @param options - Working directory options.
|
|
58
|
+
* @param options.cwd - Git repository directory.
|
|
59
|
+
* @returns `true` when hooks were installed or intentionally skipped outside Git; `false` when blocked by an external `core.hooksPath`.
|
|
60
|
+
*/
|
|
61
|
+
export function installGitHooks(options = {}) {
|
|
62
|
+
const cwd = options.cwd ?? process.cwd();
|
|
63
|
+
if (!removeLegacyHuskyHookPath(cwd)) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
const hooksDir = resolveSharedGitHooksDirectory(cwd);
|
|
67
|
+
if (!hooksDir) {
|
|
68
|
+
console.log('Skipping Git hook installation outside a Git worktree.');
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
fs.mkdirSync(hooksDir, { recursive: true });
|
|
72
|
+
const hookPrologue = 'PATH="./node_modules/.bin:$PATH"\nexport PATH';
|
|
73
|
+
writeManagedHook(hooksDir, 'commit-msg', `${hookPrologue}\nexec textmode-release hook commit-msg "$1"\n`);
|
|
74
|
+
writeManagedHook(hooksDir, 'pre-commit', `${hookPrologue}\nexec textmode-release hook pre-commit\n`);
|
|
75
|
+
writeManagedHook(hooksDir, 'pre-push', `${hookPrologue}\n${PRE_PUSH_BODY}`);
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/internal/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAyB,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,MAAM,cAAc,GAAG,iCAAiC,CAAC;AAEzD,MAAM,aAAa,GAAG;;;;;;CAMrB,CAAC;AAEF,SAAS,MAAM,CAAC,IAAc,EAAE,GAAW;IAC1C,OAAO,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE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G,YAAY,gDAAgD,CAAC,CAAC;IAC1G,gBAAgB,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,YAAY,2CAA2C,CAAC,CAAC;IACrG,gBAAgB,CAAC,QAAQ,EAAE,UAAU,EAAE,GAAG,YAAY,KAAK,aAAa,EAAE,CAAC,CAAC;IAC5E,OAAO,IAAI,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared commitlint configuration object type.
|
|
3
|
+
*/
|
|
4
|
+
export type CommitlintConfig = Record<string, unknown>;
|
|
5
|
+
/**
|
|
6
|
+
* Shared commitlint configuration extending `@commitlint/config-conventional`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const commitlintConfig: CommitlintConfig;
|
|
9
|
+
export default commitlintConfig;
|
|
10
|
+
//# sourceMappingURL=commitlint-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commitlint-config.d.ts","sourceRoot":"","sources":["../../src/lib/commitlint-config.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEvD;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,gBAA6E,CAAC;AAE7G,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
const require = createRequire(import.meta.url);
|
|
3
|
+
/**
|
|
4
|
+
* Shared commitlint configuration extending `@commitlint/config-conventional`.
|
|
5
|
+
*/
|
|
6
|
+
export const commitlintConfig = require('../../commitlint.config.cjs');
|
|
7
|
+
export default commitlintConfig;
|
|
8
|
+
//# sourceMappingURL=commitlint-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commitlint-config.js","sourceRoot":"","sources":["../../src/lib/commitlint-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAO/C;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAqB,OAAO,CAAC,6BAA6B,CAAqB,CAAC;AAE7G,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared lint-staged configuration object type.
|
|
3
|
+
*/
|
|
4
|
+
export type LintStagedConfig = Record<string, string | string[]>;
|
|
5
|
+
/**
|
|
6
|
+
* Shared lint-staged configuration that formats staged files via `textmode-release format-staged`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const lintStagedConfig: LintStagedConfig;
|
|
9
|
+
export default lintStagedConfig;
|
|
10
|
+
//# sourceMappingURL=lint-staged.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint-staged.d.ts","sourceRoot":"","sources":["../../src/lib/lint-staged.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;AAEjE;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,gBAA8E,CAAC;AAE9G,eAAe,gBAAgB,CAAC"}
|