@karmaniverous/smoz 0.2.1 → 0.2.2
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 +47 -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,17 @@ 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
|
+
if (posixRel === 'tsconfig.json')
|
|
1062
|
+
return true; // skip dev tsconfig from template
|
|
1063
|
+
return excludeDev(rel);
|
|
1064
|
+
};
|
|
1050
1065
|
const runInit = async (root, template = 'default', opts) => {
|
|
1051
1066
|
const created = [];
|
|
1052
1067
|
const skipped = [];
|
|
@@ -1077,7 +1092,10 @@ const runInit = async (root, template = 'default', opts) => {
|
|
|
1077
1092
|
const copyOpts = rl
|
|
1078
1093
|
? { conflict: policy, rl }
|
|
1079
1094
|
: { conflict: policy };
|
|
1080
|
-
await copyDirWithConflicts(projectBase, root, created, skipped, examples,
|
|
1095
|
+
await copyDirWithConflicts(projectBase, root, created, skipped, examples, {
|
|
1096
|
+
...copyOpts,
|
|
1097
|
+
exclude: excludeDev,
|
|
1098
|
+
});
|
|
1081
1099
|
rl?.close();
|
|
1082
1100
|
}
|
|
1083
1101
|
// 2) Copy selected template
|
|
@@ -1094,7 +1112,10 @@ const runInit = async (root, template = 'default', opts) => {
|
|
|
1094
1112
|
const copyOpts = rl
|
|
1095
1113
|
? { conflict: policy, rl }
|
|
1096
1114
|
: { conflict: policy };
|
|
1097
|
-
await copyDirWithConflicts(srcBase, root, created, skipped, examples,
|
|
1115
|
+
await copyDirWithConflicts(srcBase, root, created, skipped, examples, {
|
|
1116
|
+
...copyOpts,
|
|
1117
|
+
exclude: excludeTemplate,
|
|
1118
|
+
});
|
|
1098
1119
|
rl?.close();
|
|
1099
1120
|
}
|
|
1100
1121
|
// 2.5) Convert template 'gitignore' into a real '.gitignore'
|
|
@@ -1120,6 +1141,30 @@ const runInit = async (root, template = 'default', opts) => {
|
|
|
1120
1141
|
catch {
|
|
1121
1142
|
// best-effort
|
|
1122
1143
|
}
|
|
1144
|
+
// 2.6) Convert 'tsconfig.downstream.json' into 'tsconfig.json'
|
|
1145
|
+
try {
|
|
1146
|
+
const ds = path.join(root, 'tsconfig.downstream.json');
|
|
1147
|
+
const dst = path.join(root, 'tsconfig.json');
|
|
1148
|
+
if (fs.existsSync(ds)) {
|
|
1149
|
+
if (!fs.existsSync(dst)) {
|
|
1150
|
+
await fs.promises.rename(ds, dst);
|
|
1151
|
+
created.push(path.posix.normalize(dst));
|
|
1152
|
+
}
|
|
1153
|
+
else {
|
|
1154
|
+
// If a tsconfig already exists, write an example and remove the source
|
|
1155
|
+
const example = path.join(root, 'tsconfig.json.example');
|
|
1156
|
+
if (!fs.existsSync(example)) {
|
|
1157
|
+
const data = await fs.promises.readFile(ds, 'utf8');
|
|
1158
|
+
await fs.promises.writeFile(example, data, 'utf8');
|
|
1159
|
+
examples.push(path.posix.normalize(example));
|
|
1160
|
+
}
|
|
1161
|
+
await fs.promises.rm(ds, { force: true });
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
catch {
|
|
1166
|
+
// best-effort
|
|
1167
|
+
}
|
|
1123
1168
|
// Seed app/generated/register.* placeholders
|
|
1124
1169
|
{
|
|
1125
1170
|
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.2"
|
|
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
|
+
}
|