@appsemble/cli 0.27.10 → 0.27.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/README.md +3 -3
- package/__fixtures__/apps/test/README.md +1 -0
- package/commands/serve.js +21 -2
- package/lib/app.d.ts +74 -75
- package/lib/app.js +333 -124
- package/lib/app.test.js +1462 -3
- package/package.json +6 -6
- package/server/options/getAppVariables.d.ts +3 -0
- package/server/options/getAppVariables.js +4 -0
- package/server/options/index.d.ts +1 -0
- package/server/options/index.js +1 -0
- package/server/options/options.js +2 -1
- package/templates/apps/empty/app-definition.yaml +2 -2
- package/templates/blocks/mini-jsx/package.json +1 -1
- package/templates/blocks/preact/package.json +2 -2
- package/templates/blocks/vanilla/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
#  Appsemble CLI
|
|
2
2
|
|
|
3
3
|
> Manage apps and blocks from the command line.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@appsemble/cli)
|
|
6
|
-
[](https://gitlab.com/appsemble/appsemble/-/releases/0.27.12)
|
|
7
7
|
[](https://prettier.io)
|
|
8
8
|
|
|
9
9
|
## Table of Contents
|
|
@@ -323,5 +323,5 @@ appsemble run-cronjobs --interval 30
|
|
|
323
323
|
|
|
324
324
|
## License
|
|
325
325
|
|
|
326
|
-
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.27.
|
|
326
|
+
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.27.12/LICENSE.md) ©
|
|
327
327
|
[Appsemble](https://appsemble.com)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Test App
|
package/commands/serve.js
CHANGED
|
@@ -9,7 +9,7 @@ import axios from 'axios';
|
|
|
9
9
|
import csvToJson from 'csvtojson';
|
|
10
10
|
import FormData from 'form-data';
|
|
11
11
|
import globalCacheDir from 'global-cache-dir';
|
|
12
|
-
import { traverseAppDirectory } from '../lib/app.js';
|
|
12
|
+
import { parseValues, traverseAppDirectory } from '../lib/app.js';
|
|
13
13
|
import { buildBlock } from '../lib/block.js';
|
|
14
14
|
import { getProjectBuildConfig, getProjectWebpackConfig } from '../lib/config.js';
|
|
15
15
|
import { createApiServer, createStaticServer } from '../lib/createServers.js';
|
|
@@ -56,7 +56,7 @@ export function builder(yargs) {
|
|
|
56
56
|
export async function handler(argv) {
|
|
57
57
|
setArgv(argv);
|
|
58
58
|
const appPath = join(process.cwd(), argv.path);
|
|
59
|
-
const [, , appsembleApp] = await traverseAppDirectory(appPath, new FormData());
|
|
59
|
+
const [, , , appsembleApp] = await traverseAppDirectory(appPath, 'development', new FormData());
|
|
60
60
|
const appRoles = appsembleApp.definition.roles;
|
|
61
61
|
const passedUserRole = argv['user-role'];
|
|
62
62
|
if (passedUserRole && !(appRoles === null || appRoles === void 0 ? void 0 : appRoles.includes(passedUserRole))) {
|
|
@@ -207,6 +207,24 @@ export async function handler(argv) {
|
|
|
207
207
|
const { name } = parse(stat.name);
|
|
208
208
|
await Resource.bulkCreate(resources, name, true);
|
|
209
209
|
}, { allowMissing: true });
|
|
210
|
+
const appVariables = [];
|
|
211
|
+
const configPath = join(appPath, 'config');
|
|
212
|
+
if (existsSync(configPath)) {
|
|
213
|
+
const variablesPath = join(configPath, 'variables.json');
|
|
214
|
+
if (existsSync(variablesPath)) {
|
|
215
|
+
const [readAppVariables] = (await readData(variablesPath));
|
|
216
|
+
if (readAppVariables.length) {
|
|
217
|
+
for (const appVariable of readAppVariables) {
|
|
218
|
+
const { name, value } = appVariable;
|
|
219
|
+
const [parsedValues, missingValues] = parseValues('variable', name, [{ value }]);
|
|
220
|
+
if (missingValues) {
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
appVariables.push({ name, ...parsedValues });
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
210
228
|
const stubbedApp = {
|
|
211
229
|
...appsembleApp,
|
|
212
230
|
id: appId,
|
|
@@ -221,6 +239,7 @@ export async function handler(argv) {
|
|
|
221
239
|
appsembleApp: stubbedApp,
|
|
222
240
|
appBlocks,
|
|
223
241
|
appMessages,
|
|
242
|
+
appVariables,
|
|
224
243
|
...(appSecurity
|
|
225
244
|
? {
|
|
226
245
|
appMembers,
|
package/lib/app.d.ts
CHANGED
|
@@ -1,8 +1,58 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
/// <reference types="node" resolution-mode="require"/>
|
|
3
3
|
import { type ReadStream } from 'node:fs';
|
|
4
|
-
import { type App, type AppLock, type AppsembleRC, type AppVisibility } from '@appsemble/types';
|
|
4
|
+
import { type App, type AppLock, type AppsembleContext, type AppsembleRC, type AppVisibility, type ValueFromDefinition, type ValueFromProcess } from '@appsemble/types';
|
|
5
5
|
import FormData from 'form-data';
|
|
6
|
+
/**
|
|
7
|
+
* Traverses an app directory and appends the files it finds to the given FormData object.
|
|
8
|
+
*
|
|
9
|
+
* @param path The path of the app directory to traverse.
|
|
10
|
+
* @param context The Context to use from `.appsemblerc.yaml`.
|
|
11
|
+
* @param formData The FormData object to append the results into..
|
|
12
|
+
* @returns The context from `.appsemblerc.yaml` if a match was found.
|
|
13
|
+
*/
|
|
14
|
+
export declare function traverseAppDirectory(path: string, context: string, formData: FormData): Promise<[AppsembleContext, AppsembleRC, string, App]>;
|
|
15
|
+
/**
|
|
16
|
+
* Export an app as a zip file.
|
|
17
|
+
*
|
|
18
|
+
* @param appId Id of the app to be exported.
|
|
19
|
+
* @param assets Boolean representing whether to include assets in the exported zip file.
|
|
20
|
+
* @param resources Boolean representing whether to include resources in the zip file.
|
|
21
|
+
* @param path Path of the folder where you want to put your downloaded file.
|
|
22
|
+
* @param remote The remote to fetch the app from.
|
|
23
|
+
*/
|
|
24
|
+
export declare function exportAppAsZip(appId: number, assets: boolean, resources: boolean, path: string, remote: string): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Upload messages for an app.
|
|
27
|
+
*
|
|
28
|
+
* @param path The path to the app directory.
|
|
29
|
+
* @param appId The app id to upload the messages for.
|
|
30
|
+
* @param remote The remote to upload the messages to.
|
|
31
|
+
* @param force Whether or not to force the update for locked apps.
|
|
32
|
+
*/
|
|
33
|
+
export declare function uploadMessages(path: string, appId: number, remote: string, force: boolean): Promise<void>;
|
|
34
|
+
export declare function publishSeedResources(path: string, app: App, remote: string): Promise<void>;
|
|
35
|
+
export declare function publishSeedAssets(path: string, app: App, remote: string, assetsClonable: boolean): Promise<void>;
|
|
36
|
+
export declare function parseValues(type: string, name: string, valuesToParse: Record<string, ValueFromDefinition>[]): [Record<string, ValueFromProcess>, boolean];
|
|
37
|
+
export declare function publishAppConfig(path: string, app: App, remote: string): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* @param path The path to the app directory.
|
|
40
|
+
* @param languages A list of languages for which translations should be added in addition to the
|
|
41
|
+
* existing ones.
|
|
42
|
+
* @param verify A list of languages to verify.
|
|
43
|
+
* @param format The file format that should be used for the output.
|
|
44
|
+
*/
|
|
45
|
+
export declare function writeAppMessages(path: string, languages: string[], verify: string[], format: 'json' | 'yaml'): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Resolve the app’s ID and remote based on the app context.
|
|
48
|
+
*
|
|
49
|
+
* @param appPath The path to the app.
|
|
50
|
+
* @param name Which context to use in the AppsembleRC file.
|
|
51
|
+
* @param defaultRemote The remote to fall back to.
|
|
52
|
+
* @param defaultAppId The app ID to fall back to.
|
|
53
|
+
* @returns The resolved app ID and remote.
|
|
54
|
+
*/
|
|
55
|
+
export declare function resolveAppIdAndRemote(appPath: string, name: string, defaultRemote: string, defaultAppId: number): Promise<[number, string]>;
|
|
6
56
|
interface PublishAppParams {
|
|
7
57
|
/**
|
|
8
58
|
* The OAuth2 client credentials to use.
|
|
@@ -35,19 +85,15 @@ interface PublishAppParams {
|
|
|
35
85
|
/**
|
|
36
86
|
* Whether the App should be marked as a template.
|
|
37
87
|
*/
|
|
38
|
-
template
|
|
88
|
+
template?: boolean;
|
|
39
89
|
/**
|
|
40
90
|
* Whether the App should be used in demo mode.
|
|
41
91
|
*/
|
|
42
|
-
demoMode
|
|
43
|
-
/**
|
|
44
|
-
* Whether the App should seed resources and assets in demo mode.
|
|
45
|
-
*/
|
|
46
|
-
seed: boolean;
|
|
92
|
+
demoMode?: boolean;
|
|
47
93
|
/**
|
|
48
94
|
* The icon to upload.
|
|
49
95
|
*/
|
|
50
|
-
icon
|
|
96
|
+
icon?: NodeJS.ReadStream | ReadStream;
|
|
51
97
|
/**
|
|
52
98
|
* The background color to use for the icon in opaque contexts.
|
|
53
99
|
*/
|
|
@@ -55,28 +101,28 @@ interface PublishAppParams {
|
|
|
55
101
|
/**
|
|
56
102
|
* The maskable icon to upload.
|
|
57
103
|
*/
|
|
58
|
-
maskableIcon
|
|
104
|
+
maskableIcon?: NodeJS.ReadStream | ReadStream;
|
|
59
105
|
/**
|
|
60
106
|
* Whether the API should be called with a dry run.
|
|
61
107
|
*/
|
|
62
|
-
dryRun
|
|
108
|
+
dryRun?: boolean;
|
|
63
109
|
/**
|
|
64
110
|
* Whether resources from the `resources` directory should be published after publishing the app.
|
|
65
111
|
*/
|
|
66
|
-
resources
|
|
112
|
+
resources?: boolean;
|
|
67
113
|
/**
|
|
68
114
|
* Whether assets from the `assets` directory should be published after publishing the app.
|
|
69
115
|
*/
|
|
70
|
-
assets
|
|
116
|
+
assets?: boolean;
|
|
71
117
|
/**
|
|
72
118
|
* Whether published assets should be clonable. Ignored if `assets` equals false.
|
|
73
119
|
*/
|
|
74
|
-
assetsClonable
|
|
120
|
+
assetsClonable?: boolean;
|
|
75
121
|
/**
|
|
76
122
|
* If the app context is specified,
|
|
77
123
|
* modify it for the current context to include the id of the published app.
|
|
78
124
|
*/
|
|
79
|
-
modifyContext
|
|
125
|
+
modifyContext?: boolean;
|
|
80
126
|
/**
|
|
81
127
|
* The ID to use for Google Analytics for the app.
|
|
82
128
|
*/
|
|
@@ -90,6 +136,12 @@ interface PublishAppParams {
|
|
|
90
136
|
*/
|
|
91
137
|
sentryEnvironment?: string;
|
|
92
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Publish a new app.
|
|
141
|
+
*
|
|
142
|
+
* @param options The options to use for publishing an app.
|
|
143
|
+
*/
|
|
144
|
+
export declare function publishApp({ clientCredentials, context, dryRun, modifyContext, path, ...options }: PublishAppParams): Promise<void>;
|
|
93
145
|
interface UpdateAppParams {
|
|
94
146
|
/**
|
|
95
147
|
* The OAuth2 client credentials to use.
|
|
@@ -122,23 +174,23 @@ interface UpdateAppParams {
|
|
|
122
174
|
/**
|
|
123
175
|
* Whether the App should be marked as a template.
|
|
124
176
|
*/
|
|
125
|
-
template
|
|
177
|
+
template?: boolean;
|
|
126
178
|
/**
|
|
127
179
|
* Whether the App should be used in demo mode.
|
|
128
180
|
*/
|
|
129
|
-
demoMode
|
|
181
|
+
demoMode?: boolean;
|
|
130
182
|
/**
|
|
131
183
|
* Whether resources from the `resources` directory should be published after publishing the app.
|
|
132
184
|
*/
|
|
133
|
-
resources
|
|
185
|
+
resources?: boolean;
|
|
134
186
|
/**
|
|
135
187
|
* Whether assets from the `assets` directory should be published after publishing the app.
|
|
136
188
|
*/
|
|
137
|
-
assets
|
|
189
|
+
assets?: boolean;
|
|
138
190
|
/**
|
|
139
191
|
* Whether published assets should be clonable. Ignored if `assets` equals false.
|
|
140
192
|
*/
|
|
141
|
-
assetsClonable
|
|
193
|
+
assetsClonable?: boolean;
|
|
142
194
|
/**
|
|
143
195
|
* Whether the locked property should be ignored.
|
|
144
196
|
*/
|
|
@@ -146,15 +198,15 @@ interface UpdateAppParams {
|
|
|
146
198
|
/**
|
|
147
199
|
* The icon to upload.
|
|
148
200
|
*/
|
|
149
|
-
icon
|
|
201
|
+
icon?: NodeJS.ReadStream | ReadStream;
|
|
150
202
|
/**
|
|
151
203
|
* The background color to use for the icon in opaque contexts.
|
|
152
204
|
*/
|
|
153
|
-
iconBackground
|
|
205
|
+
iconBackground?: string;
|
|
154
206
|
/**
|
|
155
207
|
* The maskable icon to upload.
|
|
156
208
|
*/
|
|
157
|
-
maskableIcon
|
|
209
|
+
maskableIcon?: NodeJS.ReadStream | ReadStream;
|
|
158
210
|
/**
|
|
159
211
|
* The ID to use for Google Analytics for the app.
|
|
160
212
|
*/
|
|
@@ -168,65 +220,12 @@ interface UpdateAppParams {
|
|
|
168
220
|
*/
|
|
169
221
|
sentryEnvironment?: string;
|
|
170
222
|
}
|
|
171
|
-
/**
|
|
172
|
-
* Traverses an app directory and appends the files it finds to the given FormData object.
|
|
173
|
-
*
|
|
174
|
-
* @param path The path of the app directory to traverse.
|
|
175
|
-
* @param formData The FormData object to append the results into..
|
|
176
|
-
* @returns The context from `.appsemblerc.yaml` if a match was found.
|
|
177
|
-
*/
|
|
178
|
-
export declare function traverseAppDirectory(path: string, formData: FormData): Promise<[AppsembleRC, string, App]>;
|
|
179
|
-
/**
|
|
180
|
-
* Export an app as a zip file.
|
|
181
|
-
*
|
|
182
|
-
* @param appId Id of the app to be exported.
|
|
183
|
-
* @param assets Boolean representing whether to include assets in the exported zip file.
|
|
184
|
-
* @param resources Boolean representing whether to include resources in the zip file.
|
|
185
|
-
* @param path Path of the folder where you want to put your downloaded file.
|
|
186
|
-
* @param remote The remote to fetch the app from.
|
|
187
|
-
*/
|
|
188
|
-
export declare function exportAppAsZip(appId: number, assets: boolean, resources: boolean, path: string, remote: string): Promise<void>;
|
|
189
|
-
/**
|
|
190
|
-
* Upload messages for an app.
|
|
191
|
-
*
|
|
192
|
-
* @param path The path to the app directory.
|
|
193
|
-
* @param appId The app id to upload the messages for.
|
|
194
|
-
* @param remote The remote to upload the messages to.
|
|
195
|
-
* @param force Whether or not to force the update for locked apps.
|
|
196
|
-
*/
|
|
197
|
-
export declare function uploadMessages(path: string, appId: number, remote: string, force: boolean): Promise<void>;
|
|
198
|
-
export declare function publishSeedResources(path: string, app: App, remote: string): Promise<void>;
|
|
199
|
-
export declare function publishSeedAssets(path: string, app: App, remote: string, assetsClonable: boolean): Promise<void>;
|
|
200
|
-
/**
|
|
201
|
-
* @param path The path to the app directory.
|
|
202
|
-
* @param languages A list of languages for which translations should be added in addition to the
|
|
203
|
-
* existing ones.
|
|
204
|
-
* @param verify A list of languages to verify.
|
|
205
|
-
* @param format The file format that should be used for the output.
|
|
206
|
-
*/
|
|
207
|
-
export declare function writeAppMessages(path: string, languages: string[], verify: string[], format: 'json' | 'yaml'): Promise<void>;
|
|
208
223
|
/**
|
|
209
224
|
* Update an existing app.
|
|
210
225
|
*
|
|
211
226
|
* @param argv The command line options used for updating the app.
|
|
212
227
|
*/
|
|
213
228
|
export declare function updateApp({ clientCredentials, context, force, path, ...options }: UpdateAppParams): Promise<void>;
|
|
214
|
-
/**
|
|
215
|
-
* Publish a new app.
|
|
216
|
-
*
|
|
217
|
-
* @param options The options to use for publishing an app.
|
|
218
|
-
*/
|
|
219
|
-
export declare function publishApp({ clientCredentials, context, dryRun, modifyContext, path, ...options }: PublishAppParams): Promise<void>;
|
|
220
|
-
/**
|
|
221
|
-
* Resolve the app’s ID and remote based on the app context.
|
|
222
|
-
*
|
|
223
|
-
* @param appPath The path to the app.
|
|
224
|
-
* @param name Which context to use in the AppsembleRC file.
|
|
225
|
-
* @param defaultRemote The remote to fall back to.
|
|
226
|
-
* @param defaultAppId The app ID to fall back to.
|
|
227
|
-
* @returns The resolved app ID and remote.
|
|
228
|
-
*/
|
|
229
|
-
export declare function resolveAppIdAndRemote(appPath: string, name: string, defaultRemote: string, defaultAppId: number): Promise<[number, string]>;
|
|
230
229
|
interface PatchAppParams {
|
|
231
230
|
/**
|
|
232
231
|
* The path at which the app is hosted.
|