@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.
Files changed (45) hide show
  1. package/LICENSE +21 -121
  2. package/README.md +13 -34
  3. package/dist/cli/textmode-release.d.ts +3 -0
  4. package/dist/cli/textmode-release.d.ts.map +1 -0
  5. package/dist/cli/textmode-release.js +150 -0
  6. package/dist/cli/textmode-release.js.map +1 -0
  7. package/dist/index.d.ts +9 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +9 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/internal/engines.d.ts +5 -0
  12. package/dist/internal/engines.d.ts.map +1 -0
  13. package/dist/internal/engines.js +22 -0
  14. package/dist/internal/engines.js.map +1 -0
  15. package/dist/internal/hooks.d.ts +11 -0
  16. package/dist/internal/hooks.d.ts.map +1 -0
  17. package/dist/internal/hooks.js +78 -0
  18. package/dist/internal/hooks.js.map +1 -0
  19. package/dist/lib/commitlint-config.d.ts +10 -0
  20. package/dist/lib/commitlint-config.d.ts.map +1 -0
  21. package/dist/lib/commitlint-config.js +8 -0
  22. package/dist/lib/commitlint-config.js.map +1 -0
  23. package/dist/lib/lint-staged.d.ts +10 -0
  24. package/dist/lib/lint-staged.d.ts.map +1 -0
  25. package/dist/lib/lint-staged.js +8 -0
  26. package/dist/lib/lint-staged.js.map +1 -0
  27. package/dist/lib/release-config-cli.d.ts +3 -0
  28. package/dist/lib/release-config-cli.d.ts.map +1 -0
  29. package/dist/lib/release-config-cli.js +3 -0
  30. package/dist/lib/release-config-cli.js.map +1 -0
  31. package/dist/lib/release-config.d.ts +82 -0
  32. package/dist/lib/release-config.d.ts.map +1 -0
  33. package/dist/lib/release-config.js +153 -0
  34. package/dist/lib/release-config.js.map +1 -0
  35. package/lint-staged.config.cjs +1 -1
  36. package/package.json +67 -74
  37. package/index.d.ts +0 -31
  38. package/index.js +0 -7
  39. package/src/cli/textmode-release.mjs +0 -139
  40. package/src/husky/pre-push +0 -6
  41. package/src/internal/engines.mjs +0 -55
  42. package/src/internal/hooks.mjs +0 -94
  43. package/src/lib/commitlint-config.js +0 -4
  44. package/src/lib/lint-staged.js +0 -4
  45. package/src/lib/release-config.js +0 -139
