@karmaniverous/smoz 0.2.1 → 0.2.3
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/dist/cli/index.cjs +54 -2
- package/package.json +2 -3
- package/templates/default/app/config/openapi.ts +1 -1
- package/templates/default/package.json +4 -1
- package/templates/default/tsconfig.downstream.json +18 -0
- package/templates/default/tsconfig.eslint.json +1 -11
- package/templates/default/tsconfig.json +17 -7
package/dist/cli/index.cjs
CHANGED
|
@@ -850,6 +850,10 @@ const copyDirWithConflicts = async (srcDir, dstRoot, created, skipped, examples,
|
|
|
850
850
|
let sticky;
|
|
851
851
|
for (const abs of files) {
|
|
852
852
|
const rel = path.relative(srcDir, abs);
|
|
853
|
+
if (opts.exclude && opts.exclude(rel)) {
|
|
854
|
+
// Skip dev-only or excluded files silently.
|
|
855
|
+
continue;
|
|
856
|
+
}
|
|
853
857
|
const dest = path.resolve(dstRoot, rel);
|
|
854
858
|
const data = await fs.promises.readFile(abs, 'utf8');
|
|
855
859
|
if (!fs.existsSync(dest)) {
|
|
@@ -1047,6 +1051,24 @@ const seedRegisterPlaceholders = async (root) => {
|
|
|
1047
1051
|
};
|
|
1048
1052
|
|
|
1049
1053
|
const toPosixSep = (p) => p.split(path.sep).join('/');
|
|
1054
|
+
// Exclude dev-only type stubs (not meant for downstream apps).
|
|
1055
|
+
const excludeDev = (rel) => {
|
|
1056
|
+
const posixRel = rel.replace(/\\/g, '/');
|
|
1057
|
+
return /\/types\/[^/]*\.dev\.d\.ts$/i.test(posixRel);
|
|
1058
|
+
};
|
|
1059
|
+
const excludeTemplate = (rel) => {
|
|
1060
|
+
const posixRel = rel.replace(/\\/g, '/');
|
|
1061
|
+
// Do not copy the template's dev tsconfig; downstream apps use
|
|
1062
|
+
// tsconfig.downstream.json (renamed to tsconfig.json) instead.
|
|
1063
|
+
if (posixRel === 'tsconfig.json')
|
|
1064
|
+
return true;
|
|
1065
|
+
// Do not copy the template's package.json; we always handle the manifest
|
|
1066
|
+
// via an additive merge (create when missing, never overwrite existing keys).
|
|
1067
|
+
// Copying would only trigger a scary/irrelevant conflict prompt.
|
|
1068
|
+
if (posixRel === 'package.json')
|
|
1069
|
+
return true;
|
|
1070
|
+
return excludeDev(rel);
|
|
1071
|
+
};
|
|
1050
1072
|
const runInit = async (root, template = 'default', opts) => {
|
|
1051
1073
|
const created = [];
|
|
1052
1074
|
const skipped = [];
|
|
@@ -1077,7 +1099,10 @@ const runInit = async (root, template = 'default', opts) => {
|
|
|
1077
1099
|
const copyOpts = rl
|
|
1078
1100
|
? { conflict: policy, rl }
|
|
1079
1101
|
: { conflict: policy };
|
|
1080
|
-
await copyDirWithConflicts(projectBase, root, created, skipped, examples,
|
|
1102
|
+
await copyDirWithConflicts(projectBase, root, created, skipped, examples, {
|
|
1103
|
+
...copyOpts,
|
|
1104
|
+
exclude: excludeDev,
|
|
1105
|
+
});
|
|
1081
1106
|
rl?.close();
|
|
1082
1107
|
}
|
|
1083
1108
|
// 2) Copy selected template
|
|
@@ -1094,7 +1119,10 @@ const runInit = async (root, template = 'default', opts) => {
|
|
|
1094
1119
|
const copyOpts = rl
|
|
1095
1120
|
? { conflict: policy, rl }
|
|
1096
1121
|
: { conflict: policy };
|
|
1097
|
-
await copyDirWithConflicts(srcBase, root, created, skipped, examples,
|
|
1122
|
+
await copyDirWithConflicts(srcBase, root, created, skipped, examples, {
|
|
1123
|
+
...copyOpts,
|
|
1124
|
+
exclude: excludeTemplate,
|
|
1125
|
+
});
|
|
1098
1126
|
rl?.close();
|
|
1099
1127
|
}
|
|
1100
1128
|
// 2.5) Convert template 'gitignore' into a real '.gitignore'
|
|
@@ -1120,6 +1148,30 @@ const runInit = async (root, template = 'default', opts) => {
|
|
|
1120
1148
|
catch {
|
|
1121
1149
|
// best-effort
|
|
1122
1150
|
}
|
|
1151
|
+
// 2.6) Convert 'tsconfig.downstream.json' into 'tsconfig.json'
|
|
1152
|
+
try {
|
|
1153
|
+
const ds = path.join(root, 'tsconfig.downstream.json');
|
|
1154
|
+
const dst = path.join(root, 'tsconfig.json');
|
|
1155
|
+
if (fs.existsSync(ds)) {
|
|
1156
|
+
if (!fs.existsSync(dst)) {
|
|
1157
|
+
await fs.promises.rename(ds, dst);
|
|
1158
|
+
created.push(path.posix.normalize(dst));
|
|
1159
|
+
}
|
|
1160
|
+
else {
|
|
1161
|
+
// If a tsconfig already exists, write an example and remove the source
|
|
1162
|
+
const example = path.join(root, 'tsconfig.json.example');
|
|
1163
|
+
if (!fs.existsSync(example)) {
|
|
1164
|
+
const data = await fs.promises.readFile(ds, 'utf8');
|
|
1165
|
+
await fs.promises.writeFile(example, data, 'utf8');
|
|
1166
|
+
examples.push(path.posix.normalize(example));
|
|
1167
|
+
}
|
|
1168
|
+
await fs.promises.rm(ds, { force: true });
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
catch {
|
|
1173
|
+
// best-effort
|
|
1174
|
+
}
|
|
1123
1175
|
// Seed app/generated/register.* placeholders
|
|
1124
1176
|
{
|
|
1125
1177
|
const res = await seedRegisterPlaceholders(root);
|
package/package.json
CHANGED
|
@@ -174,13 +174,12 @@
|
|
|
174
174
|
"release:pre": "dotenvx run -f .env.local -- release-it --no-git.requireBranch --github.prerelease --preRelease",
|
|
175
175
|
"remove": "serverless remove",
|
|
176
176
|
"smoz": "tsx src/cli/index.ts",
|
|
177
|
-
"stan:build": "rimraf stan.dist && rollup --config stan.rollup.config.ts --configPlugin @rollup/plugin-typescript && rimraf stan.dist",
|
|
178
177
|
"stan:docs": "typedoc --emit none",
|
|
179
178
|
"test": "vitest run",
|
|
180
179
|
"typecheck": "tsx src/cli/index.ts register && tsc -p tsconfig.json --noEmit",
|
|
181
180
|
"templates:typecheck": "tsx scripts/templates-typecheck.ts",
|
|
182
|
-
"templates:lint": "eslint --fix -c templates/default/eslint.config.ts \"templates/default/**/*.{ts,tsx,js,jsx}\"
|
|
181
|
+
"templates:lint": "eslint --fix -c templates/default/eslint.config.ts \"templates/default/**/*.{ts,tsx,js,jsx}\" \"templates/default/eslint.config.ts\""
|
|
183
182
|
},
|
|
184
183
|
"type": "module",
|
|
185
|
-
"version": "0.2.
|
|
184
|
+
"version": "0.2.3"
|
|
186
185
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as path from 'node:path';
|
|
2
2
|
|
|
3
3
|
import * as fs from 'fs-extra';
|
|
4
|
-
import { packageDirectorySync } from '
|
|
4
|
+
import { packageDirectorySync } from 'package-directory';
|
|
5
5
|
import { createDocument } from 'zod-openapi';
|
|
6
6
|
|
|
7
7
|
import { app } from '@/app/config/app.config';
|
|
@@ -5,10 +5,13 @@
|
|
|
5
5
|
"version": "0.0.0",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@middy/core": "^6.4.5",
|
|
8
|
-
"zod": "^4.1.6"
|
|
8
|
+
"zod": "^4.1.6",
|
|
9
|
+
"fs-extra": "^11.3.1",
|
|
10
|
+
"package-directory": "^8.1.0"
|
|
9
11
|
},
|
|
10
12
|
"devDependencies": {
|
|
11
13
|
"@serverless/typescript": "^4.18.2",
|
|
14
|
+
"@types/fs-extra": "^11.0.4",
|
|
12
15
|
"@types/node": "^22",
|
|
13
16
|
"eslint": "^9.35.0",
|
|
14
17
|
"eslint-config-prettier": "^10.1.8",
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"baseUrl": ".",
|
|
4
|
+
"outDir": ".tsbuild",
|
|
5
|
+
"paths": {
|
|
6
|
+
"@/*": ["*"]
|
|
7
|
+
},
|
|
8
|
+
"tsBuildInfoFile": ".tsbuild/tsconfig.tsbuildinfo"
|
|
9
|
+
},
|
|
10
|
+
"exclude": [
|
|
11
|
+
".serverless/**",
|
|
12
|
+
"node_modules/**",
|
|
13
|
+
"app/generated/**",
|
|
14
|
+
"dist/**"
|
|
15
|
+
],
|
|
16
|
+
"extends": "./tsconfig.base.json",
|
|
17
|
+
"include": ["**/*", "**/*.json"]
|
|
18
|
+
}
|
|
@@ -3,14 +3,24 @@
|
|
|
3
3
|
"baseUrl": ".",
|
|
4
4
|
"outDir": ".tsbuild",
|
|
5
5
|
"paths": {
|
|
6
|
-
"@/*": ["*"]
|
|
6
|
+
"@/*": ["*"],
|
|
7
|
+
"@karmaniverous/smoz": [
|
|
8
|
+
"../../dist/index",
|
|
9
|
+
"../../dist/index.d.ts"
|
|
10
|
+
]
|
|
7
11
|
},
|
|
12
|
+
"typeRoots": [
|
|
13
|
+
"./types",
|
|
14
|
+
"../../node_modules/@types"
|
|
15
|
+
],
|
|
8
16
|
"tsBuildInfoFile": ".tsbuild/tsconfig.tsbuildinfo"
|
|
9
17
|
},
|
|
10
|
-
"exclude": [
|
|
18
|
+
"exclude": [
|
|
19
|
+
".serverless/**",
|
|
20
|
+
"node_modules/**",
|
|
21
|
+
"app/generated/**",
|
|
22
|
+
"dist/**"
|
|
23
|
+
],
|
|
11
24
|
"extends": "./tsconfig.base.json",
|
|
12
|
-
"include": [
|
|
13
|
-
|
|
14
|
-
"**/*.json"
|
|
15
|
-
]
|
|
16
|
-
}
|
|
25
|
+
"include": ["**/*", "**/*.json"]
|
|
26
|
+
}
|