create-ncblock 0.0.32 → 0.0.33
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/package.json
CHANGED
|
@@ -190,6 +190,27 @@ function copyDirectoryContents(
|
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
+
function applyTemplateReplacements(
|
|
194
|
+
contents: string,
|
|
195
|
+
replacements: Record<string, string>,
|
|
196
|
+
): string {
|
|
197
|
+
let replaced = contents
|
|
198
|
+
for (const [placeholder, value] of Object.entries(replacements)) {
|
|
199
|
+
replaced = replaced.replaceAll(placeholder, value)
|
|
200
|
+
}
|
|
201
|
+
return replaced
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function writeRenderedFile(args: {
|
|
205
|
+
sourcePath: string
|
|
206
|
+
targetPath: string
|
|
207
|
+
replacements: Record<string, string>
|
|
208
|
+
}) {
|
|
209
|
+
const { sourcePath, targetPath, replacements } = args
|
|
210
|
+
const contents = readFileSync(sourcePath, "utf-8")
|
|
211
|
+
writeFileSync(targetPath, applyTemplateReplacements(contents, replacements))
|
|
212
|
+
}
|
|
213
|
+
|
|
193
214
|
export function scaffoldTemplate({
|
|
194
215
|
root,
|
|
195
216
|
templateDir,
|
|
@@ -198,6 +219,12 @@ export function scaffoldTemplate({
|
|
|
198
219
|
overwrite = false,
|
|
199
220
|
sdkDep,
|
|
200
221
|
}: ScaffoldTemplateOptions) {
|
|
222
|
+
const replacements = { "{{name}}": name }
|
|
223
|
+
const appEntrySource = resolve(templateDir, "src/index.tsx")
|
|
224
|
+
const appEntryTarget = resolve(dest, "src/index.tsx")
|
|
225
|
+
const shouldRenderAppEntry =
|
|
226
|
+
existsSync(appEntrySource) && (overwrite || !existsSync(appEntryTarget))
|
|
227
|
+
|
|
201
228
|
copyDirectoryContents(templateDir, dest, {
|
|
202
229
|
overwrite,
|
|
203
230
|
// README.md and package.json are rendered below with the app name and
|
|
@@ -209,6 +236,14 @@ export function scaffoldTemplate({
|
|
|
209
236
|
]),
|
|
210
237
|
})
|
|
211
238
|
|
|
239
|
+
if (shouldRenderAppEntry) {
|
|
240
|
+
writeRenderedFile({
|
|
241
|
+
sourcePath: appEntrySource,
|
|
242
|
+
targetPath: appEntryTarget,
|
|
243
|
+
replacements,
|
|
244
|
+
})
|
|
245
|
+
}
|
|
246
|
+
|
|
212
247
|
// Scaffolded projects are standalone, not workspace members. If the user
|
|
213
248
|
// scaffolds inside an existing pnpm workspace (e.g. this repo), pnpm walks
|
|
214
249
|
// up, finds the workspace root, and the install ends up partial. A local
|
|
@@ -221,15 +256,21 @@ export function scaffoldTemplate({
|
|
|
221
256
|
|
|
222
257
|
const readmeTarget = resolve(dest, "README.md")
|
|
223
258
|
if (overwrite || !existsSync(readmeTarget)) {
|
|
224
|
-
|
|
225
|
-
|
|
259
|
+
writeRenderedFile({
|
|
260
|
+
sourcePath: resolve(templateDir, "README.md"),
|
|
261
|
+
targetPath: readmeTarget,
|
|
262
|
+
replacements,
|
|
263
|
+
})
|
|
226
264
|
}
|
|
227
265
|
|
|
228
266
|
const agentsTarget = resolve(dest, "AGENTS.md")
|
|
229
267
|
if (overwrite || !existsSync(agentsTarget)) {
|
|
230
268
|
const agentsSource = resolve(root, "scripts/scaffold-assets/AGENTS.md")
|
|
231
|
-
|
|
232
|
-
|
|
269
|
+
writeRenderedFile({
|
|
270
|
+
sourcePath: agentsSource,
|
|
271
|
+
targetPath: agentsTarget,
|
|
272
|
+
replacements,
|
|
273
|
+
})
|
|
233
274
|
}
|
|
234
275
|
|
|
235
276
|
const pkgPath = resolve(dest, "package.json")
|
package/sdk-version.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.0.
|
|
1
|
+
{"version":"0.0.31"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
color-scheme: light dark;
|
|
3
|
+
--background: #ffffff;
|
|
4
|
+
--foreground: #1f1f1f;
|
|
5
|
+
--muted: #5f5e5b;
|
|
6
|
+
--border: #e6e6e6;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
@media (prefers-color-scheme: dark) {
|
|
10
|
+
:root {
|
|
11
|
+
--background: #191919;
|
|
12
|
+
--foreground: #f1f1ef;
|
|
13
|
+
--muted: #b7b6b2;
|
|
14
|
+
--border: #3f3f3c;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
body {
|
|
19
|
+
background: var(--background);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
main {
|
|
23
|
+
box-sizing: border-box;
|
|
24
|
+
padding: 8px 24px;
|
|
25
|
+
border: 1px solid var(--border);
|
|
26
|
+
border-radius: 12px;
|
|
27
|
+
color: var(--foreground);
|
|
28
|
+
background: var(--background);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
p {
|
|
32
|
+
color: var(--muted);
|
|
33
|
+
}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { NotionCustomBlock } from "ncblock"
|
|
2
2
|
import ReactDOM from "react-dom/client"
|
|
3
|
+
import "./index.css"
|
|
3
4
|
|
|
4
5
|
function App() {
|
|
5
|
-
return
|
|
6
|
+
return (
|
|
7
|
+
<main>
|
|
8
|
+
<h3>{"{{name}}"}</h3>
|
|
9
|
+
<p>
|
|
10
|
+
Edit <code>src/index.tsx</code> and then deploy using <code>ntn</code>
|
|
11
|
+
</p>
|
|
12
|
+
</main>
|
|
13
|
+
)
|
|
6
14
|
}
|
|
7
15
|
|
|
8
16
|
ReactDOM.createRoot(document.getElementById("root")!).render(
|