@appsemble/cli 0.27.12 → 0.28.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/README.md +3 -3
- package/commands/app/delete.js +2 -10
- package/commands/app/export.js +2 -3
- package/commands/block/delete.js +2 -3
- package/commands/team/create.js +1 -2
- package/commands/team/delete.js +1 -2
- package/lib/app.d.ts +8 -1
- package/lib/app.js +21 -4
- package/lib/app.test.js +495 -23
- package/lib/asset.test.d.ts +1 -0
- package/lib/asset.test.js +101 -0
- package/lib/block.d.ts +2 -1
- package/lib/block.js +3 -2
- package/lib/block.test.js +52 -1
- package/lib/organization.js +5 -3
- package/lib/organization.test.d.ts +1 -0
- package/lib/organization.test.js +222 -0
- package/lib/resource.test.d.ts +1 -0
- package/lib/resource.test.js +391 -0
- package/lib/team.d.ts +6 -2
- package/lib/team.js +6 -4
- package/lib/team.test.d.ts +1 -0
- package/lib/team.test.js +606 -0
- package/lib/testUtils.d.ts +2 -0
- package/lib/testUtils.js +11 -0
- package/package.json +6 -6
- package/server/options/parseQuery.test.js +2 -0
- 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.28.0)
|
|
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.
|
|
326
|
+
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.28.0/LICENSE.md) ©
|
|
327
327
|
[Appsemble](https://appsemble.com)
|
package/commands/app/delete.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import axios from 'axios';
|
|
1
|
+
import { deleteApp } from '../../lib/app.js';
|
|
3
2
|
export const command = 'delete';
|
|
4
3
|
export const description = 'Delete an app using the app id.';
|
|
5
4
|
export function builder(yargs) {
|
|
@@ -9,13 +8,6 @@ export function builder(yargs) {
|
|
|
9
8
|
});
|
|
10
9
|
}
|
|
11
10
|
export async function handler({ clientCredentials, id, remote, }) {
|
|
12
|
-
await
|
|
13
|
-
const response = await axios.get(`/api/apps/${id}`);
|
|
14
|
-
const { name } = response.data;
|
|
15
|
-
logger.warn(`Deleting app: ${name}`);
|
|
16
|
-
axios.delete(`/api/apps/${id}`, {
|
|
17
|
-
baseURL: remote,
|
|
18
|
-
});
|
|
19
|
-
logger.info(`Successfully deleted ${name} app.`);
|
|
11
|
+
await deleteApp({ id, remote, clientCredentials });
|
|
20
12
|
}
|
|
21
13
|
//# sourceMappingURL=delete.js.map
|
package/commands/app/export.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
|
-
import {
|
|
2
|
+
import { logger } from '@appsemble/node-utils';
|
|
3
3
|
import { exportAppAsZip } from '../../lib/app.js';
|
|
4
4
|
export const command = 'export';
|
|
5
5
|
export const description = `Export an app as a zip file using app id.
|
|
@@ -24,9 +24,8 @@ export function builder(yargs) {
|
|
|
24
24
|
export async function handler(args) {
|
|
25
25
|
const { assets = false, clientCredentials, id: appId, path: outputDirectory, remote, resources = false, } = args;
|
|
26
26
|
const defaultOutputDirectory = join(process.cwd(), 'apps');
|
|
27
|
-
await authenticate(remote, 'apps:export', clientCredentials);
|
|
28
27
|
logger.info(`Exporting app with id: ${appId}`);
|
|
29
|
-
await exportAppAsZip(appId, assets, resources, outputDirectory || defaultOutputDirectory, remote);
|
|
28
|
+
await exportAppAsZip(clientCredentials, appId, assets, resources, outputDirectory || defaultOutputDirectory, remote);
|
|
30
29
|
logger.info('Export completed successfully');
|
|
31
30
|
}
|
|
32
31
|
//# sourceMappingURL=export.js.map
|
package/commands/block/delete.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { logger } from '@appsemble/node-utils';
|
|
2
2
|
import { deleteBlock } from '../../lib/block.js';
|
|
3
3
|
export const command = 'delete <block>';
|
|
4
4
|
export const description = 'Delete a specific block version. Using this outside local development is discouraged.';
|
|
@@ -13,9 +13,8 @@ export function builder(yargs) {
|
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
export async function handler({ block, clientCredentials, organization, remote, }) {
|
|
16
|
-
await authenticate(remote, 'blocks:delete', clientCredentials);
|
|
17
16
|
const [blockName, blockVersion] = block.split(':');
|
|
18
17
|
logger.info(`Deleting Block ${block}`);
|
|
19
|
-
await deleteBlock({ organization, blockName, blockVersion, remote });
|
|
18
|
+
await deleteBlock({ organization, blockName, blockVersion, remote, clientCredentials });
|
|
20
19
|
}
|
|
21
20
|
//# sourceMappingURL=delete.js.map
|
package/commands/team/create.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { authenticate } from '@appsemble/node-utils';
|
|
2
1
|
import { resolveAppIdAndRemote } from '../../lib/app.js';
|
|
3
2
|
import { createTeam } from '../../lib/team.js';
|
|
4
3
|
export const command = 'create <name>';
|
|
@@ -28,12 +27,12 @@ export function builder(yargs) {
|
|
|
28
27
|
}
|
|
29
28
|
export async function handler({ annotation, app, appId, clientCredentials, context, name, remote, }) {
|
|
30
29
|
const [resolvedAppId, resolvedRemote] = await resolveAppIdAndRemote(app, context, remote, appId);
|
|
31
|
-
await authenticate(resolvedRemote, 'teams:write', clientCredentials);
|
|
32
30
|
await createTeam({
|
|
33
31
|
name,
|
|
34
32
|
appId: resolvedAppId,
|
|
35
33
|
annotations: annotation,
|
|
36
34
|
remote: resolvedRemote,
|
|
35
|
+
clientCredentials,
|
|
37
36
|
});
|
|
38
37
|
}
|
|
39
38
|
//# sourceMappingURL=create.js.map
|
package/commands/team/delete.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { authenticate } from '@appsemble/node-utils';
|
|
2
1
|
import { resolveAppIdAndRemote } from '../../lib/app.js';
|
|
3
2
|
import { deleteTeam } from '../../lib/team.js';
|
|
4
3
|
export const command = 'delete';
|
|
@@ -24,11 +23,11 @@ export function builder(yargs) {
|
|
|
24
23
|
}
|
|
25
24
|
export async function handler({ app, appId, clientCredentials, context, id, remote, }) {
|
|
26
25
|
const [resolvedAppId, resolvedRemote] = await resolveAppIdAndRemote(app, context, remote, appId);
|
|
27
|
-
await authenticate(resolvedRemote, 'teams:write', clientCredentials);
|
|
28
26
|
await deleteTeam({
|
|
29
27
|
id,
|
|
30
28
|
appId: resolvedAppId,
|
|
31
29
|
remote: resolvedRemote,
|
|
30
|
+
clientCredentials,
|
|
32
31
|
});
|
|
33
32
|
}
|
|
34
33
|
//# sourceMappingURL=delete.js.map
|
package/lib/app.d.ts
CHANGED
|
@@ -15,13 +15,14 @@ export declare function traverseAppDirectory(path: string, context: string, form
|
|
|
15
15
|
/**
|
|
16
16
|
* Export an app as a zip file.
|
|
17
17
|
*
|
|
18
|
+
* @param clientCredentials The OAuth2 client credentials to use
|
|
18
19
|
* @param appId Id of the app to be exported.
|
|
19
20
|
* @param assets Boolean representing whether to include assets in the exported zip file.
|
|
20
21
|
* @param resources Boolean representing whether to include resources in the zip file.
|
|
21
22
|
* @param path Path of the folder where you want to put your downloaded file.
|
|
22
23
|
* @param remote The remote to fetch the app from.
|
|
23
24
|
*/
|
|
24
|
-
export declare function exportAppAsZip(appId: number, assets: boolean, resources: boolean, path: string, remote: string): Promise<void>;
|
|
25
|
+
export declare function exportAppAsZip(clientCredentials: string, appId: number, assets: boolean, resources: boolean, path: string, remote: string): Promise<void>;
|
|
25
26
|
/**
|
|
26
27
|
* Upload messages for an app.
|
|
27
28
|
*
|
|
@@ -31,6 +32,12 @@ export declare function exportAppAsZip(appId: number, assets: boolean, resources
|
|
|
31
32
|
* @param force Whether or not to force the update for locked apps.
|
|
32
33
|
*/
|
|
33
34
|
export declare function uploadMessages(path: string, appId: number, remote: string, force: boolean): Promise<void>;
|
|
35
|
+
interface DeleteAppArgs {
|
|
36
|
+
remote: string;
|
|
37
|
+
id: number;
|
|
38
|
+
clientCredentials: string;
|
|
39
|
+
}
|
|
40
|
+
export declare function deleteApp({ clientCredentials, id, remote }: DeleteAppArgs): Promise<void>;
|
|
34
41
|
export declare function publishSeedResources(path: string, app: App, remote: string): Promise<void>;
|
|
35
42
|
export declare function publishSeedAssets(path: string, app: App, remote: string, assetsClonable: boolean): Promise<void>;
|
|
36
43
|
export declare function parseValues(type: string, name: string, valuesToParse: Record<string, ValueFromDefinition>[]): [Record<string, ValueFromProcess>, boolean];
|
package/lib/app.js
CHANGED
|
@@ -152,6 +152,13 @@ export async function traverseAppDirectory(path, context, formData) {
|
|
|
152
152
|
: maskableIconPath;
|
|
153
153
|
return [discoveredContext, rc, yaml, gatheredData];
|
|
154
154
|
}
|
|
155
|
+
function extractFilenameFromContentDisposition(contentDisposition) {
|
|
156
|
+
const match = contentDisposition.match(/filename="(.+?)"/);
|
|
157
|
+
if (match && match.length > 1) {
|
|
158
|
+
return match[1];
|
|
159
|
+
}
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
155
162
|
async function retrieveContext(path, context) {
|
|
156
163
|
let rc;
|
|
157
164
|
let discoveredContext;
|
|
@@ -190,20 +197,20 @@ async function retrieveContext(path, context) {
|
|
|
190
197
|
/**
|
|
191
198
|
* Export an app as a zip file.
|
|
192
199
|
*
|
|
200
|
+
* @param clientCredentials The OAuth2 client credentials to use
|
|
193
201
|
* @param appId Id of the app to be exported.
|
|
194
202
|
* @param assets Boolean representing whether to include assets in the exported zip file.
|
|
195
203
|
* @param resources Boolean representing whether to include resources in the zip file.
|
|
196
204
|
* @param path Path of the folder where you want to put your downloaded file.
|
|
197
205
|
* @param remote The remote to fetch the app from.
|
|
198
206
|
*/
|
|
199
|
-
export async function exportAppAsZip(appId, assets, resources, path, remote) {
|
|
200
|
-
|
|
201
|
-
const { name } = app.data.definition;
|
|
207
|
+
export async function exportAppAsZip(clientCredentials, appId, assets, resources, path, remote) {
|
|
208
|
+
await authenticate(remote, 'apps:export', clientCredentials);
|
|
202
209
|
const response = await axios.get(`/api/apps/${appId}/export?resources=${resources}&assets=${assets}`, {
|
|
203
210
|
baseURL: remote,
|
|
204
211
|
responseType: 'stream',
|
|
205
212
|
});
|
|
206
|
-
const zipFileName = join(path,
|
|
213
|
+
const zipFileName = join(path, String(extractFilenameFromContentDisposition(response.headers['content-disposition'])));
|
|
207
214
|
const writeStream = createWriteStream(zipFileName);
|
|
208
215
|
response.data.pipe(writeStream);
|
|
209
216
|
logger.info(`Successfully downloaded file: ${zipFileName}`);
|
|
@@ -236,6 +243,16 @@ export async function uploadMessages(path, appId, remote, force) {
|
|
|
236
243
|
logger.info(`Successfully uploaded messages for language “${language.language}” 🎉`);
|
|
237
244
|
}
|
|
238
245
|
}
|
|
246
|
+
export async function deleteApp({ clientCredentials, id, remote }) {
|
|
247
|
+
await authenticate(remote, 'apps:delete', clientCredentials);
|
|
248
|
+
const response = await axios.get(`/api/apps/${id}`);
|
|
249
|
+
const { name } = response.data;
|
|
250
|
+
logger.warn(`Deleting app: ${name}`);
|
|
251
|
+
await axios.delete(`/api/apps/${id}`, {
|
|
252
|
+
baseURL: remote,
|
|
253
|
+
});
|
|
254
|
+
logger.info(`Successfully deleted app with id ${id}`);
|
|
255
|
+
}
|
|
239
256
|
export async function publishSeedResources(path, app, remote) {
|
|
240
257
|
var _a, _b;
|
|
241
258
|
const resourcesPath = join(path, 'resources');
|