@nakedev/go-scaffold 0.1.3 → 0.1.4
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 +18 -14
- package/dist/commands/generate.js +2 -1
- package/dist/commands/method.js +63 -15
- package/dist/commands/remove.js +23 -24
- package/dist/index.js +5 -4
- package/dist/templates/module-manifest.js +2 -0
- package/dist/utils/method-patcher.js +80 -16
- package/dist/utils/module-location.js +22 -0
- package/dist/utils/naming.js +75 -12
- package/dist/utils/openapi-patcher.js +19 -1
- package/dist/utils/smoke-run.js +31 -0
- package/package.json +14 -5
- package/scripts/smoke-test.mjs +2058 -0
- package/templates/create/base/.github/workflows/ci.yml.hbs +18 -5
- package/templates/create/base/AGENTS.md.hbs +10 -12
- package/templates/create/base/Makefile.hbs +9 -3
- package/templates/create/base/README.md.hbs +18 -6
- package/templates/create/features/docs/openapi.yaml.hbs +4 -5
- package/templates/create/features/docs/patterns.md.hbs +9 -6
- package/templates/generate/module/docs/item.yaml.hbs +3 -3
- package/templates/generate/module/handler.go.hbs +18 -4
- package/templates/generate/module/handler_test.go.hbs +81 -62
- package/templates/generate/module/migration.down.sql.hbs +1 -1
- package/templates/generate/module/migration.up.sql.hbs +1 -1
- package/templates/generate/module/minimal/handler.go.hbs +8 -2
- package/templates/generate/module/minimal/handler_test.go.hbs +5 -112
- package/templates/generate/module/minimal/service_test.go.hbs +39 -16
- package/templates/generate/module/model/model.go.hbs +7 -0
- package/templates/generate/module/repository_test.go.hbs +79 -0
- package/templates/generate/module/service.go.hbs +6 -4
- package/templates/generate/module/service_test.go.hbs +68 -17
- package/tests/integration/default-module.test.mjs +46 -0
- package/tests/integration/generator-naming.test.mjs +81 -0
- package/tests/integration/generator-unit-test-seams.test.mjs +91 -0
- package/tests/integration/legacy-method-compat.test.mjs +222 -0
- package/tests/integration/remove-module.test.mjs +58 -0
- package/tests/unit/naming.test.mjs +94 -0
- package/tests/unit/smoke-isolation.test.mjs +35 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSmokeRunConfig = createSmokeRunConfig;
|
|
4
|
+
const POSTGRES_HOST = "127.0.0.1";
|
|
5
|
+
function assertPort(port, label) {
|
|
6
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
|
7
|
+
throw new Error(`invalid smoke-test ${label}: ${port}`);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function createSmokeRunConfig(runID, port, dbPort = 5432) {
|
|
11
|
+
assertPort(port, "port");
|
|
12
|
+
assertPort(dbPort, "PostgreSQL port");
|
|
13
|
+
const normalizedRunID = runID.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
14
|
+
if (!normalizedRunID) {
|
|
15
|
+
throw new Error("smoke-test run ID must contain at least one letter or digit");
|
|
16
|
+
}
|
|
17
|
+
const dbName = `go_scaffold_smoke_${normalizedRunID}`;
|
|
18
|
+
return {
|
|
19
|
+
runID: normalizedRunID,
|
|
20
|
+
dbName,
|
|
21
|
+
dbHost: POSTGRES_HOST,
|
|
22
|
+
dbPort,
|
|
23
|
+
dbDsn: `postgres://postgres:postgres@${POSTGRES_HOST}:${dbPort}/${dbName}?sslmode=disable`,
|
|
24
|
+
port,
|
|
25
|
+
baseURL: `http://127.0.0.1:${port}`,
|
|
26
|
+
logPrefix: `go-scaffold-smoke-${normalizedRunID}`,
|
|
27
|
+
ownerToken: `go-scaffold-smoke-${normalizedRunID}`,
|
|
28
|
+
dockerLabel: `go-scaffold.smoke.owner=go-scaffold-smoke-${normalizedRunID}`,
|
|
29
|
+
containerNamePrefix: `go-scaffold-smoke-${normalizedRunID}`,
|
|
30
|
+
};
|
|
31
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nakedev/go-scaffold",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Scaffold Gin + GORM + Postgres Go backend projects with a consistent domain-module standard",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,14 +12,21 @@
|
|
|
12
12
|
"files": [
|
|
13
13
|
"dist",
|
|
14
14
|
"templates",
|
|
15
|
-
"bin"
|
|
15
|
+
"bin",
|
|
16
|
+
"scripts",
|
|
17
|
+
"tests"
|
|
16
18
|
],
|
|
17
19
|
"type": "commonjs",
|
|
20
|
+
"packageManager": "pnpm@11.0.7",
|
|
18
21
|
"scripts": {
|
|
19
22
|
"build": "tsc",
|
|
20
23
|
"dev": "tsc --watch",
|
|
21
|
-
"test": "
|
|
24
|
+
"test": "pnpm run test:unit && pnpm run test:integration && pnpm run test:smoke",
|
|
25
|
+
"test:unit": "node --test tests/unit/*.test.mjs",
|
|
26
|
+
"test:integration": "node --test tests/integration/*.test.mjs",
|
|
27
|
+
"test:smoke": "node scripts/smoke-test.mjs",
|
|
22
28
|
"verify": "pnpm run build && pnpm run test",
|
|
29
|
+
"prepack": "pnpm run build",
|
|
23
30
|
"prepublishOnly": "pnpm run verify"
|
|
24
31
|
},
|
|
25
32
|
"keywords": [
|
|
@@ -40,14 +47,16 @@
|
|
|
40
47
|
"commander": "^15.0.0",
|
|
41
48
|
"fs-extra": "^11.3.0",
|
|
42
49
|
"handlebars": "^4.7.8",
|
|
43
|
-
"picocolors": "^1.1.1"
|
|
50
|
+
"picocolors": "^1.1.1",
|
|
51
|
+
"pluralize": "^8.0.0"
|
|
44
52
|
},
|
|
45
53
|
"devDependencies": {
|
|
46
54
|
"@types/fs-extra": "^11.0.4",
|
|
47
55
|
"@types/node": "^24.0.0",
|
|
56
|
+
"@types/pluralize": "^0.0.33",
|
|
48
57
|
"typescript": "^5.7.0"
|
|
49
58
|
},
|
|
50
59
|
"engines": {
|
|
51
|
-
"node": ">=
|
|
60
|
+
"node": ">=22.13"
|
|
52
61
|
}
|
|
53
62
|
}
|