@percepta/create 3.1.4 → 3.1.5

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.
@@ -1,144 +0,0 @@
1
- import {
2
- getFileAtTag
3
- } from "./chunk-DCM7JOSC.js";
4
- import {
5
- readManifest,
6
- resolveMosaicTemplatePath
7
- } from "./chunk-V5EJIUBJ.js";
8
-
9
- // src/commands/upstream.ts
10
- import path from "path";
11
- import fs from "fs-extra";
12
- import chalk from "chalk";
13
- async function generateUpstreamContext(manifest, mosaicTemplatePath, tag, appDir, files) {
14
- let content = `# Mosaic Upstream Context
15
-
16
- ## App Info
17
- - **App name:** ${manifest.placeholders.__APP_NAME__ || "unknown"}
18
- - **Template:** ${manifest.templateType}
19
- - **Template version:** ${manifest.templateVersion}
20
-
21
- ## Placeholder Mappings
22
-
23
- When generalizing app code back to template, replace these values with placeholder tokens:
24
-
25
- | Value | Placeholder |
26
- |-------|------------|
27
- ${Object.entries(manifest.placeholders).sort((a, b) => b[1].length - a[1].length).map(([k, v]) => `| \`${v}\` | \`${k}\` |`).join("\n")}
28
-
29
- ## Files to Review
30
-
31
- `;
32
- for (const file of files) {
33
- const appFilePath = path.resolve(appDir, file);
34
- const templateRelPath = `${manifest.source.templatePath}/${file}`;
35
- const appContent = await fs.pathExists(appFilePath) ? await fs.readFile(appFilePath, "utf-8") : null;
36
- const templateContent = getFileAtTag(
37
- mosaicTemplatePath,
38
- tag,
39
- templateRelPath
40
- );
41
- content += `### ${file}
42
-
43
- `;
44
- if (!templateContent && appContent) {
45
- content += `**New file** (not in template at ${manifest.templateVersion})
46
-
47
- `;
48
- content += `\`\`\`
49
- ${appContent}
50
- \`\`\`
51
-
52
- `;
53
- } else if (templateContent && !appContent) {
54
- content += `**Deleted** (exists in template but not in app)
55
-
56
- `;
57
- } else if (appContent && templateContent) {
58
- content += `**App version:**
59
- \`\`\`
60
- ${appContent}
61
- \`\`\`
62
-
63
- `;
64
- content += `**Template version (at ${manifest.templateVersion}):**
65
- \`\`\`
66
- ${templateContent}
67
- \`\`\`
68
-
69
- `;
70
- } else {
71
- content += `**Not found** (file does not exist in app or template)
72
-
73
- `;
74
- }
75
- }
76
- content += `## Instructions
77
-
78
- 1. Review each file above
79
- 2. Determine which changes are generalizable (useful for all apps) vs app-specific
80
- 3. For generalizable changes: apply them to the template at \`${manifest.source.templatePath}/\`
81
- 4. When applying, replace app-specific values with placeholders using the mapping table above (replace longest values first)
82
- 5. After applying, bump the version in \`packages/create-mosaic-module/template-versions.json\`
83
- 6. Run \`pnpm template:tag\` to create the new version tag
84
- 7. Delete this file (\`.mosaic-upstream-context.md\`) when done
85
- `;
86
- return content;
87
- }
88
- async function upstreamCommand(options) {
89
- const cwd = process.cwd();
90
- try {
91
- const manifest = await readManifest(cwd);
92
- const mosaicTemplatePath = resolveMosaicTemplatePath(options);
93
- if (!options.files || options.files.length === 0) {
94
- console.error(
95
- chalk.red("Specify files with --files <file1> <file2> ...")
96
- );
97
- console.log(
98
- chalk.dim(
99
- " Example: create upstream --files src/config/getEnvConfig.ts"
100
- )
101
- );
102
- process.exit(1);
103
- }
104
- const tag = `template/${manifest.templateType}/${manifest.templateVersion}`;
105
- const context = await generateUpstreamContext(
106
- manifest,
107
- mosaicTemplatePath,
108
- tag,
109
- cwd,
110
- options.files
111
- );
112
- const contextPath = path.join(cwd, ".mosaic-upstream-context.md");
113
- await fs.writeFile(contextPath, context);
114
- console.log();
115
- console.log(chalk.bold("Upstream Context Generated"));
116
- console.log();
117
- console.log(chalk.dim(" Files:"), options.files.join(", "));
118
- console.log(
119
- chalk.dim(" Context file:"),
120
- ".mosaic-upstream-context.md"
121
- );
122
- console.log();
123
- console.log("Next steps:");
124
- console.log(
125
- chalk.dim(" 1."),
126
- "Open Claude Code in the mosaic repo"
127
- );
128
- console.log(
129
- chalk.dim(" 2."),
130
- `Tell Claude: "Read ${path.resolve(cwd, ".mosaic-upstream-context.md")} and apply generalizable changes to the template"`
131
- );
132
- console.log(
133
- chalk.dim(" 3."),
134
- "Review Claude's changes to the template"
135
- );
136
- console.log();
137
- } catch (error) {
138
- console.error(chalk.red(error.message));
139
- process.exit(1);
140
- }
141
- }
142
- export {
143
- upstreamCommand
144
- };