@@ -0,0 +1,8 @@
1
+ import { createRequire } from 'node:module';
2
+ const require = createRequire(import.meta.url);
3
+ /**
4
+ * Shared lint-staged configuration that formats staged files via `textmode-release format-staged`.
5
+ */
6
+ export const lintStagedConfig = require('../../lint-staged.config.cjs');
7
+ export default lintStagedConfig;
8
+ //# sourceMappingURL=lint-staged.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lint-staged.js","sourceRoot":"","sources":["../../src/lib/lint-staged.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,8BAA8B,CAAqB,CAAC;AAE9G,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare const _default: import("./release-config.js").ReleaseConfig;
2
+ export default _default;
3
+ //# sourceMappingURL=release-config-cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"release-config-cli.d.ts","sourceRoot":"","sources":["../../src/lib/release-config-cli.ts"],"names":[],"mappings":";AAEA,wBAAqC"}
@@ -0,0 +1,3 @@
1
+ import { createReleaseConfig } from './release-config.js';
2
+ export default createReleaseConfig();
3
+ //# sourceMappingURL=release-config-cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"release-config-cli.js","sourceRoot":"","sources":["../../src/lib/release-config-cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D,eAAe,mBAAmB,EAAE,CAAC"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Branch rule entry in a semantic-release configuration.
3
+ */
4
+ export interface ReleaseBranch {
5
+ /** Git branch name or glob. */
6
+ name: string;
7
+ /** Prerelease identifier or toggle. */
8
+ prerelease?: boolean | string;
9
+ /** npm distribution tag channel. */
10
+ channel?: string;
11
+ /** Maintenance branch semver range. */
12
+ range?: string;
13
+ }
14
+ /**
15
+ * Complete semantic-release configuration object returned by {@link createReleaseConfig}.
16
+ */
17
+ export interface ReleaseConfig {
18
+ /** Configured release branches. */
19
+ branches: Array<string | ReleaseBranch>;
20
+ /** Git tag template. */
21
+ tagFormat: string;
22
+ /** Ordered list of semantic-release plugins. */
23
+ plugins: unknown[];
24
+ /** Whether semantic-release runs in dry-run mode. */
25
+ dryRun: boolean;
26
+ /** Whether semantic-release enforces CI environment checks. */
27
+ ci: boolean;
28
+ }
29
+ /**
30
+ * Mode controlling how `@semantic-release/github` publishes GitHub releases.
31
+ */
32
+ export type GitHubReleaseMode = 'draft' | 'direct';
33
+ /**
34
+ * Minimal package manifest shape inspected by {@link githubAssetsFromPackageJson}.
35
+ */
36
+ export interface PackageExportsSource {
37
+ /** `package.json#exports` field. */
38
+ exports?: unknown;
39
+ }
40
+ /**
41
+ * Options accepted by {@link createReleaseConfig}.
42
+ */
43
+ export interface ReleaseConfigOptions {
44
+ /** JavaScript bundle asset paths attached to the GitHub release. Defaults to assets derived from `package.json#exports`. */
45
+ githubAssets?: string[];
46
+ /** GitHub release visibility mode (`'draft'` or `'direct'`). Defaults to `package.json#textmodeRelease.githubRelease` or `'draft'`. */
47
+ githubRelease?: GitHubReleaseMode | string;
48
+ /** Command executed during `@semantic-release/exec` prepare step. Defaults to `'npm run build --if-present'`. */
49
+ buildCommand?: string;
50
+ /** Files committed back by `@semantic-release/git`. Defaults to `['package.json', 'package-lock.json']`. */
51
+ gitAssets?: string[];
52
+ }
53
+ /**
54
+ * Extract publishable JavaScript bundle asset paths (`dist/*.js`, `*.mjs`, `*.cjs`) from `package.json#exports`.
55
+ *
56
+ * @param packageJson - Parsed `package.json` manifest or partial object containing `exports`.
57
+ * @returns Sorted list of relative bundle paths without a leading `./`.
58
+ */
59
+ export declare function githubAssetsFromPackageJson(packageJson: PackageExportsSource): string[];
60
+ /**
61
+ * Create a semantic-release configuration for a `textmode.js` package.
62
+ *
63
+ * Reads the current package manifest when the GitHub asset list or release mode is omitted.
64
+ *
65
+ * @param options - Optional asset, GitHub release mode, build command, and committed asset overrides.
66
+ * @returns Configured semantic-release options object.
67
+ * @example
68
+ * ```ts
69
+ * import { createReleaseConfig } from '@textmode/release';
70
+ *
71
+ * export default createReleaseConfig({ githubRelease: 'direct' });
72
+ * ```
73
+ */
74
+ export declare function createReleaseConfig(options?: ReleaseConfigOptions): ReleaseConfig;
75
+ /**
76
+ * Static semantic-release configuration for draft GitHub releases without package-derived assets.
77
+ *
78
+ * Use {@link createReleaseConfig} to derive release settings from the current package.
79
+ */
80
+ export declare const releaseConfig: ReleaseConfig;
81
+ export default releaseConfig;
82
+ //# sourceMappingURL=release-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"release-config.d.ts","sourceRoot":"","sources":["../../src/lib/release-config.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,UAAU,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC9B,oCAAoC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,mCAAmC;IACnC,QAAQ,EAAE,KAAK,CAAC,MAAM,GAAG,aAAa,CAAC,CAAC;IACxC,wBAAwB;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,qDAAqD;IACrD,MAAM,EAAE,OAAO,CAAC;IAChB,+DAA+D;IAC/D,EAAE,EAAE,OAAO,CAAC;CACZ;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC,oCAAoC;IACpC,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC,4HAA4H;IAC5H,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,uIAAuI;IACvI,aAAa,CAAC,EAAE,iBAAiB,GAAG,MAAM,CAAC;IAC3C,iHAAiH;IACjH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,4GAA4G;IAC5G,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAwBD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,oBAAoB,GAAG,MAAM,EAAE,CAIvF;AAiCD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,oBAAyB,GAAG,aAAa,CA2ErF;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,aAG1B,CAAC;AAEH,eAAe,aAAa,CAAC"}
@@ -0,0 +1,153 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ function collectBundleAssets(value, assets) {
4
+ if (typeof value === 'string') {
5
+ if (value.startsWith('./dist/') && /\.(?:[cm]?js)$/.test(value)) {
6
+ assets.add(value.slice(2));
7
+ }
8
+ return;
9
+ }
10
+ if (Array.isArray(value)) {
11
+ for (const item of value) {
12
+ collectBundleAssets(item, assets);
13
+ }
14
+ return;
15
+ }
16
+ if (value && typeof value === 'object') {
17
+ for (const item of Object.values(value)) {
18
+ collectBundleAssets(item, assets);
19
+ }
20
+ }
21
+ }
22
+ /**
23
+ * Extract publishable JavaScript bundle asset paths (`dist/*.js`, `*.mjs`, `*.cjs`) from `package.json#exports`.
24
+ *
25
+ * @param packageJson - Parsed `package.json` manifest or partial object containing `exports`.
26
+ * @returns Sorted list of relative bundle paths without a leading `./`.
27
+ */
28
+ export function githubAssetsFromPackageJson(packageJson) {
29
+ const assets = new Set();
30
+ collectBundleAssets(packageJson.exports, assets);
31
+ return [...assets].sort();
32
+ }
33
+ function readCurrentPackageManifest() {
34
+ const packagePath = path.resolve(process.cwd(), 'package.json');
35
+ if (!fs.existsSync(packagePath)) {
36
+ return undefined;
37
+ }
38
+ return JSON.parse(fs.readFileSync(packagePath, 'utf8'));
39
+ }
40
+ function getCurrentPackageGitHubAssets() {
41
+ const manifest = readCurrentPackageManifest();
42
+ return manifest ? githubAssetsFromPackageJson(manifest) : [];
43
+ }
44
+ function getCurrentPackageGitHubReleaseMode() {
45
+ const manifest = readCurrentPackageManifest();
46
+ const releaseOptions = manifest?.textmodeRelease;
47
+ return releaseOptions?.githubRelease;
48
+ }
49
+ function resolveDraftReleaseFlag(githubRelease) {
50
+ if (githubRelease === 'direct') {
51
+ return false;
52
+ }
53
+ if (githubRelease !== undefined && githubRelease !== 'draft') {
54
+ console.error(`@textmode/release: unknown textmodeRelease.githubRelease value ${JSON.stringify(githubRelease)}; using "draft".`);
55
+ }
56
+ return true;
57
+ }
58
+ /**
59
+ * Create a semantic-release configuration for a `textmode.js` package.
60
+ *
61
+ * Reads the current package manifest when the GitHub asset list or release mode is omitted.
62
+ *
63
+ * @param options - Optional asset, GitHub release mode, build command, and committed asset overrides.
64
+ * @returns Configured semantic-release options object.
65
+ * @example
66
+ * ```ts
67
+ * import { createReleaseConfig } from '@textmode/release';
68
+ *
69
+ * export default createReleaseConfig({ githubRelease: 'direct' });
70
+ * ```
71
+ */
72
+ export function createReleaseConfig(options = {}) {
73
+ const { githubAssets = getCurrentPackageGitHubAssets(), githubRelease = getCurrentPackageGitHubReleaseMode(), buildCommand = 'npm run build --if-present', gitAssets = ['package.json', 'package-lock.json'], } = options;
74
+ return {
75
+ branches: [
76
+ 'main',
77
+ {
78
+ name: 'beta',
79
+ prerelease: true,
80
+ },
81
+ ],
82
+ tagFormat: 'v${version}',
83
+ plugins: [
84
+ [
85
+ '@semantic-release/commit-analyzer',
86
+ {
87
+ releaseRules: [
88
+ { type: 'feat', release: 'minor' },
89
+ { type: 'fix', release: 'patch' },
90
+ { type: 'perf', release: 'patch' },
91
+ { type: 'refactor', release: 'patch' },
92
+ { type: 'docs', release: false },
93
+ { type: 'style', release: false },
94
+ { type: 'test', release: false },
95
+ { type: 'chore', release: false },
96
+ { breaking: true, release: 'major' },
97
+ ],
98
+ },
99
+ ],
100
+ '@semantic-release/release-notes-generator',
101
+ // Set the next package version before the build reads it.
102
+ [
103
+ '@semantic-release/npm',
104
+ {
105
+ npmPublish: false,
106
+ },
107
+ ],
108
+ [
109
+ '@semantic-release/exec',
110
+ {
111
+ prepareCmd: buildCommand,
112
+ },
113
+ ],
114
+ [
115
+ '@semantic-release/npm',
116
+ {
117
+ npmPublish: true,
118
+ },
119
+ ],
120
+ // Commit the release files after preparation. GitHub attaches the resulting bundles.
121
+ [
122
+ '@semantic-release/git',
123
+ {
124
+ assets: gitAssets,
125
+ message: 'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}',
126
+ },
127
+ ],
128
+ [
129
+ '@semantic-release/github',
130
+ {
131
+ assets: githubAssets,
132
+ draftRelease: resolveDraftReleaseFlag(githubRelease),
133
+ successComment: false,
134
+ failComment: false,
135
+ releasedLabels: false,
136
+ },
137
+ ],
138
+ ],
139
+ dryRun: false,
140
+ ci: true,
141
+ };
142
+ }
143
+ /**
144
+ * Static semantic-release configuration for draft GitHub releases without package-derived assets.
145
+ *
146
+ * Use {@link createReleaseConfig} to derive release settings from the current package.
147
+ */
148
+ export const releaseConfig = createReleaseConfig({
149
+ githubAssets: [],
150
+ githubRelease: 'draft',
151
+ });
152
+ export default releaseConfig;
153
+ //# sourceMappingURL=release-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"release-config.js","sourceRoot":"","sources":["../../src/lib/release-config.ts"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AAC;IAC/D,YAAY,EAAE,EAAE;IAChB,aAAa,EAAE,OAAO;CACtB,CAAC,CAAC;AAEH,eAAe,aAAa,CAAC"}
@@ -3,5 +3,5 @@
3
3
  const path = require('node:path');
