@crombolo/cli 0.16.0 → 0.17.0
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/oclif.manifest.json +5 -1
- package/package.json +8 -8
- package/src/commands/components/new.ts +12 -6
- package/src/support/components.ts +11 -1
- package/src/support/publish.ts +8 -1
- package/templates/basic/bundle/package.json +1 -1
- package/templates/demo/harbourstone/bundle/package.json +1 -1
- package/templates/starter/bundle/package.json +1 -1
package/oclif.manifest.json
CHANGED
|
@@ -1152,6 +1152,10 @@
|
|
|
1152
1152
|
{
|
|
1153
1153
|
"name": "template",
|
|
1154
1154
|
"type": "boolean"
|
|
1155
|
+
},
|
|
1156
|
+
{
|
|
1157
|
+
"name": "email",
|
|
1158
|
+
"type": "boolean"
|
|
1155
1159
|
}
|
|
1156
1160
|
],
|
|
1157
1161
|
"errors": [
|
|
@@ -8073,5 +8077,5 @@
|
|
|
8073
8077
|
]
|
|
8074
8078
|
}
|
|
8075
8079
|
},
|
|
8076
|
-
"version": "0.
|
|
8080
|
+
"version": "0.17.0"
|
|
8077
8081
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "The crombolo command line: scaffolding a site, schema, views, domains, content transfer and upgrades.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Crombolo",
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@crombolo/api-management": "0.
|
|
40
|
-
"@crombolo/auth": "0.
|
|
41
|
-
"@crombolo/core": "0.
|
|
42
|
-
"@crombolo/data": "0.
|
|
43
|
-
"@crombolo/schema": "0.
|
|
44
|
-
"@crombolo/server": "0.
|
|
45
|
-
"@crombolo/transfer": "0.
|
|
39
|
+
"@crombolo/api-management": "0.17.0",
|
|
40
|
+
"@crombolo/auth": "0.17.0",
|
|
41
|
+
"@crombolo/core": "0.17.0",
|
|
42
|
+
"@crombolo/data": "0.17.0",
|
|
43
|
+
"@crombolo/schema": "0.17.0",
|
|
44
|
+
"@crombolo/server": "0.17.0",
|
|
45
|
+
"@crombolo/transfer": "0.17.0",
|
|
46
46
|
"@oclif/core": "^5.1.8"
|
|
47
47
|
},
|
|
48
48
|
"oclif": {
|
|
@@ -2,10 +2,10 @@ import { existsSync } from 'node:fs'
|
|
|
2
2
|
import { mkdir, writeFile } from 'node:fs/promises'
|
|
3
3
|
import { join } from 'node:path'
|
|
4
4
|
import { viewScaffold } from '@crombolo/schema'
|
|
5
|
-
import { componentFileFor, componentScaffold, isSafeAlias } from '@crombolo/server'
|
|
5
|
+
import { componentFileFor, componentScaffold, emailScaffold, isSafeAlias } from '@crombolo/server'
|
|
6
6
|
import { Args } from '@oclif/core'
|
|
7
7
|
import { BaseCommand } from '../../base.ts'
|
|
8
|
-
import { declaredTypes } from '../../support/components.ts'
|
|
8
|
+
import { declaredTypes, formsNamingEmailTemplate } from '../../support/components.ts'
|
|
9
9
|
import { here } from '../../support/describe.ts'
|
|
10
10
|
import { siteConfig } from '../../support/site.ts'
|
|
11
11
|
|
|
@@ -21,6 +21,7 @@ export default class ComponentsNew extends BaseCommand {
|
|
|
21
21
|
outputFields: [
|
|
22
22
|
{ name: 'created', type: 'string' },
|
|
23
23
|
{ name: 'template', type: 'boolean' },
|
|
24
|
+
{ name: 'email', type: 'boolean' },
|
|
24
25
|
],
|
|
25
26
|
errors: ['usage', 'conflict'],
|
|
26
27
|
} as const
|
|
@@ -33,17 +34,22 @@ export default class ComponentsNew extends BaseCommand {
|
|
|
33
34
|
const file = componentFileFor(config.componentsDir, args.alias)
|
|
34
35
|
if (existsSync(file)) this.fail('conflict', `${here(file)} already exists.`)
|
|
35
36
|
// A content type that names this alias gets the page scaffold, which takes
|
|
36
|
-
// PageProps;
|
|
37
|
+
// PageProps; a form's Send email that names it gets the e-mail one, which
|
|
38
|
+
// takes EmailProps; anything else gets the plain one. Nothing turns on the folder.
|
|
37
39
|
const type = declaredTypes(config).find((candidate) =>
|
|
38
40
|
candidate.components.includes(args.alias),
|
|
39
41
|
)
|
|
40
|
-
|
|
42
|
+
const email = !type && formsNamingEmailTemplate(config, args.alias).length > 0
|
|
43
|
+
if (!type && !email)
|
|
41
44
|
this.say(
|
|
42
45
|
` note no content type declares the template "${args.alias}" — add it to one's templates, or \`crombolo types new\``,
|
|
43
46
|
)
|
|
44
47
|
await mkdir(join(file, '..'), { recursive: true })
|
|
45
|
-
await writeFile(
|
|
48
|
+
await writeFile(
|
|
49
|
+
file,
|
|
50
|
+
type ? viewScaffold(type) : email ? emailScaffold(args.alias) : componentScaffold(args.alias),
|
|
51
|
+
)
|
|
46
52
|
this.say(` created ${here(file)}`)
|
|
47
|
-
return { created: here(file), template: Boolean(type) }
|
|
53
|
+
return { created: here(file), template: Boolean(type), email }
|
|
48
54
|
}
|
|
49
55
|
}
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
/** The content types a site declares, which say which components are templates. */
|
|
1
|
+
/** The content types and forms a site declares, which say which components are templates. */
|
|
2
2
|
import { existsSync } from 'node:fs'
|
|
3
3
|
import type { CromboloConfig } from '@crombolo/server'
|
|
4
4
|
import { loadTypes } from './types.ts'
|
|
5
5
|
|
|
6
6
|
export const declaredTypes = (config: CromboloConfig) =>
|
|
7
7
|
existsSync(config.schemaDir) ? loadTypes(config).set.contentTypes : []
|
|
8
|
+
|
|
9
|
+
/** The forms whose Send email workflow names `alias` as its e-mail template. */
|
|
10
|
+
export const formsNamingEmailTemplate = (config: CromboloConfig, alias: string) =>
|
|
11
|
+
existsSync(config.schemaDir)
|
|
12
|
+
? (loadTypes(config).set.forms ?? []).filter((form) =>
|
|
13
|
+
form.workflows.some(
|
|
14
|
+
(workflow) => workflow.type === 'sendEmail' && workflow.settings.template === alias,
|
|
15
|
+
),
|
|
16
|
+
)
|
|
17
|
+
: []
|
package/src/support/publish.ts
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
describeRefFailure,
|
|
15
15
|
resolveNodeRef,
|
|
16
16
|
} from '@crombolo/data'
|
|
17
|
-
import { bootstrapDatabase } from '@crombolo/server'
|
|
17
|
+
import { bootstrapDatabase, createContentNotifier, resolveEmailPort } from '@crombolo/server'
|
|
18
18
|
import { Args, Flags } from '@oclif/core'
|
|
19
19
|
import { CliError } from '../errors.ts'
|
|
20
20
|
import { many } from './flags.ts'
|
|
@@ -124,12 +124,19 @@ export async function publishPages(
|
|
|
124
124
|
)
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
// The people who asked to hear of a publish here hear of this one too (story 045).
|
|
128
|
+
const notifier = createContentNotifier(db, { canSend: Boolean(resolveEmailPort(config)) })
|
|
127
129
|
for (const node of targets) {
|
|
128
130
|
const result = publishing
|
|
129
131
|
? await docs.publish(node.key, cultures.length > 0 ? cultures : null)
|
|
130
132
|
: await docs.unpublish(node.key, cultures.length > 0 ? cultures : null)
|
|
131
133
|
items.push({ key: node.key, name: node.text ?? node.key, changed: Boolean(result) })
|
|
132
134
|
if (!result) continue
|
|
135
|
+
if (publishing)
|
|
136
|
+
await notifier.raise(
|
|
137
|
+
{ actions: ['Umb.Document.Publish'], key: node.key, keyKind: 'document' },
|
|
138
|
+
{ key: null, name: 'The command line' },
|
|
139
|
+
)
|
|
133
140
|
io.say(` ${publishing ? 'published' : 'unpublished'} ${node.text ?? node.key}`)
|
|
134
141
|
}
|
|
135
142
|
io.say(
|