@ggdna/dna-gg 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -5
- package/dna/_dna.json +8 -3
- package/dna/_generated.json +4 -64
- package/dna/dot-github/workflows/quick_check.yaml +2 -2
- package/dna/scripts/delete-feature-branch.js +97 -0
- package/dna/scripts/functions/colors.js +27 -0
- package/dna/scripts/functions/run-command.js +22 -0
- package/package.json +7 -9
package/README.md
CHANGED
|
@@ -27,14 +27,25 @@ publish.
|
|
|
27
27
|
- `dna/dot-github/workflows/quick_check.yaml` — the quick check pipeline
|
|
28
28
|
every pull request has to pass
|
|
29
29
|
|
|
30
|
+
## Scripts
|
|
31
|
+
|
|
32
|
+
- `dna/scripts/delete-feature-branch.js` — the one script this layer calls
|
|
33
|
+
itself, from `/cleanup`, with the two functions it imports:
|
|
34
|
+
`dna/scripts/functions/colors.js` and
|
|
35
|
+
`dna/scripts/functions/run-command.js`
|
|
36
|
+
|
|
37
|
+
These three files are byte-identical copies of their originals in
|
|
38
|
+
[dna_scripts](https://github.com/ggdna/dna_scripts). They are duplicated
|
|
39
|
+
on purpose so that this layer does not drag the whole script set into
|
|
40
|
+
every repo that only wants the gg workflow. A repo that wants the full
|
|
41
|
+
set lists `dna_scripts` as a layer of its own — the copies are identical,
|
|
42
|
+
so both layers together produce exactly the same files.
|
|
43
|
+
|
|
30
44
|
## Layers
|
|
31
45
|
|
|
32
46
|
Builds on [dna_install](https://github.com/ggdna/dna_install) for the
|
|
33
|
-
install overview
|
|
34
|
-
repo index every gg repo keeps
|
|
35
|
-
[dna_scripts](https://github.com/ggdna/dna_scripts) for
|
|
36
|
-
`setup-github-repo.js`, `rename-class.js`, `wait-for-pr.js` and
|
|
37
|
-
`delete-feature-branch.js`, which the guides above call.
|
|
47
|
+
install overview and [dna_index](https://github.com/ggdna/dna_index) for
|
|
48
|
+
the repo index every gg repo keeps.
|
|
38
49
|
|
|
39
50
|
It extends the `@tooling` section of the install overview through
|
|
40
51
|
`dna/doc/guides/install-guide.overrides.md`: it adds `Install gg` and
|
package/dna/_dna.json
CHANGED
|
@@ -5,7 +5,12 @@
|
|
|
5
5
|
|
|
6
6
|
// The parent DNAs. dna_install brings the install overview this layer
|
|
7
7
|
// extends with the gg install guides, dna_index the index conventions
|
|
8
|
-
// every gg repo follows
|
|
9
|
-
//
|
|
10
|
-
|
|
8
|
+
// every gg repo follows. Parents first, this layer wins.
|
|
9
|
+
//
|
|
10
|
+
// dna_scripts is deliberately not a parent: this layer calls exactly one
|
|
11
|
+
// of its scripts — `delete-feature-branch.js` from the /cleanup skill —
|
|
12
|
+
// and carries its own copy of it under dna/scripts/ instead. A consumer
|
|
13
|
+
// that wants the full script set lists dna_scripts itself; the copies
|
|
14
|
+
// here are byte-identical, so having both layers changes nothing.
|
|
15
|
+
"layers": ["dna_install", "dna_index"]
|
|
11
16
|
}
|
package/dna/_generated.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"name": "base",
|
|
6
6
|
"package": "helix",
|
|
7
7
|
"ecosystem": null,
|
|
8
|
-
"resolvedVersion": "1.
|
|
8
|
+
"resolvedVersion": "1.3.1",
|
|
9
9
|
"via": null,
|
|
10
10
|
"hash": "0x705e486e88a93125"
|
|
11
11
|
},
|
|
@@ -25,27 +25,19 @@
|
|
|
25
25
|
"via": null,
|
|
26
26
|
"hash": "0x1d92b0add37a1ac7"
|
|
27
27
|
},
|
|
28
|
-
{
|
|
29
|
-
"name": "dna-scripts",
|
|
30
|
-
"package": "@ggdna/dna-scripts",
|
|
31
|
-
"ecosystem": "node",
|
|
32
|
-
"resolvedVersion": "0.1.0",
|
|
33
|
-
"via": null,
|
|
34
|
-
"hash": "0x9ee08ef13ab4c8d3"
|
|
35
|
-
},
|
|
36
28
|
{
|
|
37
29
|
"name": "self",
|
|
38
30
|
"package": null,
|
|
39
31
|
"ecosystem": null,
|
|
40
32
|
"resolvedVersion": null,
|
|
41
33
|
"via": null,
|
|
42
|
-
"hash": "
|
|
34
|
+
"hash": "0x97c559b0151610d4"
|
|
43
35
|
}
|
|
44
36
|
],
|
|
45
37
|
"claude": {
|
|
46
38
|
"claudeMdInclude": null
|
|
47
39
|
},
|
|
48
|
-
"baseVersion": "1.
|
|
40
|
+
"baseVersion": "1.3.1",
|
|
49
41
|
"baseHash": "0x705e486e88a93125",
|
|
50
42
|
"instances": [
|
|
51
43
|
{
|
|
@@ -72,17 +64,13 @@
|
|
|
72
64
|
"path": ".claude/skills/push/SKILL.md",
|
|
73
65
|
"hash": "0x76c357ca9933317d"
|
|
74
66
|
},
|
|
75
|
-
{
|
|
76
|
-
"path": ".claude/skills/scripts/SKILL.md",
|
|
77
|
-
"hash": "0xa12593aa0af31ed2"
|
|
78
|
-
},
|
|
79
67
|
{
|
|
80
68
|
"path": ".claude/skills/ticket/SKILL.md",
|
|
81
69
|
"hash": "0xbc13efe6fa9af962"
|
|
82
70
|
},
|
|
83
71
|
{
|
|
84
72
|
"path": ".github/workflows/quick_check.yaml",
|
|
85
|
-
"hash": "
|
|
73
|
+
"hash": "0xf3320fb8f530a565"
|
|
86
74
|
},
|
|
87
75
|
{
|
|
88
76
|
"path": "doc/guides/develop-guide.md",
|
|
@@ -148,10 +136,6 @@
|
|
|
148
136
|
"path": "doc/guides/install-guide/install-vscode-guide.md",
|
|
149
137
|
"hash": "0xa0da6a6877bb94c2"
|
|
150
138
|
},
|
|
151
|
-
{
|
|
152
|
-
"path": "doc/guides/scripts-guide.md",
|
|
153
|
-
"hash": "0x426857c389049083"
|
|
154
|
-
},
|
|
155
139
|
{
|
|
156
140
|
"path": "doc/hello_world.md",
|
|
157
141
|
"hash": "0x0903f7fc5224f6f1"
|
|
@@ -168,53 +152,9 @@
|
|
|
168
152
|
"path": "scripts/functions/colors.js",
|
|
169
153
|
"hash": "0xdfd97f3804665811"
|
|
170
154
|
},
|
|
171
|
-
{
|
|
172
|
-
"path": "scripts/functions/current-branch.js",
|
|
173
|
-
"hash": "0xb9ebbadf45893278"
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
"path": "scripts/functions/directories.js",
|
|
177
|
-
"hash": "0x148d4ebb8aa75523"
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
"path": "scripts/functions/get-repo-urls.js",
|
|
181
|
-
"hash": "0x4c7b3897973acec3"
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
"path": "scripts/functions/get-version.js",
|
|
185
|
-
"hash": "0xfe46316558755cf2"
|
|
186
|
-
},
|
|
187
|
-
{
|
|
188
|
-
"path": "scripts/functions/is-clean-repo.js",
|
|
189
|
-
"hash": "0x8aa95ca51d9d6517"
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
"path": "scripts/functions/is-main-up-to-date.js",
|
|
193
|
-
"hash": "0xe1ab1826d0ddd039"
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
"path": "scripts/functions/pull-request-url.js",
|
|
197
|
-
"hash": "0x5398755a61a59928"
|
|
198
|
-
},
|
|
199
155
|
{
|
|
200
156
|
"path": "scripts/functions/run-command.js",
|
|
201
157
|
"hash": "0x085b390fcb9256ab"
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
"path": "scripts/functions/sync-folders.js",
|
|
205
|
-
"hash": "0x4f83165fd92ec49d"
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
"path": "scripts/rename-class.js",
|
|
209
|
-
"hash": "0xa9daec4f3ea514b7"
|
|
210
|
-
},
|
|
211
|
-
{
|
|
212
|
-
"path": "scripts/setup-github-repo.js",
|
|
213
|
-
"hash": "0x5907588070a580ca"
|
|
214
|
-
},
|
|
215
|
-
{
|
|
216
|
-
"path": "scripts/wait-for-pr.js",
|
|
217
|
-
"hash": "0x1360c661984b78a8"
|
|
218
158
|
}
|
|
219
159
|
]
|
|
220
160
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Runs the gg
|
|
1
|
+
# Runs the gg quick check on every push and pull request against main.
|
|
2
2
|
|
|
3
3
|
name: Tests
|
|
4
4
|
|
|
@@ -17,4 +17,4 @@ jobs:
|
|
|
17
17
|
- uses: actions/checkout@v5
|
|
18
18
|
|
|
19
19
|
# Uses the Node.js preinstalled on the runner image.
|
|
20
|
-
- run: npx @tssuite/
|
|
20
|
+
- run: npx @tssuite/ggwsm one did commit
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) dnaCopyrightHolder
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by terms that can be
|
|
6
|
+
* found in the LICENSE file in the root of this package.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { gray, green, red, yellow } from './functions/colors.js';
|
|
10
|
+
import { runCommand } from './functions/run-command.js';
|
|
11
|
+
|
|
12
|
+
// Check for uncommitted changes
|
|
13
|
+
function hasUncommittedChanges() {
|
|
14
|
+
console.log(gray('Check for uncommitted changes'));
|
|
15
|
+
const status = runCommand('git status --porcelain');
|
|
16
|
+
return status.length > 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Check for unpushed commits
|
|
20
|
+
function hasUnpushedCommits(branch) {
|
|
21
|
+
try {
|
|
22
|
+
console.log(gray('Check for unpushed commits'));
|
|
23
|
+
runCommand(`git rev-parse --abbrev-ref ${branch}@{u}`);
|
|
24
|
+
const ahead = runCommand(`git rev-list --count ${branch}@{u}..${branch}`);
|
|
25
|
+
return parseInt(ahead, 10) > 0;
|
|
26
|
+
} catch {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Try a test merge into main and check if it introduces changes
|
|
32
|
+
function isBranchEffectivelyMerged(featureBranch) {
|
|
33
|
+
console.log(gray('Check if feature was fully merged'));
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
runCommand(`git merge --no-commit --no-ff ${featureBranch}`);
|
|
37
|
+
const changed = hasUncommittedChanges();
|
|
38
|
+
runCommand('git merge --abort');
|
|
39
|
+
return !changed;
|
|
40
|
+
} catch {
|
|
41
|
+
try {
|
|
42
|
+
runCommand('git merge --abort');
|
|
43
|
+
} catch {}
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
console.log(gray('Get current branch name'));
|
|
50
|
+
const currentBranch = runCommand('git rev-parse --abbrev-ref HEAD');
|
|
51
|
+
|
|
52
|
+
if (currentBranch === 'main') {
|
|
53
|
+
console.log(yellow('Please call this script from a feature branch.'));
|
|
54
|
+
process.exit(0);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (hasUncommittedChanges()) {
|
|
58
|
+
console.error(red('❌ You have uncommitted changes.'));
|
|
59
|
+
console.error(
|
|
60
|
+
yellow('Please commit or stash your changes before continuing.'),
|
|
61
|
+
);
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (hasUnpushedCommits(currentBranch)) {
|
|
66
|
+
console.error(red('❌ You have unpushed commits.'));
|
|
67
|
+
console.error(yellow('Please push your branch before continuing.'));
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
console.log(gray(`Fetching and pulling 'main'...`));
|
|
72
|
+
runCommand('git fetch');
|
|
73
|
+
runCommand('git checkout main');
|
|
74
|
+
runCommand('git pull origin main');
|
|
75
|
+
|
|
76
|
+
const isMerged = isBranchEffectivelyMerged(currentBranch);
|
|
77
|
+
|
|
78
|
+
if (isMerged) {
|
|
79
|
+
runCommand(`git branch -d ${currentBranch}`);
|
|
80
|
+
console.log(green(`✅ Branch '${currentBranch}' has been deleted.`));
|
|
81
|
+
} else {
|
|
82
|
+
console.error(
|
|
83
|
+
red(`❌ Branch '${currentBranch}' is not merged into 'main'.`),
|
|
84
|
+
);
|
|
85
|
+
console.log(
|
|
86
|
+
yellow(`Please (create and) merge a pull request and try again.`),
|
|
87
|
+
);
|
|
88
|
+
runCommand(`git checkout ${currentBranch}`);
|
|
89
|
+
console.log(gray(`Switched back to '${currentBranch}'.`));
|
|
90
|
+
}
|
|
91
|
+
} catch (error) {
|
|
92
|
+
console.error(red(`Error: ${error.message}`));
|
|
93
|
+
try {
|
|
94
|
+
runCommand('git merge --abort');
|
|
95
|
+
} catch {}
|
|
96
|
+
process.exit(1);
|
|
97
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) dnaCopyrightHolder
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by terms that can be
|
|
6
|
+
* found in the LICENSE file in the root of this package.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export const red = (str) => `\x1b[31m${str}\x1b[0m`;
|
|
10
|
+
export const green = (str) => `\x1b[32m${str}\x1b[0m`;
|
|
11
|
+
export const yellow = (str) => `\x1b[33m${str}\x1b[0m`;
|
|
12
|
+
export const blue = (str) => `\x1b[34m${str}\x1b[0m`;
|
|
13
|
+
export const magenta = (str) => `\x1b[35m${str}\x1b[0m`;
|
|
14
|
+
export const cyan = (str) => `\x1b[36m${str}\x1b[0m`;
|
|
15
|
+
export const white = (str) => `\x1b[37m${str}\x1b[0m`;
|
|
16
|
+
export const black = (str) => `\x1b[30m${str}\x1b[0m`;
|
|
17
|
+
export const bgRed = (str) => `\x1b[41m${str}\x1b[0m`;
|
|
18
|
+
export const bgGreen = (str) => `\x1b[42m${str}\x1b[0m`;
|
|
19
|
+
export const bgYellow = (str) => `\x1b[43m${str}\x1b[0m`;
|
|
20
|
+
export const bgBlue = (str) => `\x1b[44m${str}\x1b[0m`;
|
|
21
|
+
export const bgMagenta = (str) => `\x1b[45m${str}\x1b[0m`;
|
|
22
|
+
export const bgCyan = (str) => `\x1b[46m${str}\x1b[0m`;
|
|
23
|
+
export const bgWhite = (str) => `\x1b[47m${str}\x1b[0m`;
|
|
24
|
+
export const bgBlack = (str) => `\x1b[40m${str}\x1b[0m`;
|
|
25
|
+
export const gray = (str) => `\x1b[90m${str}\x1b[0m`;
|
|
26
|
+
export const lightGray = (str) => `\x1b[37m${str}\x1b[0m`;
|
|
27
|
+
export const reset = (str) => `\x1b[0m${str}\x1b[0m`;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) dnaCopyrightHolder
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by terms that can be
|
|
6
|
+
* found in the LICENSE file in the root of this package.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { execSync } from 'child_process';
|
|
10
|
+
import { gray } from './colors.js';
|
|
11
|
+
|
|
12
|
+
// Execute a shell command and return trimmed output
|
|
13
|
+
// Execute a shell command and return trimmed output
|
|
14
|
+
export function runCommand(command, silent = true, logCommand = true) {
|
|
15
|
+
if (logCommand) {
|
|
16
|
+
console.log(gray(`${command}`));
|
|
17
|
+
}
|
|
18
|
+
return execSync(command, {
|
|
19
|
+
encoding: 'utf-8',
|
|
20
|
+
stdio: silent ? ['pipe', 'pipe', 'pipe'] : undefined,
|
|
21
|
+
}).trim();
|
|
22
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ggdna/dna-gg",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "DNA layer: gg CLI workflow guides, repo setup scripts and CI check",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dna",
|
|
@@ -29,18 +29,16 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@ggdna/dna-index": "^0.1.0",
|
|
32
|
-
"@ggdna/dna-install": "^0.1.0"
|
|
33
|
-
|
|
32
|
+
"@ggdna/dna-install": "^0.1.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/node": "^26.4.1",
|
|
36
|
+
"prettier": "^3.9.6"
|
|
34
37
|
},
|
|
35
38
|
"scripts": {
|
|
36
39
|
"test:dart": "dart test",
|
|
37
40
|
"test": "pnpm run test:dart",
|
|
38
|
-
"prepublishOnly": "pnpm run test",
|
|
39
41
|
"format": "prettier --write .",
|
|
40
42
|
"format:check": "prettier --check ."
|
|
41
|
-
},
|
|
42
|
-
"devDependencies": {
|
|
43
|
-
"@types/node": "^26.2.0",
|
|
44
|
-
"prettier": "^3.9.6"
|
|
45
43
|
}
|
|
46
|
-
}
|
|
44
|
+
}
|