@acryldev/blends 1.7.11 → 1.7.12

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acryldev/blends",
3
- "version": "1.7.11",
3
+ "version": "1.7.12",
4
4
  "description": "The Acryl web framework (import { Acryl } from \"acrylblends\") and the acrylblends command that scaffolds Cordis apps.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -407,7 +407,8 @@
407
407
  "templates",
408
408
  "shared",
409
409
  "plugins",
410
- "docs"
410
+ "docs",
411
+ "pack"
411
412
  ],
412
413
  "engines": {
413
414
  "node": ">=22.19.0"
@@ -2,9 +2,7 @@
2
2
  "name": "save",
3
3
  "description": "Save the app to its own git repository, and share it: a repository of its own on GitHub, created and pushed only after a person confirms the plan. Refuses a file that holds a secret, and a private app going to a public remote.",
4
4
  "requires": [],
5
- "inject": [
6
- "appInstance"
7
- ],
5
+ "inject": ["appInstance"],
8
6
  "provides": [],
9
7
  "dependencies": {
10
8
  "@deepseek-ai/cordis": "4.0.4",
@@ -11,8 +11,8 @@ import {
11
11
  type AppIdentity,
12
12
  type CatalogCategory,
13
13
  connectRemote,
14
- type GitPort,
15
14
  GITHUB_VIA_GH,
15
+ type GitPort,
16
16
  gitCli,
17
17
  githubHosting,
18
18
  type HostingPort,
@@ -82,7 +82,11 @@ export interface ShareOptions {
82
82
  /** Who may see a new repository; blend.yaml's metadata.visibility when absent. A share with it records it there, so later saves agree. */
83
83
  readonly visibility?: Visibility
84
84
  /** List it in the Blends store. Any part not given is taken from the app: its earlier listing, else its starter's category; licence MIT. */
85
- readonly list?: { readonly category?: string; readonly subcategory?: string; readonly license?: string }
85
+ readonly list?: {
86
+ readonly category?: string
87
+ readonly subcategory?: string
88
+ readonly license?: string
89
+ }
86
90
  /** The published category list (acrylblends.github.io/categories.json), to check the place against; unchecked when absent. */
87
91
  readonly categories?: readonly CatalogCategory[]
88
92
  }
@@ -119,12 +123,21 @@ export function sharePorts(appRoot: string): SharePorts {
119
123
  list: (repository, tag) => {
120
124
  const must = (command: string, args: readonly string[], what: string) => {
121
125
  const result = run(command, args)
122
- if (result.status !== 0) throw new PersistenceError(`${what}: ${(result.stderr || result.stdout).trim()}`)
126
+ if (result.status !== 0)
127
+ throw new PersistenceError(`${what}: ${(result.stderr || result.stdout).trim()}`)
123
128
  }
124
- must('gh', ['repo', 'edit', repository, '--add-topic', BLEND_TOPIC], 'could not label the repository for the Blends store')
129
+ must(
130
+ 'gh',
131
+ ['repo', 'edit', repository, '--add-topic', BLEND_TOPIC],
132
+ 'could not label the repository for the Blends store',
133
+ )
125
134
  if (run('git', ['rev-parse', '-q', '--verify', `refs/tags/${tag}`]).status === 0) return false
126
135
  must('git', ['tag', tag], `could not tag ${tag}`)
127
- must('git', [...GITHUB_VIA_GH, 'push', '--quiet', 'origin', `refs/tags/${tag}`], `could not push ${tag}`)
136
+ must(
137
+ 'git',
138
+ [...GITHUB_VIA_GH, 'push', '--quiet', 'origin', `refs/tags/${tag}`],
139
+ `could not push ${tag}`,
140
+ )
128
141
  return true
129
142
  },
130
143
  }
@@ -145,10 +158,23 @@ const repositoryName = (name: string): string =>
145
158
  export const githubRepository = (remote: string): string | undefined =>
146
159
  /github\.com[/:]([^/]+\/[^/]+?)(?:\.git)?\/?$/u.exec(remote)?.[1]
147
160
 
148
- const INSTALL_SCRIPTS = ['preinstall', 'install', 'postinstall', 'prepublish', 'preprepare', 'prepare', 'postprepare']
161
+ const INSTALL_SCRIPTS = [
162
+ 'preinstall',
163
+ 'install',
164
+ 'postinstall',
165
+ 'prepublish',
166
+ 'preprepare',
167
+ 'prepare',
168
+ 'postprepare',
169
+ ]
149
170
  const LICENSE_ID = /^[A-Za-z0-9][A-Za-z0-9.+-]*$/u
150
171
 
151
- interface PackageJson { version?: unknown; keywords?: unknown; scripts?: Record<string, unknown>; [key: string]: unknown }
172
+ interface PackageJson {
173
+ version?: unknown
174
+ keywords?: unknown
175
+ scripts?: Record<string, unknown>
176
+ [key: string]: unknown
177
+ }
152
178
  const packageOf = (appRoot: string): PackageJson | undefined => {
153
179
  try {
154
180
  return JSON.parse(readFileSync(join(appRoot, 'package.json'), 'utf8')) as PackageJson
@@ -158,26 +184,48 @@ const packageOf = (appRoot: string): PackageJson | undefined => {
158
184
  }
159
185
 
160
186
  /** The store listing a share asked for, as the person will read it, or why it cannot be listed. */
161
- function planListing(appRoot: string, identity: AppIdentity, visibility: Visibility, repository: string | undefined, options: ShareOptions): StoreListing | ShareRefused | undefined {
187
+ function planListing(
188
+ appRoot: string,
189
+ identity: AppIdentity,
190
+ visibility: Visibility,
191
+ repository: string | undefined,
192
+ options: ShareOptions,
193
+ ): StoreListing | ShareRefused | undefined {
162
194
  const asked = options.list
163
195
  if (asked === undefined) return undefined
164
- if (visibility !== 'public') return refused('only a public app can be listed in the Blends store: choose public')
165
- if (repository === undefined) return refused('only an app on GitHub can be listed in the Blends store')
166
- if (identity.description === undefined) return refused('the store lists an app with its description: add one to blend.yaml (metadata.description)')
196
+ if (visibility !== 'public')
197
+ return refused('only a public app can be listed in the Blends store: choose public')
198
+ if (repository === undefined)
199
+ return refused('only an app on GitHub can be listed in the Blends store')
200
+ if (identity.description === undefined)
201
+ return refused(
202
+ 'the store lists an app with its description: add one to blend.yaml (metadata.description)',
203
+ )
167
204
  const pkg = packageOf(appRoot)
168
205
  if (pkg === undefined) return refused('the app has no readable package.json')
169
- const script = INSTALL_SCRIPTS.find(name => typeof pkg.scripts?.[name] === 'string')
170
- if (script !== undefined) return refused(`package.json defines the install script "${script}", which a listed app may not`)
206
+ const script = INSTALL_SCRIPTS.find((name) => typeof pkg.scripts?.[name] === 'string')
207
+ if (script !== undefined)
208
+ return refused(
209
+ `package.json defines the install script "${script}", which a listed app may not`,
210
+ )
171
211
  const categories = options.categories ?? []
172
- const placement: Placement | undefined = asked.category !== undefined
173
- ? { category: asked.category, ...(asked.subcategory === undefined ? {} : { subcategory: asked.subcategory }) }
174
- : placementOf(pkg.keywords) ?? suggestPlacement(identity.category, categories)
175
- if (placement === undefined) return refused('choose its category, one of acrylblends.github.io/blends (for example --category gaming)')
212
+ const placement: Placement | undefined =
213
+ asked.category !== undefined
214
+ ? {
215
+ category: asked.category,
216
+ ...(asked.subcategory === undefined ? {} : { subcategory: asked.subcategory }),
217
+ }
218
+ : (placementOf(pkg.keywords) ?? suggestPlacement(identity.category, categories))
219
+ if (placement === undefined)
220
+ return refused(
221
+ 'choose its category, one of acrylblends.github.io/blends (for example --category gaming)',
222
+ )
176
223
  const problem = categories.length > 0 ? placementProblem(placement, categories) : undefined
177
224
  if (problem !== undefined) return refused(problem)
178
225
  const license = asked.license ?? identity.license ?? 'MIT'
179
- if (!LICENSE_ID.test(license)) return refused(`"${license}" is not a licence id (such as MIT or Apache-2.0)`)
180
- const version = typeof pkg.version === 'string' ? pkg.version : identity.version ?? '0.1.0'
226
+ if (!LICENSE_ID.test(license))
227
+ return refused(`"${license}" is not a licence id (such as MIT or Apache-2.0)`)
228
+ const version = typeof pkg.version === 'string' ? pkg.version : (identity.version ?? '0.1.0')
181
229
  const name = (identity.id ?? '').split('.').slice(1).join('.') || repository.split('/')[1] || ''
182
230
  const id = `${(repository.split('/')[0] ?? '').toLowerCase()}.${name.toLowerCase()}`
183
231
  return { id, placement, license, tag: `v${version}` }
@@ -210,20 +258,44 @@ SOFTWARE.
210
258
  * The files the store reads, written into the app before it is saved: the licence in blend.yaml (and an MIT LICENSE file when it has none),
211
259
  * the marker and placement keywords in package.json, and the acryl.template.json that lets people start an app from it. Returns blend.yaml's text.
212
260
  */
213
- function writeListing(appRoot: string, manifestText: string, listing: StoreListing, repository: string): string {
261
+ function writeListing(
262
+ appRoot: string,
263
+ manifestText: string,
264
+ listing: StoreListing,
265
+ repository: string,
266
+ ): string {
214
267
  const identity = readAppIdentity(manifestText)
215
268
  let text = manifestText
216
269
  if (identity.id !== listing.id) text = withId(text, listing.id)
217
270
  if (identity.license !== listing.license) text = withLicense(text, listing.license)
218
271
  if (text !== manifestText) writeFileSync(join(appRoot, 'blend.yaml'), text)
219
272
  const pkg = packageOf(appRoot) ?? {}
220
- const before = Array.isArray(pkg.keywords) ? pkg.keywords.filter((word): word is string => typeof word === 'string') : []
221
- const keywords = withPlacement(before.includes(BLEND_TOPIC) ? before : [...before, BLEND_TOPIC], listing.placement)
222
- if (JSON.stringify(keywords) !== JSON.stringify(pkg.keywords)) writeFileSync(join(appRoot, 'package.json'), `${JSON.stringify({ ...pkg, keywords }, null, 2)}\n`)
273
+ const before = Array.isArray(pkg.keywords)
274
+ ? pkg.keywords.filter((word): word is string => typeof word === 'string')
275
+ : []
276
+ const keywords = withPlacement(
277
+ before.includes(BLEND_TOPIC) ? before : [...before, BLEND_TOPIC],
278
+ listing.placement,
279
+ )
280
+ if (JSON.stringify(keywords) !== JSON.stringify(pkg.keywords))
281
+ writeFileSync(
282
+ join(appRoot, 'package.json'),
283
+ `${JSON.stringify({ ...pkg, keywords }, null, 2)}\n`,
284
+ )
223
285
  const template = join(appRoot, 'acryl.template.json')
224
- if (!existsSync(template)) writeFileSync(template, `${JSON.stringify({ name: identity.name ?? basename(appRoot), description: identity.description ?? '' }, null, 2)}\n`)
225
- if (listing.license === 'MIT' && !['LICENSE', 'LICENSE.md', 'LICENSE.txt'].some(file => existsSync(join(appRoot, file))))
226
- writeFileSync(join(appRoot, 'LICENSE'), MIT(new Date().getFullYear(), repository.split('/')[0] ?? ''))
286
+ if (!existsSync(template))
287
+ writeFileSync(
288
+ template,
289
+ `${JSON.stringify({ name: identity.name ?? basename(appRoot), description: identity.description ?? '' }, null, 2)}\n`,
290
+ )
291
+ if (
292
+ listing.license === 'MIT' &&
293
+ !['LICENSE', 'LICENSE.md', 'LICENSE.txt'].some((file) => existsSync(join(appRoot, file)))
294
+ )
295
+ writeFileSync(
296
+ join(appRoot, 'LICENSE'),
297
+ MIT(new Date().getFullYear(), repository.split('/')[0] ?? ''),
298
+ )
227
299
  return text
228
300
  }
229
301
 
@@ -235,12 +307,22 @@ export function planShare(
235
307
  ): SharePlan | ShareRefused {
236
308
  const plan = planRepository(appRoot, options, ports)
237
309
  if ('ok' in plan) return plan
238
- const listing = planListing(appRoot, readAppIdentity(manifestOf(appRoot)), plan.visibility, plan.create ? plan.repository : githubRepository(plan.repository), options)
310
+ const listing = planListing(
311
+ appRoot,
312
+ readAppIdentity(manifestOf(appRoot)),
313
+ plan.visibility,
314
+ plan.create ? plan.repository : githubRepository(plan.repository),
315
+ options,
316
+ )
239
317
  if (listing !== undefined && 'ok' in listing) return listing
240
318
  return listing === undefined ? plan : { ...plan, listing }
241
319
  }
242
320
 
243
- function planRepository(appRoot: string, options: ShareOptions, ports: SharePorts): SharePlan | ShareRefused {
321
+ function planRepository(
322
+ appRoot: string,
323
+ options: ShareOptions,
324
+ ports: SharePorts,
325
+ ): SharePlan | ShareRefused {
244
326
  const identity = readAppIdentity(manifestOf(appRoot))
245
327
  const visibility = options.visibility ?? identity.visibility
246
328
  const changes = ports.pending()
@@ -301,7 +383,8 @@ export function shareApp(
301
383
  }
302
384
  const repository = now.create ? now.repository : githubRepository(now.repository)
303
385
  try {
304
- if (now.listing !== undefined && repository !== undefined) manifestText = writeListing(appRoot, manifestText, now.listing, repository)
386
+ if (now.listing !== undefined && repository !== undefined)
387
+ manifestText = writeListing(appRoot, manifestText, now.listing, repository)
305
388
  let remote = now.repository
306
389
  if (now.create) {
307
390
  const connected = connectRemote(
@@ -321,9 +404,10 @@ export function shareApp(
321
404
  }
322
405
  // Nothing new to save: the versions already saved still have to reach the remote.
323
406
  if (saved.status === 'nothing-to-save') ports.git.push()
324
- const listed = now.listing !== undefined && repository !== undefined
325
- ? { tag: now.listing.tag, created: ports.list(repository, now.listing.tag) }
326
- : undefined
407
+ const listed =
408
+ now.listing !== undefined && repository !== undefined
409
+ ? { tag: now.listing.tag, created: ports.list(repository, now.listing.tag) }
410
+ : undefined
327
411
  return {
328
412
  ok: true,
329
413
  remote,
@@ -346,11 +430,14 @@ export function renderSharePlan(plan: SharePlan): string {
346
430
  plan.changes === 0
347
431
  ? 'the versions saved so far'
348
432
  : `${String(plan.changes)} changed ${plan.changes === 1 ? 'file' : 'files'}, saved first, and the versions saved so far`
349
- const listed = plan.listing === undefined
350
- ? ''
351
- : ` Listed in the Blends store as ${plan.listing.id}, Community, under ${placementWords(plan.listing.placement)} (licence ${plan.listing.license}, people start from ${plan.listing.tag}).`
433
+ const listed =
434
+ plan.listing === undefined
435
+ ? ''
436
+ : ` Listed in the Blends store as ${plan.listing.id}, Community, under ${placementWords(plan.listing.placement)} (licence ${plan.listing.license}, people start from ${plan.listing.tag}).`
352
437
  return `Share this app to ${where}: ${what}.${listed}`
353
438
  }
354
439
 
355
440
  const placementWords = (placement: Placement): string =>
356
- placement.subcategory === undefined ? placement.category : `${placement.category} › ${placement.subcategory}`
441
+ placement.subcategory === undefined
442
+ ? placement.category
443
+ : `${placement.category} › ${placement.subcategory}`