@shivaedev/create-app 0.23.0 → 0.25.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/src/template.ts CHANGED
@@ -8,24 +8,28 @@ export type Template = typeof Template.Type;
8
8
  export const decodeTemplate = Schema.decodeUnknownSync(Schema.fromJsonString(Template));
9
9
 
10
10
  export function appTemplate(template: Template, minimal = false): Template {
11
+ const minimalManifest = template.find((entry) => entry.path === "package.minimal.json");
11
12
  const minimalBaseline = template.find((entry) => entry.path === "quality-baseline.minimal.jsonl");
12
- const files = template.filter((entry) => entry.path !== "quality-baseline.minimal.jsonl");
13
+ const files = template.filter((entry) => !["quality-baseline.minimal.jsonl", "package.minimal.json"].includes(entry.path));
13
14
  if (!minimal) {
14
15
  return files;
15
16
  }
16
17
  return files
17
18
  .filter((entry) => !entry.path.startsWith("src/modules/notes/"))
18
19
  .map((entry) => {
20
+ if (entry.path === "package.json" && minimalManifest !== undefined) {
21
+ return { ...entry, content: minimalManifest.content };
22
+ }
19
23
  if (entry.path === "quality-baseline.jsonl" && minimalBaseline !== undefined) {
20
24
  return { ...entry, content: minimalBaseline.content };
21
25
  }
22
- if (!["src/server/modules.ts", "src/server/workerModules.ts", "src/client/modules.ts"].includes(entry.path)) {
26
+ if (!["src/modules.ts", "src/server/modules.ts", "src/server/workerModules.ts", "src/client/modules.ts"].includes(entry.path)) {
23
27
  return entry;
24
28
  }
25
29
  const source = Buffer.from(entry.content, "base64")
26
30
  .toString()
27
31
  .replace(/^import .* from "#modules\/notes\/.*";\n/gmu, "")
28
- .replace(/,?\s*\b(?:notesRegistration|notesWorker)\b/gu, "");
32
+ .replace(/,?\s*\b(?:noteQueue|notesModule|notesRegistration|notesWorker)\b/gu, "");
29
33
  return { ...entry, content: Buffer.from(source).toString("base64") };
30
34
  });
31
35
  }
@@ -42,7 +46,7 @@ const Manifest = Schema.Struct({
42
46
  type: Schema.String,
43
47
  version: Schema.String,
44
48
  });
45
- const decodeManifest = Schema.decodeUnknownSync(Schema.fromJsonString(Manifest));
49
+ export const decodeManifest = Schema.decodeUnknownSync(Schema.fromJsonString(Manifest));
46
50
  // Decoding does not keep input key order, so the generated manifest lists its fields in package.json order.
47
51
  const manifestOrder = [
48
52
  "name",
@@ -57,6 +61,10 @@ const manifestOrder = [
57
61
  "engines",
58
62
  ] as const satisfies ReadonlyArray<keyof typeof Manifest.Type>;
59
63
 
64
+ export function manifestJson(manifest: typeof Manifest.Type) {
65
+ return `${JSON.stringify(Object.fromEntries(manifestOrder.map((key) => [key, manifest[key]])), null, "\t")}\n`;
66
+ }
67
+
60
68
  export function registryDependencies(dependencies: Readonly<Record<string, string>>, versions: Readonly<Record<string, string>>) {
61
69
  return Object.fromEntries(
62
70
  Object.entries(dependencies).map(([name, version]) => {
@@ -72,16 +80,19 @@ export function registryDependencies(dependencies: Readonly<Record<string, strin
72
80
  );
73
81
  }
74
82
 
75
- export function prepareManifest(source: string, versions: Readonly<Record<string, string>>) {
83
+ export function prepareManifest(source: string, versions: Readonly<Record<string, string>>, minimal = false) {
76
84
  const manifest = decodeManifest(source);
77
85
  const { "check:published": _check, ...scripts } = manifest.scripts;
78
86
  const prepared = {
79
87
  ...manifest,
80
- dependencies: registryDependencies(manifest.dependencies, versions),
88
+ dependencies: registryDependencies(
89
+ Object.fromEntries(Object.entries(manifest.dependencies).filter(([name]) => !minimal || name !== "@tanstack/react-table")),
90
+ versions,
91
+ ),
81
92
  devDependencies: registryDependencies(manifest.devDependencies, versions),
82
93
  scripts: Object.fromEntries(Object.entries(scripts).map(([name, script]) => [name, script.replaceAll("--conditions=source ", "")])),
83
94
  };
84
- return `${JSON.stringify(Object.fromEntries(manifestOrder.map((key) => [key, prepared[key]])), null, "\t")}\n`;
95
+ return manifestJson(prepared);
85
96
  }
86
97
 
87
98
  export function prepareFile(path: string, content: Buffer, versions: Readonly<Record<string, string>>) {
@@ -92,7 +103,7 @@ export function prepareFile(path: string, content: Buffer, versions: Readonly<Re
92
103
  return Buffer.from(prepareManifest(content.toString(), versions));
93
104
  }
94
105
  if (["tsconfig.json", "vite.config.ts", "vitest.config.ts", "src/server/dev.ts"].includes(path)) {
95
- return Buffer.from(content.toString().replaceAll('"source", ', "").replaceAll('["source"]', "[]"));
106
+ return Buffer.from(content.toString().replaceAll('["source"]', "[]"));
96
107
  }
97
108
  return content;
98
109
  }