@acryldev/blends 1.7.7 → 1.7.9
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/dist/index.js +1 -1
- package/docs/framework/workshop/README.md +3 -3
- package/package.json +1 -1
- package/plugins/plugin-share/plugin.json +1 -1
- package/plugins/save/package.json +1 -1
- package/plugins/save/plugin.json +9 -3
- package/plugins/save/share-cli.ts +54 -0
- package/plugins/save/share.ts +155 -3
- package/shared/library-history-versions.json +6 -1
- package/shared/library-history.json +473 -310
package/dist/index.js
CHANGED
|
@@ -17,9 +17,9 @@ ACRYL Control Center lists your apps, makes new ones and starts them. Download i
|
|
|
17
17
|
|
|
18
18
|
| | Apple Silicon / ARM | Intel / x64 |
|
|
19
19
|
| --- | --- | --- |
|
|
20
|
-
| macOS | [ACRYL-Control-Center-mac-arm64.dmg](https://github.com/
|
|
21
|
-
| Windows | [ACRYL-Control-Center-win-arm64.exe](https://github.com/
|
|
22
|
-
| Linux (Debian, Ubuntu) | [ACRYL-Control-Center-linux-arm64.deb](https://github.com/
|
|
20
|
+
| macOS | [ACRYL-Control-Center-mac-arm64.dmg](https://github.com/acrylblends/63-acryl-control-center/releases/latest/download/ACRYL-Control-Center-mac-arm64.dmg) | [ACRYL-Control-Center-mac-x64.dmg](https://github.com/acrylblends/63-acryl-control-center/releases/latest/download/ACRYL-Control-Center-mac-x64.dmg) |
|
|
21
|
+
| Windows | [ACRYL-Control-Center-win-arm64.exe](https://github.com/acrylblends/63-acryl-control-center/releases/latest/download/ACRYL-Control-Center-win-arm64.exe) | [ACRYL-Control-Center-win-x64.exe](https://github.com/acrylblends/63-acryl-control-center/releases/latest/download/ACRYL-Control-Center-win-x64.exe) |
|
|
22
|
+
| Linux (Debian, Ubuntu) | [ACRYL-Control-Center-linux-arm64.deb](https://github.com/acrylblends/63-acryl-control-center/releases/latest/download/ACRYL-Control-Center-linux-arm64.deb) | [ACRYL-Control-Center-linux-x64.deb](https://github.com/acrylblends/63-acryl-control-center/releases/latest/download/ACRYL-Control-Center-linux-x64.deb) |
|
|
23
23
|
|
|
24
24
|
The apps are not signed yet: on macOS the first start is right-click > Open; on Windows SmartScreen may ask, More info > Run anyway; on Linux
|
|
25
25
|
`sudo apt install ./ACRYL-Control-Center-linux-x64.deb`. Or, with Node.js installed, start it without a download:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acryldev/save",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"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.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
package/plugins/save/plugin.json
CHANGED
|
@@ -2,14 +2,20 @@
|
|
|
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": [
|
|
5
|
+
"inject": [
|
|
6
|
+
"appInstance"
|
|
7
|
+
],
|
|
6
8
|
"provides": [],
|
|
7
9
|
"dependencies": {
|
|
8
10
|
"@deepseek-ai/cordis": "4.0.4",
|
|
9
|
-
"@acryldev/app-persistence": "0.1.
|
|
11
|
+
"@acryldev/app-persistence": "0.1.4"
|
|
10
12
|
},
|
|
11
|
-
"mount": "
|
|
13
|
+
"mount": "mount the plugin to give the agent a save_app tool; its scripts (npm run save, npm run share) are added to package.json with it",
|
|
12
14
|
"entries": {
|
|
13
15
|
"": "index.ts"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"save": "node plugins/save/cli.ts",
|
|
19
|
+
"share": "node plugins/save/share-cli.ts"
|
|
14
20
|
}
|
|
15
21
|
}
|
|
@@ -5,12 +5,15 @@
|
|
|
5
5
|
* --confirm <plan> send exactly this plan (the JSON `--json` printed, as it is or base64url-encoded so no shell can change it), and nothing when
|
|
6
6
|
* the app no longer matches it: for a person's own surface that showed them the plan and took their yes (the ACRYL
|
|
7
7
|
* launcher's Share)
|
|
8
|
+
* --list list it in the Blends store too (public only), as Community under your name; --category <address> and
|
|
9
|
+
* --subcategory <address> place it (default: its earlier place, else its starter's category), --license <id> (default MIT)
|
|
8
10
|
* Exits 1 when the share was refused.
|
|
9
11
|
*/
|
|
10
12
|
import { realpathSync } from 'node:fs'
|
|
11
13
|
import { createInterface } from 'node:readline/promises'
|
|
12
14
|
import { fileURLToPath } from 'node:url'
|
|
13
15
|
import { parseArgs } from 'node:util'
|
|
16
|
+
import { CATEGORIES_URL, type CatalogCategory, readCategories } from '@acryldev/app-persistence'
|
|
14
17
|
import { planShare, renderSharePlan, type SharePlan, type ShareResult, shareApp } from './share.ts'
|
|
15
18
|
|
|
16
19
|
function report(result: ShareResult): number {
|
|
@@ -21,6 +24,12 @@ function report(result: ShareResult): number {
|
|
|
21
24
|
return 1
|
|
22
25
|
}
|
|
23
26
|
console.log(`shared to ${result.remote}${result.created ? ' (created)' : ''}`)
|
|
27
|
+
if (result.listed !== undefined)
|
|
28
|
+
console.log(
|
|
29
|
+
result.listed.created
|
|
30
|
+
? `listed in the Blends store from ${result.listed.tag}: acrylblends.github.io shows it within about an hour`
|
|
31
|
+
: `${result.listed.tag} was already tagged, so the store keeps that version: raise the version in package.json to list this one`,
|
|
32
|
+
)
|
|
24
33
|
return 0
|
|
25
34
|
}
|
|
26
35
|
|
|
@@ -44,6 +53,31 @@ function readPlan(text: string): unknown {
|
|
|
44
53
|
return undefined
|
|
45
54
|
}
|
|
46
55
|
|
|
56
|
+
/** The store's category list; without it (offline) a place is not checked here, and the store's sync still is. */
|
|
57
|
+
async function publishedCategories(): Promise<{ categories?: readonly CatalogCategory[] }> {
|
|
58
|
+
try {
|
|
59
|
+
const response = await fetch(CATEGORIES_URL, { signal: AbortSignal.timeout(10_000) })
|
|
60
|
+
const categories = response.ok ? readCategories(await response.json()) : 'unreachable'
|
|
61
|
+
return typeof categories === 'string' ? {} : { categories }
|
|
62
|
+
} catch {
|
|
63
|
+
return {}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const HELP = `npm run share [-- options]: send this app to a GitHub repository of your own (through your gh login). The plan comes first; nothing is sent until you type yes.
|
|
68
|
+
|
|
69
|
+
--owner <account> the GitHub account or organization for a new repository (default: yours)
|
|
70
|
+
--visibility private|public who may see a new repository (default: blend.yaml metadata.visibility, else private); kept in blend.yaml
|
|
71
|
+
--list also list it in the Blends store (acrylblends.github.io and Control Center), as Community under your name; public only
|
|
72
|
+
--category <address> its category, one of acrylblends.github.io/blends (default: its earlier place, else its starter's category)
|
|
73
|
+
--subcategory <address> a subcategory of that category
|
|
74
|
+
--license <id> its licence when listed, an SPDX id (default MIT)
|
|
75
|
+
--json print the plan as JSON and send nothing
|
|
76
|
+
--confirm <plan> send exactly this plan (the JSON --json printed); for a surface that showed a person the plan
|
|
77
|
+
-h, --help this text
|
|
78
|
+
|
|
79
|
+
Example: npm run share -- --visibility public --list --category business --subcategory crm`
|
|
80
|
+
|
|
47
81
|
async function main(argv: readonly string[]): Promise<number> {
|
|
48
82
|
const appRoot = fileURLToPath(new URL('../..', import.meta.url))
|
|
49
83
|
const { values } = parseArgs({
|
|
@@ -54,8 +88,17 @@ async function main(argv: readonly string[]): Promise<number> {
|
|
|
54
88
|
visibility: { type: 'string' },
|
|
55
89
|
json: { type: 'boolean' },
|
|
56
90
|
confirm: { type: 'string' },
|
|
91
|
+
list: { type: 'boolean' },
|
|
92
|
+
category: { type: 'string' },
|
|
93
|
+
subcategory: { type: 'string' },
|
|
94
|
+
license: { type: 'string' },
|
|
95
|
+
help: { type: 'boolean', short: 'h' },
|
|
57
96
|
},
|
|
58
97
|
})
|
|
98
|
+
if (values.help === true) {
|
|
99
|
+
console.log(HELP)
|
|
100
|
+
return 0
|
|
101
|
+
}
|
|
59
102
|
if (
|
|
60
103
|
values.visibility !== undefined &&
|
|
61
104
|
values.visibility !== 'private' &&
|
|
@@ -64,7 +107,18 @@ async function main(argv: readonly string[]): Promise<number> {
|
|
|
64
107
|
console.error('not shared: --visibility is private or public')
|
|
65
108
|
return 1
|
|
66
109
|
}
|
|
110
|
+
const listing = values.list === true || values.category !== undefined
|
|
67
111
|
const options = {
|
|
112
|
+
...(listing
|
|
113
|
+
? {
|
|
114
|
+
list: {
|
|
115
|
+
...(values.category === undefined ? {} : { category: values.category }),
|
|
116
|
+
...(values.subcategory === undefined ? {} : { subcategory: values.subcategory }),
|
|
117
|
+
...(values.license === undefined ? {} : { license: values.license }),
|
|
118
|
+
},
|
|
119
|
+
...(await publishedCategories()),
|
|
120
|
+
}
|
|
121
|
+
: {}),
|
|
68
122
|
...(values.owner === undefined ? {} : { owner: values.owner }),
|
|
69
123
|
...(values.visibility === undefined
|
|
70
124
|
? {}
|
package/plugins/save/share.ts
CHANGED
|
@@ -5,22 +5,46 @@
|
|
|
5
5
|
* same guards hold: no file that holds a secret, and a private app never goes to a public repository.
|
|
6
6
|
*/
|
|
7
7
|
import { spawnSync } from 'node:child_process'
|
|
8
|
-
import { readFileSync, writeFileSync } from 'node:fs'
|
|
8
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs'
|
|
9
9
|
import { basename, join } from 'node:path'
|
|
10
10
|
import {
|
|
11
|
+
type AppIdentity,
|
|
12
|
+
type CatalogCategory,
|
|
11
13
|
connectRemote,
|
|
12
14
|
type GitPort,
|
|
15
|
+
GITHUB_VIA_GH,
|
|
13
16
|
gitCli,
|
|
14
17
|
githubHosting,
|
|
15
18
|
type HostingPort,
|
|
16
19
|
PersistenceError,
|
|
20
|
+
type Placement,
|
|
21
|
+
placementOf,
|
|
22
|
+
placementProblem,
|
|
17
23
|
readAppIdentity,
|
|
18
24
|
type SecretFinding,
|
|
19
25
|
saveApp,
|
|
26
|
+
suggestPlacement,
|
|
20
27
|
type Visibility,
|
|
28
|
+
withId,
|
|
29
|
+
withLicense,
|
|
30
|
+
withPlacement,
|
|
21
31
|
withVisibility,
|
|
22
32
|
} from '@acryldev/app-persistence'
|
|
23
33
|
|
|
34
|
+
/** The GitHub topic acrylblends.github.io's hourly sync finds a Blend's repository by. */
|
|
35
|
+
export const BLEND_TOPIC = 'acrylblends-blend'
|
|
36
|
+
|
|
37
|
+
/** Where and how the Blends store lists the app: shown in the plan, written by the share. */
|
|
38
|
+
export interface StoreListing {
|
|
39
|
+
/** Its id in the store, under its owner's name (`ana.notes`): an app made from a starter is `acrylblends.<name>`, which only official owners may list. */
|
|
40
|
+
readonly id: string
|
|
41
|
+
readonly placement: Placement
|
|
42
|
+
/** An SPDX licence id (MIT): a public Blend names its terms. */
|
|
43
|
+
readonly license: string
|
|
44
|
+
/** The tag people start from (`--from github:owner/repo#v1.0.0`): v and the app's version. */
|
|
45
|
+
readonly tag: string
|
|
46
|
+
}
|
|
47
|
+
|
|
24
48
|
/** What a share would send, and where. */
|
|
25
49
|
export interface SharePlan {
|
|
26
50
|
/** The repository: `owner/name` for one to be created, the remote's address for an app that has one. */
|
|
@@ -30,6 +54,8 @@ export interface SharePlan {
|
|
|
30
54
|
readonly visibility: Visibility
|
|
31
55
|
/** How many files changed since the last save; the share saves them first. */
|
|
32
56
|
readonly changes: number
|
|
57
|
+
/** Listed in the Blends store too (acrylblends.github.io and Control Center's store), as Community under the owner's name. */
|
|
58
|
+
readonly listing?: StoreListing
|
|
33
59
|
}
|
|
34
60
|
|
|
35
61
|
export type ShareRefused = {
|
|
@@ -45,6 +71,8 @@ export type ShareResult =
|
|
|
45
71
|
readonly created: boolean
|
|
46
72
|
/** The version saved by the share, when something had changed. */
|
|
47
73
|
readonly commit?: string
|
|
74
|
+
/** The store listing: its tag, and whether this share made it (an existing tag is kept, so a new listing needs a new version). */
|
|
75
|
+
readonly listed?: { readonly tag: string; readonly created: boolean }
|
|
48
76
|
}
|
|
49
77
|
| ShareRefused
|
|
50
78
|
|
|
@@ -53,6 +81,10 @@ export interface ShareOptions {
|
|
|
53
81
|
readonly owner?: string
|
|
54
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. */
|
|
55
83
|
readonly visibility?: Visibility
|
|
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 }
|
|
86
|
+
/** The published category list (acrylblends.github.io/categories.json), to check the place against; unchecked when absent. */
|
|
87
|
+
readonly categories?: readonly CatalogCategory[]
|
|
56
88
|
}
|
|
57
89
|
|
|
58
90
|
/** What a share needs from the computer; tests give their own. */
|
|
@@ -63,6 +95,8 @@ export interface SharePorts {
|
|
|
63
95
|
account(): string | undefined
|
|
64
96
|
/** How many files differ from the last save. */
|
|
65
97
|
pending(): number
|
|
98
|
+
/** Label `owner/repo` for the Blends store and push the tag; false when the tag already existed (it is never moved). */
|
|
99
|
+
list(repository: string, tag: string): boolean
|
|
66
100
|
}
|
|
67
101
|
|
|
68
102
|
/** The person's own git and gh, in the app's folder. */
|
|
@@ -82,6 +116,17 @@ export function sharePorts(appRoot: string): SharePorts {
|
|
|
82
116
|
const result = run('git', ['status', '--porcelain'])
|
|
83
117
|
return result.status === 0 ? result.stdout.split('\n').filter(Boolean).length : 0
|
|
84
118
|
},
|
|
119
|
+
list: (repository, tag) => {
|
|
120
|
+
const must = (command: string, args: readonly string[], what: string) => {
|
|
121
|
+
const result = run(command, args)
|
|
122
|
+
if (result.status !== 0) throw new PersistenceError(`${what}: ${(result.stderr || result.stdout).trim()}`)
|
|
123
|
+
}
|
|
124
|
+
must('gh', ['repo', 'edit', repository, '--add-topic', BLEND_TOPIC], 'could not label the repository for the Blends store')
|
|
125
|
+
if (run('git', ['rev-parse', '-q', '--verify', `refs/tags/${tag}`]).status === 0) return false
|
|
126
|
+
must('git', ['tag', tag], `could not tag ${tag}`)
|
|
127
|
+
must('git', [...GITHUB_VIA_GH, 'push', '--quiet', 'origin', `refs/tags/${tag}`], `could not push ${tag}`)
|
|
128
|
+
return true
|
|
129
|
+
},
|
|
85
130
|
}
|
|
86
131
|
}
|
|
87
132
|
|
|
@@ -96,12 +141,106 @@ const repositoryName = (name: string): string =>
|
|
|
96
141
|
.replace(/^[-.]+|[-.]+$/gu, '')
|
|
97
142
|
.toLowerCase()
|
|
98
143
|
|
|
144
|
+
/** `owner/repo` of a GitHub remote address, or undefined for another host. */
|
|
145
|
+
export const githubRepository = (remote: string): string | undefined =>
|
|
146
|
+
/github\.com[/:]([^/]+\/[^/]+?)(?:\.git)?\/?$/u.exec(remote)?.[1]
|
|
147
|
+
|
|
148
|
+
const INSTALL_SCRIPTS = ['preinstall', 'install', 'postinstall', 'prepublish', 'preprepare', 'prepare', 'postprepare']
|
|
149
|
+
const LICENSE_ID = /^[A-Za-z0-9][A-Za-z0-9.+-]*$/u
|
|
150
|
+
|
|
151
|
+
interface PackageJson { version?: unknown; keywords?: unknown; scripts?: Record<string, unknown>; [key: string]: unknown }
|
|
152
|
+
const packageOf = (appRoot: string): PackageJson | undefined => {
|
|
153
|
+
try {
|
|
154
|
+
return JSON.parse(readFileSync(join(appRoot, 'package.json'), 'utf8')) as PackageJson
|
|
155
|
+
} catch {
|
|
156
|
+
return undefined
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** 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 {
|
|
162
|
+
const asked = options.list
|
|
163
|
+
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)')
|
|
167
|
+
const pkg = packageOf(appRoot)
|
|
168
|
+
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`)
|
|
171
|
+
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)')
|
|
176
|
+
const problem = categories.length > 0 ? placementProblem(placement, categories) : undefined
|
|
177
|
+
if (problem !== undefined) return refused(problem)
|
|
178
|
+
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'
|
|
181
|
+
const name = (identity.id ?? '').split('.').slice(1).join('.') || repository.split('/')[1] || ''
|
|
182
|
+
const id = `${(repository.split('/')[0] ?? '').toLowerCase()}.${name.toLowerCase()}`
|
|
183
|
+
return { id, placement, license, tag: `v${version}` }
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const MIT = (year: number, holder: string) => `MIT License
|
|
187
|
+
|
|
188
|
+
Copyright (c) ${String(year)} ${holder}
|
|
189
|
+
|
|
190
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
191
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
192
|
+
in the Software without restriction, including without limitation the rights
|
|
193
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
194
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
195
|
+
furnished to do so, subject to the following conditions:
|
|
196
|
+
|
|
197
|
+
The above copyright notice and this permission notice shall be included in all
|
|
198
|
+
copies or substantial portions of the Software.
|
|
199
|
+
|
|
200
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
201
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
202
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
203
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
204
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
205
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
206
|
+
SOFTWARE.
|
|
207
|
+
`
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* 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
|
+
* 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
|
+
*/
|
|
213
|
+
function writeListing(appRoot: string, manifestText: string, listing: StoreListing, repository: string): string {
|
|
214
|
+
const identity = readAppIdentity(manifestText)
|
|
215
|
+
let text = manifestText
|
|
216
|
+
if (identity.id !== listing.id) text = withId(text, listing.id)
|
|
217
|
+
if (identity.license !== listing.license) text = withLicense(text, listing.license)
|
|
218
|
+
if (text !== manifestText) writeFileSync(join(appRoot, 'blend.yaml'), text)
|
|
219
|
+
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`)
|
|
223
|
+
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] ?? ''))
|
|
227
|
+
return text
|
|
228
|
+
}
|
|
229
|
+
|
|
99
230
|
/** What sharing the app would send. Sends nothing and changes nothing. */
|
|
100
231
|
export function planShare(
|
|
101
232
|
appRoot: string,
|
|
102
233
|
options: ShareOptions = {},
|
|
103
234
|
ports: SharePorts = sharePorts(appRoot),
|
|
104
235
|
): SharePlan | ShareRefused {
|
|
236
|
+
const plan = planRepository(appRoot, options, ports)
|
|
237
|
+
if ('ok' in plan) return plan
|
|
238
|
+
const listing = planListing(appRoot, readAppIdentity(manifestOf(appRoot)), plan.visibility, plan.create ? plan.repository : githubRepository(plan.repository), options)
|
|
239
|
+
if (listing !== undefined && 'ok' in listing) return listing
|
|
240
|
+
return listing === undefined ? plan : { ...plan, listing }
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function planRepository(appRoot: string, options: ShareOptions, ports: SharePorts): SharePlan | ShareRefused {
|
|
105
244
|
const identity = readAppIdentity(manifestOf(appRoot))
|
|
106
245
|
const visibility = options.visibility ?? identity.visibility
|
|
107
246
|
const changes = ports.pending()
|
|
@@ -136,7 +275,8 @@ export const sameSharePlan = (a: SharePlan, b: SharePlan): boolean =>
|
|
|
136
275
|
a.repository === b.repository &&
|
|
137
276
|
a.create === b.create &&
|
|
138
277
|
a.visibility === b.visibility &&
|
|
139
|
-
a.changes === b.changes
|
|
278
|
+
a.changes === b.changes &&
|
|
279
|
+
JSON.stringify(a.listing) === JSON.stringify(b.listing)
|
|
140
280
|
|
|
141
281
|
/** The person's yes: share exactly the plan they read. An app that changed since is not shared; the plan is read again first. */
|
|
142
282
|
export function shareApp(
|
|
@@ -159,7 +299,9 @@ export function shareApp(
|
|
|
159
299
|
manifestText = withVisibility(manifestText, options.visibility)
|
|
160
300
|
writeFileSync(join(appRoot, 'blend.yaml'), manifestText)
|
|
161
301
|
}
|
|
302
|
+
const repository = now.create ? now.repository : githubRepository(now.repository)
|
|
162
303
|
try {
|
|
304
|
+
if (now.listing !== undefined && repository !== undefined) manifestText = writeListing(appRoot, manifestText, now.listing, repository)
|
|
163
305
|
let remote = now.repository
|
|
164
306
|
if (now.create) {
|
|
165
307
|
const connected = connectRemote(
|
|
@@ -179,11 +321,15 @@ export function shareApp(
|
|
|
179
321
|
}
|
|
180
322
|
// Nothing new to save: the versions already saved still have to reach the remote.
|
|
181
323
|
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
|
|
182
327
|
return {
|
|
183
328
|
ok: true,
|
|
184
329
|
remote,
|
|
185
330
|
created: now.create,
|
|
186
331
|
...(saved.status === 'saved' ? { commit: saved.commit } : {}),
|
|
332
|
+
...(listed === undefined ? {} : { listed }),
|
|
187
333
|
}
|
|
188
334
|
} catch (error) {
|
|
189
335
|
if (error instanceof PersistenceError) return refused(error.message)
|
|
@@ -200,5 +346,11 @@ export function renderSharePlan(plan: SharePlan): string {
|
|
|
200
346
|
plan.changes === 0
|
|
201
347
|
? 'the versions saved so far'
|
|
202
348
|
: `${String(plan.changes)} changed ${plan.changes === 1 ? 'file' : 'files'}, saved first, and the versions saved so far`
|
|
203
|
-
|
|
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}).`
|
|
352
|
+
return `Share this app to ${where}: ${what}.${listed}`
|
|
204
353
|
}
|
|
354
|
+
|
|
355
|
+
const placementWords = (placement: Placement): string =>
|
|
356
|
+
placement.subcategory === undefined ? placement.category : `${placement.category} › ${placement.subcategory}`
|