@lucaismyname/create-l1-stack 0.1.5 → 0.1.7

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +21 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lucaismyname/create-l1-stack",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
package/src/index.js CHANGED
@@ -863,14 +863,27 @@ async function applyTesting(targetDir) {
863
863
 
864
864
  const tsconfigAppPath = path.join(targetDir, 'tsconfig.app.json')
865
865
  try {
866
- const tsconfig = await fse.readJson(tsconfigAppPath)
867
- tsconfig.compilerOptions ??= {}
868
- const existingTypes = Array.isArray(tsconfig.compilerOptions.types)
869
- ? tsconfig.compilerOptions.types
870
- : ['vite/client']
871
- if (!existingTypes.includes('vitest/globals')) existingTypes.push('vitest/globals')
872
- tsconfig.compilerOptions.types = existingTypes
873
- await fse.writeJson(tsconfigAppPath, tsconfig, { spaces: 2 })
866
+ const src = await fs.readFile(tsconfigAppPath, 'utf8')
867
+ let next = src
868
+
869
+ // tsconfig.app.json is JSONC (comments), so patch it as text.
870
+ // Ensure vitest globals are available for test/expect typing.
871
+ if (!next.includes('vitest/globals')) {
872
+ next = next.replace(
873
+ /"types"\s*:\s*\[\s*"vite\/client"\s*\]/m,
874
+ '"types": ["vite/client", "vitest/globals"]'
875
+ )
876
+ }
877
+
878
+ // Ensure tests are not part of the build typecheck.
879
+ if (!/\"exclude\"\s*:/m.test(next)) {
880
+ next = next.replace(
881
+ /\n\}\s*\n?$/m,
882
+ `,\n "exclude": [\n "src/**/*.{test,spec}.ts",\n "src/**/*.{test,spec}.tsx",\n "src/test/**"\n ]\n}\n`
883
+ )
884
+ }
885
+
886
+ if (next !== src) await fs.writeFile(tsconfigAppPath, next, 'utf8')
874
887
  } catch {
875
888
  // ignore
876
889
  }