@acryldev/blends 1.7.29 → 1.7.30

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.
@@ -19,25 +19,38 @@ export function osVersion(packageVersion, blendVersion) {
19
19
  }
20
20
 
21
21
  /**
22
- * blend.yaml's text with `metadata.version` set to `version` (added under `metadata:` when missing), the rest of the text untouched. The packed copy
23
- * carries the version the OS shows, so the frame's top bar, the About window and Installed apps name the same one. Without a `metadata:` block the text
24
- * is returned as it is.
22
+ * blend.yaml's text with `metadata.<key>` set to `value` (added under `metadata:` when missing), the rest of the text untouched. Without a `metadata:`
23
+ * block the text is returned as it is.
25
24
  */
26
- export function withManifestVersion(text, version) {
25
+ function withMetadataField(text, key, value) {
27
26
  const lines = text.split('\n')
28
27
  const start = lines.findIndex((line) => /^metadata:\s*(#.*)?$/u.test(line))
29
28
  if (start === -1) return text
30
29
  let end = lines.findIndex((line, index) => index > start && /^\S/u.test(line))
31
30
  if (end === -1) end = lines.length
32
31
  const at = lines.findIndex(
33
- (line, index) => index > start && index < end && /^\s+version:/u.test(line),
32
+ (line, index) => index > start && index < end && new RegExp(`^\\s+${key}:`, 'u').test(line),
34
33
  )
35
34
  const indent =
36
35
  lines
37
36
  .slice(start + 1, end)
38
37
  .find((line) => /^\s+\S/u.test(line))
39
38
  ?.match(/^\s+/u)?.[0] ?? ' '
40
- if (at === -1) lines.splice(start + 1, 0, `${indent}version: ${version}`)
41
- else lines[at] = `${lines[at].match(/^\s+/u)[0]}version: ${version}`
39
+ if (at === -1) lines.splice(start + 1, 0, `${indent}${key}: ${value}`)
40
+ else lines[at] = `${lines[at].match(/^\s+/u)[0]}${key}: ${value}`
42
41
  return lines.join('\n')
43
42
  }
43
+
44
+ /**
45
+ * blend.yaml's text with `metadata.version` set to `version`. The packed copy carries the version the OS shows, so the frame's top bar, the About
46
+ * window and Installed apps name the same one.
47
+ */
48
+ export const withManifestVersion = (text, version) => withMetadataField(text, 'version', version)
49
+
50
+ /**
51
+ * blend.yaml's text with `metadata.name` set to the product's name, as a JSON string (a name may hold a colon or a quote). The packed copy is the
52
+ * scaffold's, named for its folder (`blend`); the instance names an app by this field, so the window's title, the About panel and the Dock say the
53
+ * product ("ACRYL Control Center").
54
+ */
55
+ export const withManifestName = (text, name) =>
56
+ withMetadataField(text, 'name', JSON.stringify(name))
@@ -35,7 +35,7 @@ import { fileURLToPath, pathToFileURL } from 'node:url'
35
35
  import { desktopEntry, launcherScript, tarballName } from './lib/arch-linux.mjs'
36
36
  import { createSource, repositoryOnlyIn } from './lib/create-source.mjs'
37
37
  import { DEB_DEPENDS, debPackageName } from './lib/deb.mjs'
38
- import { osVersion, withManifestVersion } from './lib/os-version.mjs'
38
+ import { osVersion, withManifestName, withManifestVersion } from './lib/os-version.mjs'
39
39
 
40
40
  const root = resolve(dirname(fileURLToPath(import.meta.url)), '..')
41
41
  /**
@@ -552,11 +552,13 @@ const blendVersion = await (async () => {
552
552
  }
553
553
  })()
554
554
  manifest.version = osVersion(manifest.version, blendVersion)
555
- // The frame's top bar reads blend.yaml: the packed copy names the same version as About and Installed apps (a release sets only package.json's).
556
- if (blendVersion !== manifest.version && existsSync(join(app, 'blend.yaml'))) {
555
+ // The packed blend.yaml is the scaffold's: it names the version the OS shows (the frame's top bar reads it, a release sets only package.json's) and the
556
+ // product (the instance names the app, so the window's title and the About panel, by it).
557
+ if (existsSync(join(app, 'blend.yaml'))) {
558
+ const written = readFileSync(join(app, 'blend.yaml'), 'utf8')
557
559
  writeFileSync(
558
560
  join(app, 'blend.yaml'),
559
- withManifestVersion(readFileSync(join(app, 'blend.yaml'), 'utf8'), manifest.version),
561
+ withManifestName(withManifestVersion(written, manifest.version), PRODUCT),
560
562
  )
561
563
  }
562
564
  log(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acryldev/blends",
3
- "version": "1.7.29",
3
+ "version": "1.7.30",
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",