@appsemble/cli 0.18.26 → 0.18.30
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/commands/app/create.d.ts +2 -1
- package/dist/commands/app/create.js +9 -3
- package/dist/commands/app/create.js.map +1 -1
- package/dist/commands/app/update.js +4 -2
- package/dist/commands/app/update.js.map +1 -1
- package/dist/commands/asset/create.d.ts +15 -0
- package/dist/commands/asset/create.js +66 -0
- package/dist/commands/asset/create.js.map +1 -0
- package/dist/commands/asset.d.ts +4 -0
- package/dist/commands/asset.js +11 -0
- package/dist/commands/asset.js.map +1 -0
- package/dist/commands/block/build.js +3 -4
- package/dist/commands/block/build.js.map +1 -1
- package/dist/commands/block/extract-messages.js +3 -4
- package/dist/commands/block/extract-messages.js.map +1 -1
- package/dist/commands/block/publish.js +4 -6
- package/dist/commands/block/publish.js.map +1 -1
- package/dist/commands/config/get.js +2 -1
- package/dist/commands/config/get.js.map +1 -1
- package/dist/commands/config/set.js +2 -1
- package/dist/commands/config/set.js.map +1 -1
- package/dist/commands/organization/create.js +9 -31
- package/dist/commands/organization/create.js.map +1 -1
- package/dist/commands/organization/update.js +9 -30
- package/dist/commands/organization/update.js.map +1 -1
- package/dist/commands/resource/create.d.ts +3 -1
- package/dist/commands/resource/create.js +17 -7
- package/dist/commands/resource/create.js.map +1 -1
- package/dist/commands/resource/update.d.ts +3 -1
- package/dist/commands/resource/update.js +18 -8
- package/dist/commands/resource/update.js.map +1 -1
- package/dist/commands/start.js +2 -2
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/team/create.d.ts +14 -0
- package/dist/commands/team/create.js +44 -0
- package/dist/commands/team/create.js.map +1 -0
- package/dist/commands/team/delete.d.ts +13 -0
- package/dist/commands/team/delete.js +39 -0
- package/dist/commands/team/delete.js.map +1 -0
- package/dist/commands/team/member/delete.d.ts +14 -0
- package/dist/commands/team/member/delete.js +44 -0
- package/dist/commands/team/member/delete.js.map +1 -0
- package/dist/commands/team/member/invite.d.ts +14 -0
- package/dist/commands/team/member/invite.js +44 -0
- package/dist/commands/team/member/invite.js.map +1 -0
- package/dist/commands/team/member/update.d.ts +16 -0
- package/dist/commands/team/member/update.js +51 -0
- package/dist/commands/team/member/update.js.map +1 -0
- package/dist/commands/team/member.d.ts +4 -0
- package/dist/commands/team/member.js +11 -0
- package/dist/commands/team/member.js.map +1 -0
- package/dist/commands/team/update.d.ts +15 -0
- package/dist/commands/team/update.js +40 -0
- package/dist/commands/team/update.js.map +1 -0
- package/dist/commands/team.d.ts +4 -0
- package/dist/commands/team.js +11 -0
- package/dist/commands/team.js.map +1 -0
- package/dist/lib/app.d.ts +146 -0
- package/dist/lib/app.js +332 -9
- package/dist/lib/app.js.map +1 -1
- package/dist/lib/{createResource.d.ts → asset.d.ts} +5 -4
- package/dist/lib/asset.js +23 -0
- package/dist/lib/asset.js.map +1 -0
- package/dist/lib/block.d.ts +61 -0
- package/dist/lib/block.js +297 -0
- package/dist/lib/block.js.map +1 -0
- package/dist/lib/getBlockConfigFromTypeScript.js +4 -3
- package/dist/lib/getBlockConfigFromTypeScript.js.map +1 -1
- package/dist/lib/organization.d.ts +21 -0
- package/dist/lib/organization.js +65 -0
- package/dist/lib/organization.js.map +1 -0
- package/dist/lib/{updateResource.d.ts → resource.d.ts} +19 -0
- package/dist/lib/{updateResource.js → resource.js} +17 -2
- package/dist/lib/resource.js.map +1 -0
- package/dist/lib/serverImport.js +4 -3
- package/dist/lib/serverImport.js.map +1 -1
- package/dist/lib/team.d.ts +53 -0
- package/dist/lib/team.js +64 -0
- package/dist/lib/team.js.map +1 -0
- package/dist/types.d.ts +2 -2
- package/package.json +5 -5
- package/dist/lib/buildBlock.d.ts +0 -9
- package/dist/lib/buildBlock.js +0 -39
- package/dist/lib/buildBlock.js.map +0 -1
- package/dist/lib/createApp.d.ts +0 -59
- package/dist/lib/createApp.js +0 -120
- package/dist/lib/createApp.js.map +0 -1
- package/dist/lib/createResource.js +0 -25
- package/dist/lib/createResource.js.map +0 -1
- package/dist/lib/discoverBlocks.d.ts +0 -10
- package/dist/lib/discoverBlocks.js +0 -24
- package/dist/lib/discoverBlocks.js.map +0 -1
- package/dist/lib/getBlockConfig.d.ts +0 -8
- package/dist/lib/getBlockConfig.js +0 -45
- package/dist/lib/getBlockConfig.js.map +0 -1
- package/dist/lib/makePayload.d.ts +0 -9
- package/dist/lib/makePayload.js +0 -94
- package/dist/lib/makePayload.js.map +0 -1
- package/dist/lib/processBlockMessages.d.ts +0 -2
- package/dist/lib/processBlockMessages.js +0 -43
- package/dist/lib/processBlockMessages.js.map +0 -1
- package/dist/lib/publishBlock.d.ts +0 -8
- package/dist/lib/publishBlock.js +0 -32
- package/dist/lib/publishBlock.js.map +0 -1
- package/dist/lib/traverseAppDirectory.d.ts +0 -11
- package/dist/lib/traverseAppDirectory.js +0 -94
- package/dist/lib/traverseAppDirectory.js.map +0 -1
- package/dist/lib/traverseBlockThemes.d.ts +0 -9
- package/dist/lib/traverseBlockThemes.js +0 -40
- package/dist/lib/traverseBlockThemes.js.map +0 -1
- package/dist/lib/updateApp.d.ts +0 -55
- package/dist/lib/updateApp.js +0 -78
- package/dist/lib/updateApp.js.map +0 -1
- package/dist/lib/updateResource.js.map +0 -1
- package/dist/lib/uploadAppBlockTheme.d.ts +0 -11
- package/dist/lib/uploadAppBlockTheme.js +0 -33
- package/dist/lib/uploadAppBlockTheme.js.map +0 -1
- package/dist/lib/uploadMessages.d.ts +0 -9
- package/dist/lib/uploadMessages.js +0 -39
- package/dist/lib/uploadMessages.js.map +0 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.updateOrganization = exports.createOrganization = void 0;
|
|
7
|
+
const node_utils_1 = require("@appsemble/node-utils");
|
|
8
|
+
const axios_1 = __importDefault(require("axios"));
|
|
9
|
+
const form_data_1 = __importDefault(require("form-data"));
|
|
10
|
+
async function createOrganization({ description, email, icon, id, name, website, }) {
|
|
11
|
+
const formData = new form_data_1.default();
|
|
12
|
+
formData.append('id', id);
|
|
13
|
+
if (description) {
|
|
14
|
+
node_utils_1.logger.info(`Setting description to ${description}`);
|
|
15
|
+
formData.append('description', description);
|
|
16
|
+
}
|
|
17
|
+
if (email) {
|
|
18
|
+
node_utils_1.logger.info(`Setting email to ${email}`);
|
|
19
|
+
formData.append('email', email);
|
|
20
|
+
}
|
|
21
|
+
if (icon) {
|
|
22
|
+
node_utils_1.logger.info(`Including icon ${icon.path || 'from stdin'}`);
|
|
23
|
+
formData.append('icon', icon);
|
|
24
|
+
}
|
|
25
|
+
if (name) {
|
|
26
|
+
node_utils_1.logger.info(`Setting name to ${name}`);
|
|
27
|
+
formData.append('name', name);
|
|
28
|
+
}
|
|
29
|
+
if (website) {
|
|
30
|
+
node_utils_1.logger.info(`Setting website to ${website}`);
|
|
31
|
+
formData.append('website', website);
|
|
32
|
+
}
|
|
33
|
+
node_utils_1.logger.info(`Creating organization ${id}${name ? ` (${name})` : ''}`);
|
|
34
|
+
await axios_1.default.post('/api/organizations', formData);
|
|
35
|
+
node_utils_1.logger.info(`Successfully created organization ${id}${name ? ` (${name})` : ''}`);
|
|
36
|
+
}
|
|
37
|
+
exports.createOrganization = createOrganization;
|
|
38
|
+
async function updateOrganization({ description, email, icon, id, name, website, }) {
|
|
39
|
+
node_utils_1.logger.info(`Updating organization ${id}${name ? ` (${name})` : ''}`);
|
|
40
|
+
const formData = new form_data_1.default();
|
|
41
|
+
if (description) {
|
|
42
|
+
node_utils_1.logger.info(`Setting description to ${description}`);
|
|
43
|
+
formData.append('description', description);
|
|
44
|
+
}
|
|
45
|
+
if (email) {
|
|
46
|
+
node_utils_1.logger.info(`Setting email to ${email}`);
|
|
47
|
+
formData.append('email', email);
|
|
48
|
+
}
|
|
49
|
+
if (icon) {
|
|
50
|
+
node_utils_1.logger.info(`Including icon ${icon.path || 'from stdin'}`);
|
|
51
|
+
formData.append('icon', icon);
|
|
52
|
+
}
|
|
53
|
+
if (name) {
|
|
54
|
+
node_utils_1.logger.info(`Setting name to ${name}`);
|
|
55
|
+
formData.append('name', name);
|
|
56
|
+
}
|
|
57
|
+
if (website) {
|
|
58
|
+
node_utils_1.logger.info(`Setting website to ${website}`);
|
|
59
|
+
formData.append('website', website);
|
|
60
|
+
}
|
|
61
|
+
await axios_1.default.patch(`/api/organizations/${id}`, formData);
|
|
62
|
+
node_utils_1.logger.info(`Successfully updated organization ${id}${name ? ` (${name})` : ''}`);
|
|
63
|
+
}
|
|
64
|
+
exports.updateOrganization = updateOrganization;
|
|
65
|
+
//# sourceMappingURL=organization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization.js","sourceRoot":"","sources":["../../src/lib/organization.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA+C;AAC/C,kDAA0B;AAC1B,0DAAiC;AAqB1B,KAAK,UAAU,kBAAkB,CAAC,EACvC,WAAW,EACX,KAAK,EACL,IAAI,EACJ,EAAE,EACF,IAAI,EACJ,OAAO,GACqB;IAC5B,MAAM,QAAQ,GAAG,IAAI,mBAAQ,EAAE,CAAC;IAChC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAE1B,IAAI,WAAW,EAAE;QACf,mBAAM,CAAC,IAAI,CAAC,0BAA0B,WAAW,EAAE,CAAC,CAAC;QACrD,QAAQ,CAAC,MAAM,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;KAC7C;IAED,IAAI,KAAK,EAAE;QACT,mBAAM,CAAC,IAAI,CAAC,oBAAoB,KAAK,EAAE,CAAC,CAAC;QACzC,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;KACjC;IAED,IAAI,IAAI,EAAE;QACR,mBAAM,CAAC,IAAI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EAAE,WAAW,CAAC,CAAC;KAC7C;IAED,IAAI,KAAK,EAAE;QACT,mBAAM,CAAC,IAAI,CAAC,oBAAoB,KAAK,EAAE,CAAC,CAAC;QACzC,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;KACjC;IAED,IAAI,IAAI,EAAE;QACR,mBAAM,CAAC,IAAI,CAAC,kBAAkB,IAAI,CAAC,IAAI,IAAI,YAAY,EAAE,CAAC,CAAC;QAC3D,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;KAC/B;IAED,IAAI,IAAI,EAAE;QACR,mBAAM,CAAC,IAAI,CAAC,mBAAmB,IAAI,EAAE,CAAC,CAAC;QACvC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;KAC/B;IAED,IAAI,OAAO,EAAE;QACX,mBAAM,CAAC,IAAI,CAAC,sBAAsB,OAAO,EAAE,CAAC,CAAC;QAC7C,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;KACrC;IAED,MAAM,eAAK,CAAC,KAAK,CAAC,sBAAsB,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAC;IACxD,mBAAM,CAAC,IAAI,CAAC,qCAAqC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACpF,CAAC;AAvCD,gDAuCC"}
|
|
@@ -16,5 +16,24 @@ interface UpdateResourceParams {
|
|
|
16
16
|
*/
|
|
17
17
|
remote: string;
|
|
18
18
|
}
|
|
19
|
+
interface CreateResourceParams {
|
|
20
|
+
/**
|
|
21
|
+
* The name of the resource that a new entry is being created of.
|
|
22
|
+
*/
|
|
23
|
+
resourceName: string;
|
|
24
|
+
/**
|
|
25
|
+
* The path in which the resource JSON is located.
|
|
26
|
+
*/
|
|
27
|
+
path: string;
|
|
28
|
+
/**
|
|
29
|
+
* The ID of the app to create a resource entry for.
|
|
30
|
+
*/
|
|
31
|
+
appId: number;
|
|
32
|
+
/**
|
|
33
|
+
* The remote server to create the app on.
|
|
34
|
+
*/
|
|
35
|
+
remote: string;
|
|
36
|
+
}
|
|
37
|
+
export declare function createResource({ appId, path, remote, resourceName, }: CreateResourceParams): Promise<void>;
|
|
19
38
|
export declare function updateResource({ appId, path, remote, resourceName, }: UpdateResourceParams): Promise<void>;
|
|
20
39
|
export {};
|
|
@@ -3,10 +3,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.updateResource = void 0;
|
|
6
|
+
exports.updateResource = exports.createResource = void 0;
|
|
7
7
|
const url_1 = require("url");
|
|
8
8
|
const node_utils_1 = require("@appsemble/node-utils");
|
|
9
9
|
const axios_1 = __importDefault(require("axios"));
|
|
10
|
+
async function createResource({ appId, path, remote, resourceName, }) {
|
|
11
|
+
const [file] = await node_utils_1.readData(path);
|
|
12
|
+
if (typeof file !== 'object') {
|
|
13
|
+
throw new node_utils_1.AppsembleError(`File at ${path} does not contain an object or array of objects`);
|
|
14
|
+
}
|
|
15
|
+
const resources = [].concat(file);
|
|
16
|
+
node_utils_1.logger.info(`Creating ${resources.length} resource(s) from ${path}`);
|
|
17
|
+
for (const resource of resources) {
|
|
18
|
+
const { data: { id }, } = await axios_1.default.post(`/api/apps/${appId}/resources/${resourceName}`, resource, {
|
|
19
|
+
baseURL: remote,
|
|
20
|
+
});
|
|
21
|
+
node_utils_1.logger.info(`Successfully created resource ${id} at ${new url_1.URL(`/apps/${appId}/resources/${resourceName}/${id}`, remote)}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.createResource = createResource;
|
|
10
25
|
async function updateResource({ appId, path, remote, resourceName, }) {
|
|
11
26
|
const [file] = await node_utils_1.readData(path);
|
|
12
27
|
if (typeof file !== 'object') {
|
|
@@ -26,4 +41,4 @@ async function updateResource({ appId, path, remote, resourceName, }) {
|
|
|
26
41
|
}
|
|
27
42
|
}
|
|
28
43
|
exports.updateResource = updateResource;
|
|
29
|
-
//# sourceMappingURL=
|
|
44
|
+
//# sourceMappingURL=resource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.js","sourceRoot":"","sources":["../../src/lib/resource.ts"],"names":[],"mappings":";;;;;;AAAA,6BAA0B;AAE1B,sDAAyE;AAEzE,kDAA0B;AA8CnB,KAAK,UAAU,cAAc,CAAC,EACnC,KAAK,EACL,IAAI,EACJ,MAAM,EACN,YAAY,GACS;IACrB,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,qBAAQ,CAAW,IAAI,CAAC,CAAC;IAE9C,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,MAAM,IAAI,2BAAc,CAAC,WAAW,IAAI,iDAAiD,CAAC,CAAC;KAC5F;IAED,MAAM,SAAS,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAClC,mBAAM,CAAC,IAAI,CAAC,YAAY,SAAS,CAAC,MAAM,qBAAqB,IAAI,EAAE,CAAC,CAAC;IAErE,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;QAChC,MAAM,EACJ,IAAI,EAAE,EAAE,EAAE,EAAE,GACb,GAAG,MAAM,eAAK,CAAC,IAAI,CAAW,aAAa,KAAK,cAAc,YAAY,EAAE,EAAE,QAAQ,EAAE;YACvF,OAAO,EAAE,MAAM;SAChB,CAAC,CAAC;QAEH,mBAAM,CAAC,IAAI,CACT,iCAAiC,EAAE,OAAO,IAAI,SAAG,CAC/C,SAAS,KAAK,cAAc,YAAY,IAAI,EAAE,EAAE,EAChD,MAAM,CACP,EAAE,CACJ,CAAC;KACH;AACH,CAAC;AA7BD,wCA6BC;AAEM,KAAK,UAAU,cAAc,CAAC,EACnC,KAAK,EACL,IAAI,EACJ,MAAM,EACN,YAAY,GACS;IACrB,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,qBAAQ,CAAW,IAAI,CAAC,CAAC;IAE9C,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,MAAM,IAAI,2BAAc,CAAC,WAAW,IAAI,iDAAiD,CAAC,CAAC;KAC5F;IAED,MAAM,SAAS,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAClC,mBAAM,CAAC,IAAI,CAAC,YAAY,SAAS,CAAC,MAAM,qBAAqB,IAAI,EAAE,CAAC,CAAC;IAErE,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;QAChC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;YAChB,mBAAM,CAAC,IAAI,CAAC,qBAAqB,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAC,CAAC;YACtF,SAAS;SACV;QAED,MAAM,EACJ,IAAI,EAAE,EAAE,EAAE,EAAE,GACb,GAAG,MAAM,eAAK,CAAC,GAAG,CACjB,aAAa,KAAK,cAAc,YAAY,IAAI,QAAQ,CAAC,EAAE,EAAE,EAC7D,QAAQ,EACR;YACE,OAAO,EAAE,MAAM;SAChB,CACF,CAAC;QAEF,mBAAM,CAAC,IAAI,CACT,iCAAiC,EAAE,OAAO,IAAI,SAAG,CAC/C,SAAS,KAAK,cAAc,YAAY,IAAI,EAAE,EAAE,EAChD,MAAM,CACP,EAAE,CACJ,CAAC;KACH;AACH,CAAC;AAtCD,wCAsCC"}
|
package/dist/lib/serverImport.js
CHANGED
|
@@ -21,6 +21,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.serverImport = void 0;
|
|
23
23
|
const node_utils_1 = require("@appsemble/node-utils");
|
|
24
|
+
const utils_1 = require("@appsemble/utils");
|
|
24
25
|
const PROMPT = process.platform === 'win32' ? '>' : '$';
|
|
25
26
|
const COMMAND = /yarn/.test(process.env.npm_execpath)
|
|
26
27
|
? 'yarn add --dev --ignore-workspace-root-check'
|
|
@@ -43,11 +44,11 @@ async function serverImport(...members) {
|
|
|
43
44
|
// build time, but while type checking.
|
|
44
45
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
45
46
|
const mod = await Promise.resolve().then(() => __importStar(require('@appsemble/server')));
|
|
46
|
-
|
|
47
|
-
if (!
|
|
47
|
+
for (const member of members) {
|
|
48
|
+
if (!utils_1.has(mod, member)) {
|
|
48
49
|
throw new Error(`@appsemble/server does not export ${member}`);
|
|
49
50
|
}
|
|
50
|
-
}
|
|
51
|
+
}
|
|
51
52
|
return mod;
|
|
52
53
|
}
|
|
53
54
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverImport.js","sourceRoot":"","sources":["../../src/lib/serverImport.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,sDAAuD;
|
|
1
|
+
{"version":3,"file":"serverImport.js","sourceRoot":"","sources":["../../src/lib/serverImport.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,sDAAuD;AACvD,4CAAuC;AAEvC,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;AACxD,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;IACnD,CAAC,CAAC,8CAA8C;IAChD,CAAC,CAAC,wBAAwB,CAAC;AAC7B,MAAM,eAAe,GAAG;;EAEtB,MAAM,IAAI,OAAO;CAClB,CAAC;AAEF;;;;;GAKG;AACI,KAAK,UAAU,YAAY,CAEhC,GAAG,OAAY;;IACf,IAAI;QACF,qEAAqE;QACrE,4FAA4F;QAC5F,uCAAuC;QACvC,6DAA6D;QAC7D,MAAM,GAAG,GAAG,wDAAa,mBAAmB,GAAC,CAAC;QAC9C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;YAC5B,IAAI,CAAC,WAAG,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE;gBACrB,MAAM,IAAI,KAAK,CAAC,qCAAqC,MAAM,EAAE,CAAC,CAAC;aAChE;SACF;QACD,OAAO,GAAG,CAAC;KACZ;IAAC,OAAO,KAAc,EAAE;QACvB,IACG,KAAa,CAAC,IAAI,KAAK,kBAAkB;YAC1C,CAAA,MAAC,KAAa,CAAC,YAAY,0CAAG,CAAC,CAAC,MAAK,UAAU,EAC/C;YACA,MAAM,KAAK,CAAC;SACb;QACD,MAAM,IAAI,2BAAc,CAAC,eAAe,CAAC,CAAC;KAC3C;AACH,CAAC;AAxBD,oCAwBC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { TeamRole } from '@appsemble/utils';
|
|
2
|
+
interface SharedTeamParams {
|
|
3
|
+
/**
|
|
4
|
+
* The ID of the app to create the team for.
|
|
5
|
+
*/
|
|
6
|
+
appId: number;
|
|
7
|
+
}
|
|
8
|
+
interface SharedExistingTeamParams extends SharedTeamParams {
|
|
9
|
+
/**
|
|
10
|
+
* The ID of the team.
|
|
11
|
+
*/
|
|
12
|
+
id: number;
|
|
13
|
+
}
|
|
14
|
+
interface SharedTeamMemberParams extends SharedExistingTeamParams {
|
|
15
|
+
/**
|
|
16
|
+
* The ID or email adress of the team member.
|
|
17
|
+
*/
|
|
18
|
+
user: string;
|
|
19
|
+
}
|
|
20
|
+
interface UpdateTeamMemberParams extends SharedTeamMemberParams {
|
|
21
|
+
/**
|
|
22
|
+
* The new role of the team member.
|
|
23
|
+
*/
|
|
24
|
+
role: TeamRole;
|
|
25
|
+
}
|
|
26
|
+
interface UpdateTeamParams extends SharedExistingTeamParams {
|
|
27
|
+
/**
|
|
28
|
+
* The new name of the team.
|
|
29
|
+
*/
|
|
30
|
+
name?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The list of annotations to apply in key=value format.
|
|
33
|
+
*/
|
|
34
|
+
annotations?: string[];
|
|
35
|
+
}
|
|
36
|
+
interface CreateTeamParams extends SharedTeamParams {
|
|
37
|
+
/**
|
|
38
|
+
* The name of the team.
|
|
39
|
+
*/
|
|
40
|
+
name: string;
|
|
41
|
+
/**
|
|
42
|
+
* The list of annotations to apply in key=value format.
|
|
43
|
+
*/
|
|
44
|
+
annotations?: string[];
|
|
45
|
+
}
|
|
46
|
+
export declare function resolveAnnotations(annotations: string[]): Record<string, string>;
|
|
47
|
+
export declare function createTeam({ appId, name, annotations, }: CreateTeamParams): Promise<void>;
|
|
48
|
+
export declare function deleteTeam({ appId, id }: SharedExistingTeamParams): Promise<void>;
|
|
49
|
+
export declare function updateTeam({ appId, id, name, annotations, }: UpdateTeamParams): Promise<void>;
|
|
50
|
+
export declare function inviteMember({ appId, id, user }: SharedTeamMemberParams): Promise<void>;
|
|
51
|
+
export declare function updateMember({ appId, id, role, user, }: UpdateTeamMemberParams): Promise<void>;
|
|
52
|
+
export declare function deleteMember({ appId, id, user }: SharedTeamMemberParams): Promise<void>;
|
|
53
|
+
export {};
|
package/dist/lib/team.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.deleteMember = exports.updateMember = exports.inviteMember = exports.updateTeam = exports.deleteTeam = exports.createTeam = exports.resolveAnnotations = void 0;
|
|
7
|
+
const node_utils_1 = require("@appsemble/node-utils");
|
|
8
|
+
const axios_1 = __importDefault(require("axios"));
|
|
9
|
+
function resolveAnnotations(annotations) {
|
|
10
|
+
const annotationRegex = /^\w+=.+$/;
|
|
11
|
+
if (annotations.some((a) => !annotationRegex.test(a))) {
|
|
12
|
+
throw new node_utils_1.AppsembleError('One of the annotations did not follow the pattern of key=value');
|
|
13
|
+
}
|
|
14
|
+
return annotations.length
|
|
15
|
+
? Object.fromEntries(annotations.map((annotation) => {
|
|
16
|
+
const [key, ...value] = annotation.split('=');
|
|
17
|
+
return [key, value.join('=')];
|
|
18
|
+
}))
|
|
19
|
+
: undefined;
|
|
20
|
+
}
|
|
21
|
+
exports.resolveAnnotations = resolveAnnotations;
|
|
22
|
+
async function createTeam({ appId, name, annotations = [], }) {
|
|
23
|
+
node_utils_1.logger.info(`Creating team ${name}`);
|
|
24
|
+
const { data: { id }, } = await axios_1.default.post(`/api/apps/${appId}/teams`, {
|
|
25
|
+
name,
|
|
26
|
+
annotations: resolveAnnotations(annotations),
|
|
27
|
+
});
|
|
28
|
+
node_utils_1.logger.info(`Successfully created team ${name} with ID ${id}`);
|
|
29
|
+
}
|
|
30
|
+
exports.createTeam = createTeam;
|
|
31
|
+
async function deleteTeam({ appId, id }) {
|
|
32
|
+
node_utils_1.logger.info(`Deleting team ${id}`);
|
|
33
|
+
await axios_1.default.delete(`/api/apps/${appId}/teams/${id}`);
|
|
34
|
+
node_utils_1.logger.info(`Successfully deleted team ${id}`);
|
|
35
|
+
}
|
|
36
|
+
exports.deleteTeam = deleteTeam;
|
|
37
|
+
async function updateTeam({ appId, id, name, annotations = [], }) {
|
|
38
|
+
node_utils_1.logger.info(`Updating team ${id}`);
|
|
39
|
+
await axios_1.default.put(`/api/apps/${appId}/teams/${id}`, {
|
|
40
|
+
name,
|
|
41
|
+
annotations: resolveAnnotations(annotations),
|
|
42
|
+
});
|
|
43
|
+
node_utils_1.logger.info(`Successfully updated team ${id}`);
|
|
44
|
+
}
|
|
45
|
+
exports.updateTeam = updateTeam;
|
|
46
|
+
async function inviteMember({ appId, id, user }) {
|
|
47
|
+
node_utils_1.logger.info(`Inviting ${user} to team ${id}`);
|
|
48
|
+
await axios_1.default.post(`/api/apps/${appId}/teams/${id}/members`, { id: user });
|
|
49
|
+
node_utils_1.logger.info(`Successfully invited ${user} to team ${id}`);
|
|
50
|
+
}
|
|
51
|
+
exports.inviteMember = inviteMember;
|
|
52
|
+
async function updateMember({ appId, id, role, user, }) {
|
|
53
|
+
node_utils_1.logger.info(`Updating ${user}’s role in team ${id} to ${role}`);
|
|
54
|
+
await axios_1.default.put(`/api/apps/${appId}/teams/${id}/members/${user}`, { role });
|
|
55
|
+
node_utils_1.logger.info(`Successfully updated ${user} in team ${id}`);
|
|
56
|
+
}
|
|
57
|
+
exports.updateMember = updateMember;
|
|
58
|
+
async function deleteMember({ appId, id, user }) {
|
|
59
|
+
node_utils_1.logger.info(`Deleting ${user} to team ${id}`);
|
|
60
|
+
await axios_1.default.delete(`/api/apps/${appId}/teams/${id}/members/${user}`);
|
|
61
|
+
node_utils_1.logger.info(`Successfully deleted ${user} from team ${id}`);
|
|
62
|
+
}
|
|
63
|
+
exports.deleteMember = deleteMember;
|
|
64
|
+
//# sourceMappingURL=team.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"team.js","sourceRoot":"","sources":["../../src/lib/team.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA+D;AAE/D,kDAA0B;AAsD1B,SAAgB,kBAAkB,CAAC,WAAqB;IACtD,MAAM,eAAe,GAAG,UAAU,CAAC;IAEnC,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;QACrD,MAAM,IAAI,2BAAc,CAAC,gEAAgE,CAAC,CAAC;KAC5F;IAED,OAAO,WAAW,CAAC,MAAM;QACvB,CAAC,CAAC,MAAM,CAAC,WAAW,CAChB,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;YAC7B,MAAM,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC9C,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QAChC,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AAK,EAAE,EAAE,EAAE,IAAI,EAA0B;IAC5E,mBAAM,CAAC,IAAI,CAAC,YAAY,IAAI,YAAY,EAAE,EAAE,CAAC,CAAC;IAC9C,MAAM,eAAK,CAAC,IAAI,CAAC,aAAa,KAAK,UAAU,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IACzE,mBAAM,CAAC,IAAI,CAAC,wBAAwB,IAAI,YAAY,EAAE,EAAE,CAAC,CAAC;AAC5D,CAAC;AAJD,oCAIC;AAEM,KAAK,UAAU,YAAY,CAAC,EACjC,KAAK,EACL,EAAE,EACF,IAAI,EACJ,IAAI,GACmB;IACvB,mBAAM,CAAC,IAAI,CAAC,YAAY,IAAI,mBAAmB,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC;IAChE,MAAM,eAAK,CAAC,GAAG,CAAC,aAAa,KAAK,UAAU,EAAE,YAAY,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5E,mBAAM,CAAC,IAAI,CAAC,wBAAwB,IAAI,YAAY,EAAE,EAAE,CAAC,CAAC;AAC5D,CAAC;AATD,oCASC;AAEM,KAAK,UAAU,YAAY,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAA0B;IAC5E,mBAAM,CAAC,IAAI,CAAC,YAAY,IAAI,YAAY,EAAE,EAAE,CAAC,CAAC;IAC9C,MAAM,eAAK,CAAC,MAAM,CAAC,aAAa,KAAK,UAAU,EAAE,YAAY,IAAI,EAAE,CAAC,CAAC;IACrE,mBAAM,CAAC,IAAI,CAAC,wBAAwB,IAAI,cAAc,EAAE,EAAE,CAAC,CAAC;AAC9D,CAAC;AAJD,oCAIC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -55,10 +55,10 @@ export interface AppsembleContext {
|
|
|
55
55
|
iconBackground?: string;
|
|
56
56
|
maskableIcon?: string;
|
|
57
57
|
/**
|
|
58
|
-
* If `id` is specified, this will override `--
|
|
58
|
+
* If `id` is specified, this will override `--id` passed by the command line when
|
|
59
59
|
* updating an app.
|
|
60
60
|
*/
|
|
61
|
-
id?:
|
|
61
|
+
id?: number;
|
|
62
62
|
/**
|
|
63
63
|
* If `private` is specified, this will override `--private` passed on the command line.
|
|
64
64
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appsemble/cli",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.30",
|
|
4
4
|
"description": "The CLI for developing with Appsemble apps and blocks",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"app",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"test": "jest"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@appsemble/node-utils": "0.18.
|
|
36
|
-
"@appsemble/types": "0.18.
|
|
37
|
-
"@appsemble/utils": "0.18.
|
|
35
|
+
"@appsemble/node-utils": "0.18.30",
|
|
36
|
+
"@appsemble/types": "0.18.30",
|
|
37
|
+
"@appsemble/utils": "0.18.30",
|
|
38
38
|
"@fortawesome/fontawesome-common-types": "^0.2.35",
|
|
39
39
|
"axios": "^0.21.1",
|
|
40
40
|
"chalk": "^4.1.1",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"yargs": "^17.0.1"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@appsemble/types": "0.18.
|
|
59
|
+
"@appsemble/types": "0.18.30",
|
|
60
60
|
"@types/concat-stream": "^1.6.1",
|
|
61
61
|
"@types/fs-extra": "^9.0.12",
|
|
62
62
|
"@types/inquirer": "^7.3.3",
|
package/dist/lib/buildBlock.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { BlockConfig } from '@appsemble/types';
|
|
2
|
-
import { Stats } from 'webpack';
|
|
3
|
-
/**
|
|
4
|
-
* Builds a block using Webpack.
|
|
5
|
-
*
|
|
6
|
-
* @param config - The config of the block to build.
|
|
7
|
-
* @returns The Webpack stats object.
|
|
8
|
-
*/
|
|
9
|
-
export declare function buildBlock(config: BlockConfig): Promise<Stats>;
|
package/dist/lib/buildBlock.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildBlock = void 0;
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
const node_utils_1 = require("@appsemble/node-utils");
|
|
6
|
-
const fs_extra_1 = require("fs-extra");
|
|
7
|
-
const webpack_1 = require("webpack");
|
|
8
|
-
const loadWebpackConfig_1 = require("./loadWebpackConfig");
|
|
9
|
-
/**
|
|
10
|
-
* Builds a block using Webpack.
|
|
11
|
-
*
|
|
12
|
-
* @param config - The config of the block to build.
|
|
13
|
-
* @returns The Webpack stats object.
|
|
14
|
-
*/
|
|
15
|
-
async function buildBlock(config) {
|
|
16
|
-
const conf = await loadWebpackConfig_1.loadWebpackConfig(config, 'production', path_1.join(config.dir, config.output));
|
|
17
|
-
if (await fs_extra_1.pathExists(conf.output.path)) {
|
|
18
|
-
node_utils_1.logger.warn(`Removing ${conf.output.path}`);
|
|
19
|
-
await fs_extra_1.remove(conf.output.path);
|
|
20
|
-
}
|
|
21
|
-
node_utils_1.logger.info(`Building ${config.name}@${config.version} 🔨`);
|
|
22
|
-
const compiler = webpack_1.webpack(conf);
|
|
23
|
-
return new Promise((resolve, reject) => {
|
|
24
|
-
compiler.run((err, stats) => {
|
|
25
|
-
if (err) {
|
|
26
|
-
reject(err);
|
|
27
|
-
}
|
|
28
|
-
else if (stats.hasErrors()) {
|
|
29
|
-
reject(new node_utils_1.AppsembleError(stats.toString({ colors: true })));
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
node_utils_1.logger.verbose(stats.toString({ colors: true }));
|
|
33
|
-
resolve(stats);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
exports.buildBlock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AAC,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;gBACjD,OAAO,CAAC,KAAK,CAAC,CAAC;aAChB;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAtBD,gCAsBC"}
|
package/dist/lib/createApp.d.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { ReadStream } from 'fs';
|
|
3
|
-
interface CreateAppParams {
|
|
4
|
-
/**
|
|
5
|
-
* The OAuth2 client credentials to use.
|
|
6
|
-
*/
|
|
7
|
-
clientCredentials: string;
|
|
8
|
-
/**
|
|
9
|
-
* If specified, the context matching this name is used, overriding command line flags.
|
|
10
|
-
*/
|
|
11
|
-
context?: string;
|
|
12
|
-
/**
|
|
13
|
-
* The ID of the organization to upload for.
|
|
14
|
-
*/
|
|
15
|
-
organization: string;
|
|
16
|
-
/**
|
|
17
|
-
* The path in which the App YAML is located.
|
|
18
|
-
*/
|
|
19
|
-
path: string;
|
|
20
|
-
/**
|
|
21
|
-
* Whether the App should be marked as private.
|
|
22
|
-
*/
|
|
23
|
-
private: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* The remote server to create the app on.
|
|
26
|
-
*/
|
|
27
|
-
remote: string;
|
|
28
|
-
/**
|
|
29
|
-
* Whether the App should be marked as a template.
|
|
30
|
-
*/
|
|
31
|
-
template: boolean;
|
|
32
|
-
/**
|
|
33
|
-
* The icon to upload.
|
|
34
|
-
*/
|
|
35
|
-
icon: NodeJS.ReadStream | ReadStream;
|
|
36
|
-
/**
|
|
37
|
-
* The background color to use for the icon in opaque contexts.
|
|
38
|
-
*/
|
|
39
|
-
iconBackground: string;
|
|
40
|
-
/**
|
|
41
|
-
* The maskable icon to upload.
|
|
42
|
-
*/
|
|
43
|
-
maskableIcon: NodeJS.ReadStream | ReadStream;
|
|
44
|
-
/**
|
|
45
|
-
* Whether the API should be called with a dry run.
|
|
46
|
-
*/
|
|
47
|
-
dryRun: boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Whether resources from the `resources` directory should be created after creating the app.
|
|
50
|
-
*/
|
|
51
|
-
resources: boolean;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Create a new App.
|
|
55
|
-
*
|
|
56
|
-
* @param options - The options to use for creating an app.
|
|
57
|
-
*/
|
|
58
|
-
export declare function createApp({ clientCredentials, context, dryRun, path, resources, ...options }: CreateAppParams): Promise<void>;
|
|
59
|
-
export {};
|
package/dist/lib/createApp.js
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createApp = void 0;
|
|
7
|
-
const fs_1 = require("fs");
|
|
8
|
-
const path_1 = require("path");
|
|
9
|
-
const url_1 = require("url");
|
|
10
|
-
const util_1 = require("util");
|
|
11
|
-
const node_utils_1 = require("@appsemble/node-utils");
|
|
12
|
-
const axios_1 = __importDefault(require("axios"));
|
|
13
|
-
const form_data_1 = __importDefault(require("form-data"));
|
|
14
|
-
const fs_extra_1 = require("fs-extra");
|
|
15
|
-
const authentication_1 = require("./authentication");
|
|
16
|
-
const createResource_1 = require("./createResource");
|
|
17
|
-
const traverseAppDirectory_1 = require("./traverseAppDirectory");
|
|
18
|
-
const traverseBlockThemes_1 = require("./traverseBlockThemes");
|
|
19
|
-
const uploadMessages_1 = require("./uploadMessages");
|
|
20
|
-
/**
|
|
21
|
-
* Create a new App.
|
|
22
|
-
*
|
|
23
|
-
* @param options - The options to use for creating an app.
|
|
24
|
-
*/
|
|
25
|
-
async function createApp({ clientCredentials, context, dryRun, path, resources, ...options }) {
|
|
26
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
27
|
-
const file = await fs_1.promises.stat(path);
|
|
28
|
-
const formData = new form_data_1.default();
|
|
29
|
-
let appsembleContext;
|
|
30
|
-
if (file.isFile()) {
|
|
31
|
-
// Assuming file is App YAML
|
|
32
|
-
const [app, data] = await node_utils_1.readData(path);
|
|
33
|
-
formData.append('yaml', data);
|
|
34
|
-
formData.append('definition', JSON.stringify(app));
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
appsembleContext = await traverseAppDirectory_1.traverseAppDirectory(path, context, formData);
|
|
38
|
-
}
|
|
39
|
-
const remote = (_a = appsembleContext.remote) !== null && _a !== void 0 ? _a : options.remote;
|
|
40
|
-
const organizationId = (_b = appsembleContext.organization) !== null && _b !== void 0 ? _b : options.organization;
|
|
41
|
-
const template = (_d = (_c = appsembleContext.template) !== null && _c !== void 0 ? _c : options.template) !== null && _d !== void 0 ? _d : false;
|
|
42
|
-
const isPrivate = (_e = appsembleContext.private) !== null && _e !== void 0 ? _e : options.private;
|
|
43
|
-
const iconBackground = (_f = appsembleContext.iconBackground) !== null && _f !== void 0 ? _f : options.iconBackground;
|
|
44
|
-
const icon = (_g = options.icon) !== null && _g !== void 0 ? _g : appsembleContext.icon;
|
|
45
|
-
const maskableIcon = (_h = options.maskableIcon) !== null && _h !== void 0 ? _h : appsembleContext.maskableIcon;
|
|
46
|
-
node_utils_1.logger.verbose(`App remote: ${remote}`);
|
|
47
|
-
node_utils_1.logger.verbose(`App organzation: ${organizationId}`);
|
|
48
|
-
node_utils_1.logger.verbose(`App is template: ${util_1.inspect(template, { colors: true })}`);
|
|
49
|
-
node_utils_1.logger.verbose(`App is private: ${util_1.inspect(isPrivate, { colors: true })}`);
|
|
50
|
-
node_utils_1.logger.verbose(`Icon background: ${iconBackground}`);
|
|
51
|
-
if (!organizationId) {
|
|
52
|
-
throw new node_utils_1.AppsembleError('An organization id must be passed as a command line flag or in the context');
|
|
53
|
-
}
|
|
54
|
-
formData.append('OrganizationId', organizationId);
|
|
55
|
-
formData.append('template', String(template));
|
|
56
|
-
formData.append('private', String(isPrivate));
|
|
57
|
-
formData.append('iconBackground', iconBackground);
|
|
58
|
-
if (icon) {
|
|
59
|
-
const realIcon = typeof icon === 'string' ? fs_1.createReadStream(icon) : icon;
|
|
60
|
-
node_utils_1.logger.info(`Using icon from ${(_j = realIcon.path) !== null && _j !== void 0 ? _j : 'stdin'}`);
|
|
61
|
-
formData.append('icon', realIcon);
|
|
62
|
-
}
|
|
63
|
-
if (maskableIcon) {
|
|
64
|
-
const realIcon = typeof maskableIcon === 'string' ? fs_1.createReadStream(maskableIcon) : maskableIcon;
|
|
65
|
-
node_utils_1.logger.info(`Using icon from ${(_k = realIcon.path) !== null && _k !== void 0 ? _k : 'stdin'}`);
|
|
66
|
-
formData.append('icon', realIcon);
|
|
67
|
-
}
|
|
68
|
-
await authentication_1.authenticate(remote, resources ? 'apps:write resources:write' : 'apps:write', clientCredentials);
|
|
69
|
-
const { data } = await axios_1.default.post('/api/apps', formData, { baseURL: remote, params: { dryRun } });
|
|
70
|
-
if (dryRun) {
|
|
71
|
-
node_utils_1.logger.info('Skipped uploading block themes and app messages.');
|
|
72
|
-
node_utils_1.logger.info('Successfully ran dry run. The app should be valid when creating it.');
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
if (file.isDirectory() && !dryRun) {
|
|
76
|
-
// After uploading the app, upload block styles and messages if they are available
|
|
77
|
-
await traverseBlockThemes_1.traverseBlockThemes(path, data.id, remote, false);
|
|
78
|
-
await uploadMessages_1.uploadMessages(path, data.id, remote, false);
|
|
79
|
-
if (resources && fs_1.existsSync(path_1.join(path, 'resources'))) {
|
|
80
|
-
const resourcePath = path_1.join(path, 'resources');
|
|
81
|
-
try {
|
|
82
|
-
const resourceFiles = await fs_1.promises.readdir(resourcePath, { withFileTypes: true });
|
|
83
|
-
for (const resource of resourceFiles) {
|
|
84
|
-
if (resource.isFile()) {
|
|
85
|
-
const { name } = path_1.parse(resource.name);
|
|
86
|
-
await createResource_1.createResource({
|
|
87
|
-
appId: data.id,
|
|
88
|
-
path: path_1.join(resourcePath, resource.name),
|
|
89
|
-
remote,
|
|
90
|
-
resourceName: name,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
else if (resource.isDirectory()) {
|
|
94
|
-
const subDirectoryResources = await fs_extra_1.readdir(path_1.join(resourcePath, resource.name), {
|
|
95
|
-
withFileTypes: true,
|
|
96
|
-
});
|
|
97
|
-
for (const subResource of subDirectoryResources.filter((s) => s.isFile())) {
|
|
98
|
-
await createResource_1.createResource({
|
|
99
|
-
appId: data.id,
|
|
100
|
-
path: path_1.join(resourcePath, resource.name, subResource.name),
|
|
101
|
-
remote,
|
|
102
|
-
resourceName: resource.name,
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
catch (error) {
|
|
109
|
-
node_utils_1.logger.error('Something went wrong when creating resources:');
|
|
110
|
-
node_utils_1.logger.error(error);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
const { host, protocol } = new url_1.URL(remote);
|
|
115
|
-
node_utils_1.logger.info(`Successfully created app ${data.definition.name}! 🙌`);
|
|
116
|
-
node_utils_1.logger.info(`App URL: ${protocol}//${data.path}.${data.OrganizationId}.${host}`);
|
|
117
|
-
node_utils_1.logger.info(`App store page: ${new url_1.URL(`/apps/${data.id}`, remote)}`);
|
|
118
|
-
}
|
|
119
|
-
exports.createApp = createApp;
|
|
120
|
-
//# sourceMappingURL=createApp.js.map
|