4
4
 
5
5
  module.exports = {
6
- '*': `node ${JSON.stringify(path.join(__dirname, 'src/cli/textmode-release.mjs'))} format-staged`,
6
+ '*': `node ${JSON.stringify(path.join(__dirname, 'dist/cli/textmode-release.js'))} format-staged`,
7
7
  };
package/package.json CHANGED
@@ -1,75 +1,68 @@
1
1
  {
2
- "name": "@textmode/release",
3
- "version": "0.2.0",
4
- "type": "module",
5
- "license": "CC0-1.0",
6
- "description": "Shared release and Git-hook tooling for the textmode.js ecosystem (semantic-release, commitlint, lint-staged).",
7
- "keywords": [
8
- "textmode",
9
- "semantic-release",
10
- "commitlint",
11
- "lint-staged",
12
- "git-hooks",
13
- "release"
14
- ],
15
- "author": "humanbydefinition <hello@textmode.art> (https://code.textmode.art)",
16
- "homepage": "https://code.textmode.art",
17
- "repository": {
18
- "type": "git",
19
- "url": "git+https://github.com/textmode-art/tooling.git",
20
- "directory": "packages/release"
21
- },
22
- "engines": {
23
- "node": ">=24 <25"
24
- },
25
- "bin": {
26
- "textmode-release": "src/cli/textmode-release.mjs"
27
- },
28
- "exports": {
29
- ".": {
30
- "types": "./index.d.ts",
31
- "import": "./index.js"
32
- },
33
- "./commitlint": "./commitlint.config.cjs",
34
- "./lint-staged": "./lint-staged.config.cjs",
35
- "./package.json": "./package.json"
36
- },
37
- "files": [
38
- "src",
39
- "index.js",
40
- "index.d.ts",
41
- "commitlint.config.cjs",
42
- "lint-staged.config.cjs",
43
- "README.md"
44
- ],
45
- "dependencies": {
46
- "@commitlint/cli": "^21.2.1",
47
- "@commitlint/config-conventional": "^21.2.0",
48
- "@semantic-release/commit-analyzer": "^13.0.1",
49
- "@semantic-release/exec": "^7.1.0",
50
- "@semantic-release/git": "^11.0.1",
51
- "@semantic-release/github": "^12.0.9",
52
- "@semantic-release/npm": "^13.1.5",
53
- "@semantic-release/release-notes-generator": "^14.1.0",
54
- "@textmode/lint": "^0.1.0",
55
- "lint-staged": "^17.0.8",
56
- "semantic-release": "^25.0.5"
57
- },
58
- "devDependencies": {
59
- "@types/node": "^26.1.2",
60
- "typescript": "^6.0.3",
61
- "vitest": "^4.1.10"
62
- },
63
- "scripts": {
64
- "check": "pnpm run check:format && pnpm run lint && pnpm run check:types && pnpm run test && pnpm run check:package && pnpm run check:pack",
65
- "check:format": "prettier --check .",
66
- "check:package": "node scripts/check-package.mjs",
67
- "check:pack": "node scripts/pack-smoke.mjs",
68
- "check:types": "tsc --noEmit --strict --module NodeNext --moduleResolution NodeNext --target ES2022 test/types/consumer.ts",
69
- "lint": "node --check src/cli/textmode-release.mjs && node --check src/internal/*.mjs && node --check src/lib/*.js",
70
- "test": "vitest run"
71
- },
72
- "publishConfig": {
73
- "access": "public"
74
- }
75
- }
2
+ "name": "@textmode/release",
3
+ "version": "0.3.0",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "description": "Shared release and Git-hook tooling for the textmode.js ecosystem (semantic-release, commitlint, lint-staged).",
7
+ "keywords": [
8
+ "textmode",
9
+ "semantic-release",
10
+ "commitlint",
11
+ "lint-staged",
12
+ "git-hooks",
13
+ "release"
14
+ ],
15
+ "author": "humanbydefinition <hello@textmode.art> (https://code.textmode.art)",
16
+ "homepage": "https://code.textmode.art",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/textmode-art/tooling.git",
20
+ "directory": "packages/release"
21
+ },
22
+ "engines": {
23
+ "node": "^24.15.0 || >=26.0.0"
24
+ },
25
+ "bin": {
26
+ "textmode-release": "dist/cli/textmode-release.js"
27
+ },
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/index.d.ts",
31
+ "import": "./dist/index.js"
32
+ },
33
+ "./commitlint": "./commitlint.config.cjs",
34
+ "./lint-staged": "./lint-staged.config.cjs",
35
+ "./package.json": "./package.json"
36
+ },
37
+ "files": [
38
+ "dist",
39
+ "commitlint.config.cjs",
40
+ "lint-staged.config.cjs",
41
+ "README.md"
42
+ ],
43
+ "dependencies": {
44
+ "@commitlint/cli": "^21.2.4",
45
+ "@commitlint/config-conventional": "^21.2.4",
46
+ "@semantic-release/commit-analyzer": "^13.0.1",
47
+ "@semantic-release/exec": "^7.1.0",
48
+ "@semantic-release/git": "^11.0.1",
49
+ "@semantic-release/github": "^12.0.10",
50
+ "@semantic-release/npm": "^13.2.0",
51
+ "@semantic-release/release-notes-generator": "^14.1.0",
52
+ "lint-staged": "^17.6.0",
53
+ "semantic-release": "^25.0.9",
54
+ "@textmode/lint": "^0.2.0"
55
+ },
56
+ "devDependencies": {
57
+ "@types/node": "^24.0.0",
58
+ "typescript": "^6.0.3",
59
+ "vitest": "^5.1.0"
60
+ },
61
+ "publishConfig": {
62
+ "access": "public"
63
+ },
64
+ "scripts": {
65
+ "build": "tsc -b",
66
+ "test": "vitest run"
67
+ }
68
+ }
package/index.d.ts DELETED
@@ -1,31 +0,0 @@
1
- export interface ReleaseBranch {
2
- name: string;
3
- prerelease?: boolean | string;
4
- channel?: string;
5
- range?: string;
6
- }
7
-
8
- export interface ReleaseConfig {
9
- branches: (string | ReleaseBranch)[];
10
- tagFormat: string;
11
- plugins: unknown[];
12
- dryRun: boolean;
13
- ci: boolean;
14
- }
15
-
16
- export type GitHubReleaseMode = 'draft' | 'direct';
17
-
18
- export interface ReleaseConfigOptions {
19
- githubAssets?: string[];
20
- githubRelease?: GitHubReleaseMode;
21
- }
22
-
23
- export declare function githubAssetsFromPackageJson(packageJson: { exports?: unknown }): string[];
24
-
25
- export declare function createReleaseConfig(options?: ReleaseConfigOptions): ReleaseConfig;
26
-
27
- export declare const releaseConfig: ReleaseConfig;
28
-
29
- export declare const commitlintConfig: Record<string, unknown>;
30
-
31
- export declare const lintStagedConfig: Record<string, unknown>;
package/index.js DELETED
@@ -1,7 +0,0 @@
1
- export {
2
- createReleaseConfig,
3
- githubAssetsFromPackageJson,
4
- default as releaseConfig,
5
- } from './src/lib/release-config.js';
6
- export { commitlintConfig } from './src/lib/commitlint-config.js';
7
- export { lintStagedConfig } from './src/lib/lint-staged.js';
@@ -1,139 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import fs from 'node:fs';
4
- import path from 'node:path';
5
- import process from 'node:process';
6
- import { fileURLToPath } from 'node:url';
7
-
8
- import { runEngine } from '../internal/engines.mjs';
9
- import { installGitHooks } from '../internal/hooks.mjs';
10
-
11
- const PACKAGE_JSON = JSON.parse(fs.readFileSync(new URL('../../package.json', import.meta.url), 'utf8'));
12
- const PACKAGE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..');
13
-
14
- const COMMANDS = new Set(['release', 'hooks', 'format-staged']);
15
-
16
- function printGeneralHelp() {
17
- console.log(`@textmode/release ${PACKAGE_JSON.version}`);
18
- console.log('');
19
- console.log('Usage: textmode-release <command> [options]');
20
- console.log('');
21
- console.log('Commands:');
22
- console.log(' release [args...] Run semantic-release with the shared config');
23
- console.log(' hooks Install managed Git hooks (commitlint, lint-staged, push guard)');
24
- console.log(' format-staged [files...] Format staged files with the shared Prettier config (internal)');
25
- console.log('');
26
- console.log('Common options:');
27
- console.log(' --cwd <directory> Directory to run in');
28
- console.log(' --help, -h Show help');
29
- console.log(' --version, -v Show version');
30
- console.log('');
31
- console.log('Every argument after the release command is forwarded to semantic-release.');
32
- }
33
-
34
- function printCommandHelp(command) {
35
- const usage = {
36
- release: 'textmode-release release [args...]',
37
- hooks: 'textmode-release hooks',
38
- 'format-staged': 'textmode-release format-staged [files...]',
39
- };
40
- console.log(`Usage: ${usage[command]}`);
41
- }
42
-
43
- function parseArgv(argv) {
44
- const values = { cwd: undefined, help: false, version: false };
45
- const rest = [];
46
- let commandSeen = false;
47
-
48
- for (let index = 0; index < argv.length; index += 1) {
49
- const arg = argv[index];
50
- if (arg === '--cwd') {
51
- if (index + 1 >= argv.length || argv[index + 1].startsWith('-')) {
52
- throw new Error('--cwd requires a directory value.');
53
- }
54
- values.cwd = argv[index + 1];
55
- index += 1;
56
- continue;
57
- }
58
- if (!commandSeen) {
59
- if (arg === '--help' || arg === '-h') {
60
- values.help = true;
61
- continue;
62
- }
63
- if (arg === '--version' || arg === '-v') {
64
- values.version = true;
65
- continue;
66
- }
67
- if (!arg.startsWith('-')) {
68
- commandSeen = true;
69
- }
70
- }
71
- rest.push(arg);
72
- }
73
-
74
- const [command, ...forwarded] = rest;
75
- if (command !== undefined && !COMMANDS.has(command)) {
76
- throw new Error(`Unknown command "${command}".`);
77
- }
78
- if (command !== 'release' && command !== 'format-staged' && forwarded.length > 0) {
79
- throw new Error(`The ${command} command does not accept arguments.`);
80
- }
81
-
82
- return { command, forwarded, values };
83
- }
84
-
85
- function runRelease(forwarded, cwd) {
86
- const releaseConfig = path.join(PACKAGE_ROOT, 'src', 'lib', 'release-config.js');
87
- return runEngine('semantic-release', 'semantic-release', ['--extends', releaseConfig, ...forwarded], { cwd });
88
- }
89
-
90
- function runFormatStaged(files, cwd) {
91
- if (files.length === 0) {
92
- console.error('format-staged requires at least one staged file.');
93
- return 2;
94
- }
95
- return runEngine('@textmode/lint', 'textmode-lint', ['format', ...files], { cwd });
96
- }
97
-
98
- function main(argv) {
99
- let parsed;
100
- try {
101
- parsed = parseArgv(argv);
102
- } catch (error) {
103
- console.error(error instanceof Error ? error.message : String(error));
104
- return 2;
105
- }
106
-
107
- const { command, forwarded, values } = parsed;
108
- const cwd = values.cwd ? path.resolve(values.cwd) : process.cwd();
109
-
110
- if (values.version && command === undefined) {
111
- console.log(PACKAGE_JSON.version);
112
- return 0;
113
- }
114
- if (values.help && command === undefined) {
115
- printGeneralHelp();
116
- return 0;
117
- }
118
- if (command === undefined) {
119
- console.error('Missing command. Run textmode-release --help for usage.');
120
- return 2;
121
- }
122
- if (values.help) {
123
- printCommandHelp(command);
124
- return 0;
125
- }
126
-
127
- switch (command) {
128
- case 'release':
129
- return runRelease(forwarded, cwd);
130
- case 'hooks':
131
- return installGitHooks({ cwd }) === false ? 1 : 0;
132
- case 'format-staged':
133
- return runFormatStaged(forwarded, cwd);
134
- default:
135
- return 2;
136
- }
137
- }
138
-
139
- process.exitCode = main(process.argv.slice(2));
@@ -1,6 +0,0 @@
1
- branch="$(git rev-parse --abbrev-ref HEAD)"
2
-
3
- if [ "$branch" = "dev" ] || [ "$branch" = "beta" ] || [ "$branch" = "main" ]; then
4
- echo "Direct pushes to '$branch' are not allowed. Open a pull request to dev, then promote dev -> beta -> main."
5
- exit 1
6
- fi