@appsemble/cli 0.27.9 → 0.27.11
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/app/patch.js +7 -58
- package/commands/serve.js +1 -1
- package/lib/app.d.ts +127 -75
- package/lib/app.js +223 -125
- package/lib/app.test.d.ts +1 -0
- package/lib/app.test.js +1350 -0
- package/package.json +8 -5
- package/server/options/getAppReadmes.d.ts +2 -0
- package/server/options/getAppReadmes.js +11 -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.11)
|
|
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.11/LICENSE.md) ©
|
|
327
327
|
[Appsemble](https://appsemble.com)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Test App
|
package/commands/app/patch.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { authenticate, logger } from '@appsemble/node-utils';
|
|
2
|
-
import
|
|
3
|
-
import FormData from 'form-data';
|
|
2
|
+
import { patchApp } from '../../lib/app.js';
|
|
4
3
|
export const command = 'patch';
|
|
5
4
|
export const description = 'Change the settings of an app without having the entire source.';
|
|
6
5
|
export function builder(yargs) {
|
|
@@ -55,61 +54,11 @@ export function builder(yargs) {
|
|
|
55
54
|
}
|
|
56
55
|
export async function handler({ clientCredentials, id, remote, ...args }) {
|
|
57
56
|
await authenticate(remote, 'apps:write', clientCredentials);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
formData.append('force', String(args.force));
|
|
65
|
-
}
|
|
66
|
-
if (args.demoMode) {
|
|
67
|
-
logger.info(`Setting app demo mode to ${args.demoMode}`);
|
|
68
|
-
formData.append('demoMode', String(args.demoMode));
|
|
69
|
-
}
|
|
70
|
-
if (args.template) {
|
|
71
|
-
logger.info(`Setting template to ${args.template}`);
|
|
72
|
-
formData.append('template', String(args.template));
|
|
73
|
-
}
|
|
74
|
-
if (args.visibility) {
|
|
75
|
-
logger.info(`Setting app visibility to ${args.visibility}`);
|
|
76
|
-
formData.append('visibility', args.visibility);
|
|
77
|
-
}
|
|
78
|
-
if (args.iconBackground) {
|
|
79
|
-
logger.info(`Setting app icon background to ${args.iconBackground}`);
|
|
80
|
-
formData.append('iconBackground', args.iconBackground);
|
|
81
|
-
}
|
|
82
|
-
if (args.showAppDefinition) {
|
|
83
|
-
logger.info(`Setting showAppDefinition to ${args.showAppDefinition}`);
|
|
84
|
-
formData.append('showAppDefinition', String(args.showAppDefinition));
|
|
85
|
-
}
|
|
86
|
-
if (args.showAppsembleLogin) {
|
|
87
|
-
logger.info(`Setting showAppsembleLogin to ${args.showAppsembleLogin}`);
|
|
88
|
-
formData.append('showAppsembleLogin', String(args.showAppsembleLogin));
|
|
89
|
-
}
|
|
90
|
-
if (args.showAppsembleOAuth2Login) {
|
|
91
|
-
logger.info(`Setting showAppsembleOAuth2Login to ${args.showAppsembleOAuth2Login}`);
|
|
92
|
-
formData.append('showAppsembleOAuth2Login', String(args.showAppsembleOAuth2Login));
|
|
93
|
-
}
|
|
94
|
-
if (args.enableSelfRegistration) {
|
|
95
|
-
logger.info(`Setting enableSelfRegistration to ${args.enableSelfRegistration}`);
|
|
96
|
-
formData.append('enableSelfRegistration', String(args.enableSelfRegistration));
|
|
97
|
-
}
|
|
98
|
-
try {
|
|
99
|
-
if (args.locked) {
|
|
100
|
-
await axios.post(`api/apps/${id}/lock`, {
|
|
101
|
-
locked: args.locked,
|
|
102
|
-
});
|
|
103
|
-
logger.info(`Successfully set app lock value for app with id ${id} to ${args.locked}`);
|
|
104
|
-
if (!formData.getLengthSync()) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
await axios.patch(`/api/apps/${id}`, formData);
|
|
109
|
-
logger.info(`Successfully updated app with id ${id}`);
|
|
110
|
-
}
|
|
111
|
-
catch (error) {
|
|
112
|
-
logger.error(error);
|
|
113
|
-
}
|
|
57
|
+
logger.info(`Patching app ${id}`);
|
|
58
|
+
await patchApp({
|
|
59
|
+
...args,
|
|
60
|
+
id,
|
|
61
|
+
remote,
|
|
62
|
+
});
|
|
114
63
|
}
|
|
115
64
|
//# sourceMappingURL=patch.js.map
|
package/commands/serve.js
CHANGED
|
@@ -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))) {
|
package/lib/app.d.ts
CHANGED
|
@@ -1,8 +1,56 @@
|
|
|
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 AppsembleRC, type AppVisibility } from '@appsemble/types';
|
|
4
|
+
import { type App, type AppLock, type AppsembleContext, type AppsembleRC, type AppVisibility } 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
|
+
/**
|
|
37
|
+
* @param path The path to the app directory.
|
|
38
|
+
* @param languages A list of languages for which translations should be added in addition to the
|
|
39
|
+
* existing ones.
|
|
40
|
+
* @param verify A list of languages to verify.
|
|
41
|
+
* @param format The file format that should be used for the output.
|
|
42
|
+
*/
|
|
43
|
+
export declare function writeAppMessages(path: string, languages: string[], verify: string[], format: 'json' | 'yaml'): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Resolve the app’s ID and remote based on the app context.
|
|
46
|
+
*
|
|
47
|
+
* @param appPath The path to the app.
|
|
48
|
+
* @param name Which context to use in the AppsembleRC file.
|
|
49
|
+
* @param defaultRemote The remote to fall back to.
|
|
50
|
+
* @param defaultAppId The app ID to fall back to.
|
|
51
|
+
* @returns The resolved app ID and remote.
|
|
52
|
+
*/
|
|
53
|
+
export declare function resolveAppIdAndRemote(appPath: string, name: string, defaultRemote: string, defaultAppId: number): Promise<[number, string]>;
|
|
6
54
|
interface PublishAppParams {
|
|
7
55
|
/**
|
|
8
56
|
* The OAuth2 client credentials to use.
|
|
@@ -35,19 +83,15 @@ interface PublishAppParams {
|
|
|
35
83
|
/**
|
|
36
84
|
* Whether the App should be marked as a template.
|
|
37
85
|
*/
|
|
38
|
-
template
|
|
86
|
+
template?: boolean;
|
|
39
87
|
/**
|
|
40
88
|
* Whether the App should be used in demo mode.
|
|
41
89
|
*/
|
|
42
|
-
demoMode
|
|
43
|
-
/**
|
|
44
|
-
* Whether the App should seed resources and assets in demo mode.
|
|
45
|
-
*/
|
|
46
|
-
seed: boolean;
|
|
90
|
+
demoMode?: boolean;
|
|
47
91
|
/**
|
|
48
92
|
* The icon to upload.
|
|
49
93
|
*/
|
|
50
|
-
icon
|
|
94
|
+
icon?: NodeJS.ReadStream | ReadStream;
|
|
51
95
|
/**
|
|
52
96
|
* The background color to use for the icon in opaque contexts.
|
|
53
97
|
*/
|
|
@@ -55,28 +99,28 @@ interface PublishAppParams {
|
|
|
55
99
|
/**
|
|
56
100
|
* The maskable icon to upload.
|
|
57
101
|
*/
|
|
58
|
-
maskableIcon
|
|
102
|
+
maskableIcon?: NodeJS.ReadStream | ReadStream;
|
|
59
103
|
/**
|
|
60
104
|
* Whether the API should be called with a dry run.
|
|
61
105
|
*/
|
|
62
|
-
dryRun
|
|
106
|
+
dryRun?: boolean;
|
|
63
107
|
/**
|
|
64
108
|
* Whether resources from the `resources` directory should be published after publishing the app.
|
|
65
109
|
*/
|
|
66
|
-
resources
|
|
110
|
+
resources?: boolean;
|
|
67
111
|
/**
|
|
68
112
|
* Whether assets from the `assets` directory should be published after publishing the app.
|
|
69
113
|
*/
|
|
70
|
-
assets
|
|
114
|
+
assets?: boolean;
|
|
71
115
|
/**
|
|
72
116
|
* Whether published assets should be clonable. Ignored if `assets` equals false.
|
|
73
117
|
*/
|
|
74
|
-
assetsClonable
|
|
118
|
+
assetsClonable?: boolean;
|
|
75
119
|
/**
|
|
76
120
|
* If the app context is specified,
|
|
77
121
|
* modify it for the current context to include the id of the published app.
|
|
78
122
|
*/
|
|
79
|
-
modifyContext
|
|
123
|
+
modifyContext?: boolean;
|
|
80
124
|
/**
|
|
81
125
|
* The ID to use for Google Analytics for the app.
|
|
82
126
|
*/
|
|
@@ -90,6 +134,12 @@ interface PublishAppParams {
|
|
|
90
134
|
*/
|
|
91
135
|
sentryEnvironment?: string;
|
|
92
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Publish a new app.
|
|
139
|
+
*
|
|
140
|
+
* @param options The options to use for publishing an app.
|
|
141
|
+
*/
|
|
142
|
+
export declare function publishApp({ clientCredentials, context, dryRun, modifyContext, path, ...options }: PublishAppParams): Promise<void>;
|
|
93
143
|
interface UpdateAppParams {
|
|
94
144
|
/**
|
|
95
145
|
* The OAuth2 client credentials to use.
|
|
@@ -122,23 +172,23 @@ interface UpdateAppParams {
|
|
|
122
172
|
/**
|
|
123
173
|
* Whether the App should be marked as a template.
|
|
124
174
|
*/
|
|
125
|
-
template
|
|
175
|
+
template?: boolean;
|
|
126
176
|
/**
|
|
127
177
|
* Whether the App should be used in demo mode.
|
|
128
178
|
*/
|
|
129
|
-
demoMode
|
|
179
|
+
demoMode?: boolean;
|
|
130
180
|
/**
|
|
131
181
|
* Whether resources from the `resources` directory should be published after publishing the app.
|
|
132
182
|
*/
|
|
133
|
-
resources
|
|
183
|
+
resources?: boolean;
|
|
134
184
|
/**
|
|
135
185
|
* Whether assets from the `assets` directory should be published after publishing the app.
|
|
136
186
|
*/
|
|
137
|
-
assets
|
|
187
|
+
assets?: boolean;
|
|
138
188
|
/**
|
|
139
189
|
* Whether published assets should be clonable. Ignored if `assets` equals false.
|
|
140
190
|
*/
|
|
141
|
-
assetsClonable
|
|
191
|
+
assetsClonable?: boolean;
|
|
142
192
|
/**
|
|
143
193
|
* Whether the locked property should be ignored.
|
|
144
194
|
*/
|
|
@@ -146,15 +196,15 @@ interface UpdateAppParams {
|
|
|
146
196
|
/**
|
|
147
197
|
* The icon to upload.
|
|
148
198
|
*/
|
|
149
|
-
icon
|
|
199
|
+
icon?: NodeJS.ReadStream | ReadStream;
|
|
150
200
|
/**
|
|
151
201
|
* The background color to use for the icon in opaque contexts.
|
|
152
202
|
*/
|
|
153
|
-
iconBackground
|
|
203
|
+
iconBackground?: string;
|
|
154
204
|
/**
|
|
155
205
|
* The maskable icon to upload.
|
|
156
206
|
*/
|
|
157
|
-
maskableIcon
|
|
207
|
+
maskableIcon?: NodeJS.ReadStream | ReadStream;
|
|
158
208
|
/**
|
|
159
209
|
* The ID to use for Google Analytics for the app.
|
|
160
210
|
*/
|
|
@@ -168,63 +218,65 @@ interface UpdateAppParams {
|
|
|
168
218
|
*/
|
|
169
219
|
sentryEnvironment?: string;
|
|
170
220
|
}
|
|
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
221
|
/**
|
|
209
222
|
* Update an existing app.
|
|
210
223
|
*
|
|
211
224
|
* @param argv The command line options used for updating the app.
|
|
212
225
|
*/
|
|
213
226
|
export declare function updateApp({ clientCredentials, context, force, path, ...options }: UpdateAppParams): Promise<void>;
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
227
|
+
interface PatchAppParams {
|
|
228
|
+
/**
|
|
229
|
+
* The path at which the app is hosted.
|
|
230
|
+
*/
|
|
231
|
+
path?: string;
|
|
232
|
+
/**
|
|
233
|
+
* Whether the locked property should be ignored.
|
|
234
|
+
*/
|
|
235
|
+
force?: boolean;
|
|
236
|
+
/**
|
|
237
|
+
* The ID of the app to update.
|
|
238
|
+
*/
|
|
239
|
+
id?: number;
|
|
240
|
+
/**
|
|
241
|
+
* Visibility of the app in the public app store.
|
|
242
|
+
*/
|
|
243
|
+
visibility?: AppVisibility;
|
|
244
|
+
/**
|
|
245
|
+
* The remote server to create the app on.
|
|
246
|
+
*/
|
|
247
|
+
remote: string;
|
|
248
|
+
/**
|
|
249
|
+
* Whether the App should be marked as a template.
|
|
250
|
+
*/
|
|
251
|
+
template?: boolean;
|
|
252
|
+
/**
|
|
253
|
+
* Whether the App should be used in demo mode.
|
|
254
|
+
*/
|
|
255
|
+
demoMode?: boolean;
|
|
256
|
+
/**
|
|
257
|
+
* The background color to use for the icon in opaque contexts.
|
|
258
|
+
*/
|
|
259
|
+
iconBackground?: string;
|
|
260
|
+
/**
|
|
261
|
+
* Whether or not the app definition is exposed for display in Appsemble Studio.
|
|
262
|
+
*/
|
|
263
|
+
showAppDefinition?: boolean;
|
|
264
|
+
/**
|
|
265
|
+
* Whether the Appsemble password login method should be shown.
|
|
266
|
+
*/
|
|
267
|
+
showAppsembleLogin?: boolean;
|
|
268
|
+
/**
|
|
269
|
+
* Whether the Appsemble OAuth2 login method should be shown.
|
|
270
|
+
*/
|
|
271
|
+
showAppsembleOAuth2Login?: boolean;
|
|
272
|
+
/**
|
|
273
|
+
* Whether new users should be able to register themselves.
|
|
274
|
+
*/
|
|
275
|
+
enableSelfRegistration?: boolean;
|
|
276
|
+
/**
|
|
277
|
+
* Whether the app is currently locked.
|
|
278
|
+
*/
|
|
279
|
+
locked?: AppLock;
|
|
280
|
+
}
|
|
281
|
+
export declare function patchApp({ id, remote, ...options }: PatchAppParams): Promise<void>;
|
|
230
282
|
export {};
|