@appsemble/cli 0.18.27 → 0.18.31

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.
Files changed (130) hide show
  1. package/dist/commands/app/create.d.ts +2 -1
  2. package/dist/commands/app/create.js +9 -3
  3. package/dist/commands/app/create.js.map +1 -1
  4. package/dist/commands/app/update.js +4 -2
  5. package/dist/commands/app/update.js.map +1 -1
  6. package/dist/commands/asset/create.d.ts +15 -0
  7. package/dist/commands/asset/create.js +66 -0
  8. package/dist/commands/asset/create.js.map +1 -0
  9. package/dist/commands/asset.d.ts +4 -0
  10. package/dist/commands/asset.js +11 -0
  11. package/dist/commands/asset.js.map +1 -0
  12. package/dist/commands/block/build.js +3 -4
  13. package/dist/commands/block/build.js.map +1 -1
  14. package/dist/commands/block/extract-messages.js +3 -4
  15. package/dist/commands/block/extract-messages.js.map +1 -1
  16. package/dist/commands/block/publish.js +4 -6
  17. package/dist/commands/block/publish.js.map +1 -1
  18. package/dist/commands/config/get.js +2 -1
  19. package/dist/commands/config/get.js.map +1 -1
  20. package/dist/commands/config/set.js +2 -1
  21. package/dist/commands/config/set.js.map +1 -1
  22. package/dist/commands/organization/create.js +9 -31
  23. package/dist/commands/organization/create.js.map +1 -1
  24. package/dist/commands/organization/update.js +9 -30
  25. package/dist/commands/organization/update.js.map +1 -1
  26. package/dist/commands/resource/create.d.ts +3 -1
  27. package/dist/commands/resource/create.js +17 -7
  28. package/dist/commands/resource/create.js.map +1 -1
  29. package/dist/commands/resource/update.d.ts +3 -1
  30. package/dist/commands/resource/update.js +18 -8
  31. package/dist/commands/resource/update.js.map +1 -1
  32. package/dist/commands/start.js +2 -2
  33. package/dist/commands/start.js.map +1 -1
  34. package/dist/commands/{app/team → team}/create.d.ts +5 -2
  35. package/dist/commands/team/create.js +44 -0
  36. package/dist/commands/team/create.js.map +1 -0
  37. package/dist/commands/{app/team → team}/delete.d.ts +4 -2
  38. package/dist/commands/team/delete.js +39 -0
  39. package/dist/commands/team/delete.js.map +1 -0
  40. package/dist/commands/{app/team → team}/member/delete.d.ts +4 -2
  41. package/dist/commands/{app/team → team}/member/delete.js +16 -6
  42. package/dist/commands/team/member/delete.js.map +1 -0
  43. package/dist/commands/{app/team → team}/member/invite.d.ts +4 -2
  44. package/dist/commands/{app/team → team}/member/invite.js +16 -6
  45. package/dist/commands/team/member/invite.js.map +1 -0
  46. package/dist/commands/{app/team → team}/member/update.d.ts +4 -2
  47. package/dist/commands/{app/team → team}/member/update.js +16 -6
  48. package/dist/commands/team/member/update.js.map +1 -0
  49. package/dist/commands/{app/team → team}/member.d.ts +0 -0
  50. package/dist/commands/{app/team → team}/member.js +0 -0
  51. package/dist/commands/team/member.js.map +1 -0
  52. package/dist/commands/{app/team → team}/update.d.ts +4 -2
  53. package/dist/commands/{app/team → team}/update.js +7 -10
  54. package/dist/commands/team/update.js.map +1 -0
  55. package/dist/commands/{app/team.d.ts → team.d.ts} +0 -0
  56. package/dist/commands/{app/team.js → team.js} +0 -0
  57. package/dist/commands/team.js.map +1 -0
  58. package/dist/lib/app.d.ts +146 -0
  59. package/dist/lib/app.js +332 -9
  60. package/dist/lib/app.js.map +1 -1
  61. package/dist/lib/{createResource.d.ts → asset.d.ts} +5 -4
  62. package/dist/lib/asset.js +23 -0
  63. package/dist/lib/asset.js.map +1 -0
  64. package/dist/lib/block.d.ts +61 -0
  65. package/dist/lib/block.js +297 -0
  66. package/dist/lib/block.js.map +1 -0
  67. package/dist/lib/getBlockConfigFromTypeScript.js +4 -3
  68. package/dist/lib/getBlockConfigFromTypeScript.js.map +1 -1
  69. package/dist/lib/organization.d.ts +21 -0
  70. package/dist/lib/organization.js +65 -0
  71. package/dist/lib/organization.js.map +1 -0
  72. package/dist/lib/{updateResource.d.ts → resource.d.ts} +19 -0
  73. package/dist/lib/{updateResource.js → resource.js} +17 -2
  74. package/dist/lib/resource.js.map +1 -0
  75. package/dist/lib/serverImport.js +4 -3
  76. package/dist/lib/serverImport.js.map +1 -1
  77. package/dist/lib/team.d.ts +6 -1
  78. package/dist/lib/team.js +17 -8
  79. package/dist/lib/team.js.map +1 -1
  80. package/dist/types.d.ts +2 -2
  81. package/package.json +5 -5
  82. package/dist/commands/app/team/create.js +0 -29
  83. package/dist/commands/app/team/create.js.map +0 -1
  84. package/dist/commands/app/team/delete.js +0 -29
  85. package/dist/commands/app/team/delete.js.map +0 -1
  86. package/dist/commands/app/team/member/delete.js.map +0 -1
  87. package/dist/commands/app/team/member/invite.js.map +0 -1
  88. package/dist/commands/app/team/member/update.js.map +0 -1
  89. package/dist/commands/app/team/member.js.map +0 -1
  90. package/dist/commands/app/team/update.js.map +0 -1
  91. package/dist/commands/app/team.js.map +0 -1
  92. package/dist/lib/buildBlock.d.ts +0 -9
  93. package/dist/lib/buildBlock.js +0 -39
  94. package/dist/lib/buildBlock.js.map +0 -1
  95. package/dist/lib/createApp.d.ts +0 -59
  96. package/dist/lib/createApp.js +0 -120
  97. package/dist/lib/createApp.js.map +0 -1
  98. package/dist/lib/createResource.js +0 -25
  99. package/dist/lib/createResource.js.map +0 -1
  100. package/dist/lib/discoverBlocks.d.ts +0 -10
  101. package/dist/lib/discoverBlocks.js +0 -24
  102. package/dist/lib/discoverBlocks.js.map +0 -1
  103. package/dist/lib/getBlockConfig.d.ts +0 -8
  104. package/dist/lib/getBlockConfig.js +0 -45
  105. package/dist/lib/getBlockConfig.js.map +0 -1
  106. package/dist/lib/makePayload.d.ts +0 -9
  107. package/dist/lib/makePayload.js +0 -94
  108. package/dist/lib/makePayload.js.map +0 -1
  109. package/dist/lib/processBlockMessages.d.ts +0 -2
  110. package/dist/lib/processBlockMessages.js +0 -43
  111. package/dist/lib/processBlockMessages.js.map +0 -1
  112. package/dist/lib/publishBlock.d.ts +0 -8
  113. package/dist/lib/publishBlock.js +0 -32
  114. package/dist/lib/publishBlock.js.map +0 -1
  115. package/dist/lib/traverseAppDirectory.d.ts +0 -11
  116. package/dist/lib/traverseAppDirectory.js +0 -94
  117. package/dist/lib/traverseAppDirectory.js.map +0 -1
  118. package/dist/lib/traverseBlockThemes.d.ts +0 -9
  119. package/dist/lib/traverseBlockThemes.js +0 -40
  120. package/dist/lib/traverseBlockThemes.js.map +0 -1
  121. package/dist/lib/updateApp.d.ts +0 -55
  122. package/dist/lib/updateApp.js +0 -78
  123. package/dist/lib/updateApp.js.map +0 -1
  124. package/dist/lib/updateResource.js.map +0 -1
  125. package/dist/lib/uploadAppBlockTheme.d.ts +0 -11
  126. package/dist/lib/uploadAppBlockTheme.js +0 -33
  127. package/dist/lib/uploadAppBlockTheme.js.map +0 -1
  128. package/dist/lib/uploadMessages.d.ts +0 -9
  129. package/dist/lib/uploadMessages.js +0 -39
  130. package/dist/lib/uploadMessages.js.map +0 -1
package/dist/lib/app.d.ts CHANGED
@@ -1,3 +1,126 @@
1
+ /// <reference types="node" />
2
+ import { ReadStream } from 'fs';
3
+ import FormData from 'form-data';
4
+ import { AppsembleContext, AppsembleRC } from '../types';
5
+ interface CreateAppParams {
6
+ /**
7
+ * The OAuth2 client credentials to use.
8
+ */
9
+ clientCredentials: string;
10
+ /**
11
+ * If specified, the context matching this name is used, overriding command line flags.
12
+ */
13
+ context?: string;
14
+ /**
15
+ * The ID of the organization to upload for.
16
+ */
17
+ organization: string;
18
+ /**
19
+ * The path in which the App YAML is located.
20
+ */
21
+ path: string;
22
+ /**
23
+ * Whether the App should be marked as private.
24
+ */
25
+ private: boolean;
26
+ /**
27
+ * The remote server to create the app on.
28
+ */
29
+ remote: string;
30
+ /**
31
+ * Whether the App should be marked as a template.
32
+ */
33
+ template: boolean;
34
+ /**
35
+ * The icon to upload.
36
+ */
37
+ icon: NodeJS.ReadStream | ReadStream;
38
+ /**
39
+ * The background color to use for the icon in opaque contexts.
40
+ */
41
+ iconBackground: string;
42
+ /**
43
+ * The maskable icon to upload.
44
+ */
45
+ maskableIcon: NodeJS.ReadStream | ReadStream;
46
+ /**
47
+ * Whether the API should be called with a dry run.
48
+ */
49
+ dryRun: boolean;
50
+ /**
51
+ * Whether resources from the `resources` directory should be created after creating the app.
52
+ */
53
+ resources: boolean;
54
+ /**
55
+ * If the app context is specified,
56
+ * modify it for the current context to include the id of the created app.
57
+ */
58
+ modifyContext: boolean;
59
+ }
60
+ interface UpdateAppParams {
61
+ /**
62
+ * The OAuth2 client credentials to use.
63
+ */
64
+ clientCredentials: string;
65
+ /**
66
+ * If specified, the context matching this name is used, overriding command line flags.
67
+ */
68
+ context?: string;
69
+ /**
70
+ * The ID of the app to update.
71
+ */
72
+ id?: number;
73
+ /**
74
+ * The path in which the App YAML is located.
75
+ */
76
+ path: string;
77
+ /**
78
+ * Whether the App should be marked as private.
79
+ */
80
+ private: boolean;
81
+ /**
82
+ * The remote server to create the app on.
83
+ */
84
+ remote: string;
85
+ /**
86
+ * Whether the App should be marked as a template.
87
+ */
88
+ template: boolean;
89
+ /**
90
+ * Whether the locked property should be ignored.
91
+ */
92
+ force: boolean;
93
+ /**
94
+ * The icon to upload.
95
+ */
96
+ icon: NodeJS.ReadStream | ReadStream;
97
+ /**
98
+ * The background color to use for the icon in opaque contexts.
99
+ */
100
+ iconBackground: string;
101
+ /**
102
+ * The maskable icon to upload.
103
+ */
104
+ maskableIcon: NodeJS.ReadStream | ReadStream;
105
+ }
106
+ /**
107
+ * Traverses an app directory and appends the files it finds to the given FormData object.
108
+ *
109
+ * @param path - The path of the app directory to traverse.
110
+ * @param context - The Context to use from `.appsemblerc.yaml`.
111
+ * @param formData - The FormData object to append the results into..
112
+ * @returns The context from `.appsemblerc.yaml` if a match was found.
113
+ */
114
+ export declare function traverseAppDirectory(path: string, context: string, formData: FormData): Promise<[AppsembleContext, AppsembleRC]>;
115
+ /**
116
+ * Upload messages for an app.
117
+ *
118
+ * @param path - The path to the app directory.
119
+ * @param appId - The app id to upload the messages for.
120
+ * @param remote - The remote to upload the messages to.
121
+ * @param force - Whether or not to force the update for locked apps.
122
+ */
123
+ export declare function uploadMessages(path: string, appId: number, remote: string, force: boolean): Promise<void>;
1
124
  /**
2
125
  * @param path - The path to the app directory.
3
126
  * @param languages - A list of languages for which translations should be added in addition to the
@@ -6,3 +129,26 @@
6
129
  * @param format - The file format that should be used for the output.
7
130
  */
8
131
  export declare function writeAppMessages(path: string, languages: string[], verify: string[], format: 'json' | 'yaml'): Promise<void>;
132
+ /**
133
+ * Create a new App.
134
+ *
135
+ * @param argv - The command line options used for updating the app.
136
+ */
137
+ export declare function updateApp({ clientCredentials, context, force, path, ...options }: UpdateAppParams): Promise<void>;
138
+ /**
139
+ * Create a new App.
140
+ *
141
+ * @param options - The options to use for creating an app.
142
+ */
143
+ export declare function createApp({ clientCredentials, context, dryRun, modifyContext, path, resources, ...options }: CreateAppParams): Promise<void>;
144
+ /**
145
+ * Resolve the app’s ID and remote based on the app context.
146
+ *
147
+ * @param appPath - The path to the app.
148
+ * @param name - Which context to use in the AppsembleRC file.
149
+ * @param defaultRemote - The remote to fall back to.
150
+ * @param defaultAppId - The app ID to fall back to.
151
+ * @returns The resolved app ID and remote.
152
+ */
153
+ export declare function resolveAppIdAndRemote(appPath: string, name: string, defaultRemote: string, defaultAppId: number): Promise<[number, string]>;
154
+ export {};
package/dist/lib/app.js CHANGED
@@ -1,11 +1,138 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.writeAppMessages = void 0;
6
+ exports.resolveAppIdAndRemote = exports.createApp = exports.updateApp = exports.writeAppMessages = exports.uploadMessages = exports.traverseAppDirectory = void 0;
4
7
  const fs_1 = require("fs");
5
8
  const path_1 = require("path");
9
+ const url_1 = require("url");
6
10
  const util_1 = require("util");
7
11
  const node_utils_1 = require("@appsemble/node-utils");
8
12
  const utils_1 = require("@appsemble/utils");
13
+ const axios_1 = __importDefault(require("axios"));
14
+ const form_data_1 = __importDefault(require("form-data"));
15
+ const fs_extra_1 = require("fs-extra");
16
+ const authentication_1 = require("./authentication");
17
+ const block_1 = require("./block");
18
+ const coercers_1 = require("./coercers");
19
+ const processCss_1 = require("./processCss");
20
+ const resource_1 = require("./resource");
21
+ /**
22
+ * Traverses an app directory and appends the files it finds to the given FormData object.
23
+ *
24
+ * @param path - The path of the app directory to traverse.
25
+ * @param context - The Context to use from `.appsemblerc.yaml`.
26
+ * @param formData - The FormData object to append the results into..
27
+ * @returns The context from `.appsemblerc.yaml` if a match was found.
28
+ */
29
+ async function traverseAppDirectory(path, context, formData) {
30
+ let appFound;
31
+ let discoveredContext;
32
+ let rc;
33
+ let iconPath;
34
+ let maskableIconPath;
35
+ node_utils_1.logger.info(`Traversing directory for App files in ${path} 🕵`);
36
+ await node_utils_1.opendirSafe(path, async (filepath, stat) => {
37
+ switch (stat.name.toLowerCase()) {
38
+ case '.appsemblerc.yaml': {
39
+ node_utils_1.logger.info(`Reading app settings from ${filepath}`);
40
+ [rc] = await node_utils_1.readData(filepath);
41
+ if ('iconBackground' in rc) {
42
+ formData.append('iconBackground', rc.iconBackground);
43
+ }
44
+ if (context && utils_1.has(rc === null || rc === void 0 ? void 0 : rc.context, context)) {
45
+ discoveredContext = rc.context[context];
46
+ node_utils_1.logger.verbose(`Using context: ${util_1.inspect(discoveredContext, { colors: true })}`);
47
+ }
48
+ break;
49
+ }
50
+ case 'app-definition.yaml': {
51
+ node_utils_1.logger.info(`Using app definition from ${filepath}`);
52
+ if (appFound) {
53
+ throw new node_utils_1.AppsembleError('Found duplicate app definition');
54
+ }
55
+ appFound = filepath;
56
+ const [app, data] = await node_utils_1.readData(filepath);
57
+ formData.append('yaml', data);
58
+ formData.append('definition', JSON.stringify(app));
59
+ return;
60
+ }
61
+ case 'icon.png':
62
+ case 'icon.svg':
63
+ iconPath = filepath;
64
+ return;
65
+ case 'maskable-icon.png':
66
+ maskableIconPath = filepath;
67
+ return;
68
+ case 'readme.md':
69
+ node_utils_1.logger.info(`Including longDescription from ${filepath}`);
70
+ formData.append('longDescription', await fs_1.promises.readFile(filepath, 'utf8'));
71
+ return;
72
+ case 'screenshots':
73
+ return node_utils_1.opendirSafe(filepath, (screenshotPath, screenshotStat) => {
74
+ node_utils_1.logger.info(`Adding screenshot ${screenshotPath} 🖼️`);
75
+ if (!screenshotStat.isFile()) {
76
+ throw new node_utils_1.AppsembleError(`Expected ${screenshotPath} to be an image file`);
77
+ }
78
+ formData.append('screenshots', fs_1.createReadStream(screenshotPath));
79
+ }, { allowMissing: true });
80
+ case 'theme':
81
+ return node_utils_1.opendirSafe(filepath, async (themeDir, themeStat) => {
82
+ const name = themeStat.name.toLowerCase();
83
+ if (name !== 'core' && name !== 'shared') {
84
+ return;
85
+ }
86
+ if (!themeStat.isDirectory()) {
87
+ throw new node_utils_1.AppsembleError(`Expected ${themeDir} to be a directory`);
88
+ }
89
+ const css = await processCss_1.processCss(path_1.join(themeDir, 'index.css'));
90
+ formData.append(`${name}Style`, Buffer.from(css), `${name}.css`);
91
+ });
92
+ default:
93
+ node_utils_1.logger.warn(`Found unused file ${filepath}`);
94
+ }
95
+ });
96
+ if (!appFound) {
97
+ throw new node_utils_1.AppsembleError('No app definition found');
98
+ }
99
+ discoveredContext || (discoveredContext = {});
100
+ discoveredContext.icon = discoveredContext.icon
101
+ ? path_1.resolve(path, discoveredContext.icon)
102
+ : iconPath;
103
+ discoveredContext.maskableIcon || (discoveredContext.maskableIcon = maskableIconPath);
104
+ return [discoveredContext, rc];
105
+ }
106
+ exports.traverseAppDirectory = traverseAppDirectory;
107
+ /**
108
+ * Upload messages for an app.
109
+ *
110
+ * @param path - The path to the app directory.
111
+ * @param appId - The app id to upload the messages for.
112
+ * @param remote - The remote to upload the messages to.
113
+ * @param force - Whether or not to force the update for locked apps.
114
+ */
115
+ async function uploadMessages(path, appId, remote, force) {
116
+ const result = [];
117
+ node_utils_1.logger.info('Searching for translations 🕵');
118
+ await node_utils_1.opendirSafe(path_1.join(path, 'i18n'), async (messageFile) => {
119
+ node_utils_1.logger.verbose(`Processing ${messageFile} ⚙️`);
120
+ const { name: language } = path_1.parse(messageFile);
121
+ if (result.some((entry) => entry.language === language)) {
122
+ throw new node_utils_1.AppsembleError(`Found duplicate language “${language}”. Make sure each language only exists once in the directory.`);
123
+ }
124
+ const [messages] = await node_utils_1.readData(messageFile);
125
+ result.push({ force, language, messages });
126
+ }, { allowMissing: true });
127
+ if (!result.length) {
128
+ node_utils_1.logger.info('No translations found 🤷');
129
+ }
130
+ for (const language of result) {
131
+ await axios_1.default.post(`/api/apps/${appId}/messages`, language, { baseURL: remote });
132
+ node_utils_1.logger.info(`Successfully uploaded messages for language “${language.language}” 🎉`);
133
+ }
134
+ }
135
+ exports.uploadMessages = uploadMessages;
9
136
  /**
10
137
  * @param path - The path to the app directory.
11
138
  * @param languages - A list of languages for which translations should be added in addition to the
@@ -14,7 +141,7 @@ const utils_1 = require("@appsemble/utils");
14
141
  * @param format - The file format that should be used for the output.
15
142
  */
16
143
  async function writeAppMessages(path, languages, verify, format) {
17
- var _a, _b, _c;
144
+ var _a, _b;
18
145
  node_utils_1.logger.info(`Extracting messages from ${path}`);
19
146
  let app;
20
147
  let i18nDir = path_1.join(path, 'i18n');
@@ -111,17 +238,18 @@ async function writeAppMessages(path, languages, verify, format) {
111
238
  }
112
239
  }
113
240
  const blockMessages = {};
114
- Object.keys((_b = oldMessages.blocks) !== null && _b !== void 0 ? _b : {}).forEach((key) => {
115
- if (!Object.keys(blockMessageKeys).includes(key)) {
116
- throw new node_utils_1.AppsembleError(`Invalid translation key: blocks.${key}\nThis block is not used in the app`);
241
+ if (oldMessages.blocks) {
242
+ for (const key of Object.keys(oldMessages.blocks)) {
243
+ if (!utils_1.has(blockMessageKeys, key)) {
244
+ throw new node_utils_1.AppsembleError(`Invalid translation key: blocks.${key}\nThis block is not used in the app`);
245
+ }
117
246
  }
118
- });
247
+ }
119
248
  for (const [blockName] of Object.entries(blockMessageKeys)) {
120
- if ((_c = oldMessages.blocks) === null || _c === void 0 ? void 0 : _c[blockName]) {
121
- const currentVersionKeys = Object.keys(blockMessageKeys[blockName]);
249
+ if ((_b = oldMessages.blocks) === null || _b === void 0 ? void 0 : _b[blockName]) {
122
250
  blockMessages[blockName] = {};
123
251
  for (const [version, oldValues] of Object.entries(oldMessages.blocks[blockName])) {
124
- if (!currentVersionKeys.includes(version)) {
252
+ if (!utils_1.has(blockMessageKeys[blockName], version)) {
125
253
  throw new node_utils_1.AppsembleError(`Invalid translation key: blocks.${blockName}.${version}
126
254
  This block version is not used in the app`);
127
255
  }
@@ -147,4 +275,199 @@ This block version is not used in the app`);
147
275
  }
148
276
  }
149
277
  exports.writeAppMessages = writeAppMessages;
278
+ /**
279
+ * Create a new App.
280
+ *
281
+ * @param argv - The command line options used for updating the app.
282
+ */
283
+ async function updateApp({ clientCredentials, context, force, path, ...options }) {
284
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
285
+ const file = await fs_1.promises.stat(path);
286
+ const formData = new form_data_1.default();
287
+ let appsembleContext;
288
+ if (file.isFile()) {
289
+ const [app, data] = await node_utils_1.readData(path);
290
+ formData.append('yaml', data);
291
+ formData.append('definition', JSON.stringify(app));
292
+ }
293
+ else {
294
+ [appsembleContext] = await traverseAppDirectory(path, context, formData);
295
+ }
296
+ const remote = (_a = appsembleContext.remote) !== null && _a !== void 0 ? _a : options.remote;
297
+ const id = (_b = appsembleContext.id) !== null && _b !== void 0 ? _b : options.id;
298
+ const template = (_d = (_c = appsembleContext.template) !== null && _c !== void 0 ? _c : options.template) !== null && _d !== void 0 ? _d : false;
299
+ const isPrivate = (_e = appsembleContext.private) !== null && _e !== void 0 ? _e : options.private;
300
+ const iconBackground = (_f = appsembleContext.iconBackground) !== null && _f !== void 0 ? _f : options.iconBackground;
301
+ const icon = (_g = options.icon) !== null && _g !== void 0 ? _g : appsembleContext.icon;
302
+ const maskableIcon = (_h = options.maskableIcon) !== null && _h !== void 0 ? _h : appsembleContext.maskableIcon;
303
+ node_utils_1.logger.info(`App id: ${id}`);
304
+ node_utils_1.logger.verbose(`App remote: ${remote}`);
305
+ node_utils_1.logger.verbose(`App is template: ${util_1.inspect(template, { colors: true })}`);
306
+ node_utils_1.logger.verbose(`App is private: ${util_1.inspect(isPrivate, { colors: true })}`);
307
+ node_utils_1.logger.verbose(`Icon background: ${iconBackground}`);
308
+ node_utils_1.logger.verbose(`Force update: ${util_1.inspect(force, { colors: true })}`);
309
+ if (!id) {
310
+ throw new node_utils_1.AppsembleError('The app id must be passed as a command line flag or in the context');
311
+ }
312
+ formData.append('force', String(force));
313
+ formData.append('template', String(template));
314
+ formData.append('private', String(isPrivate));
315
+ formData.append('iconBackground', iconBackground);
316
+ if (icon) {
317
+ const realIcon = typeof icon === 'string' ? fs_1.createReadStream(icon) : icon;
318
+ node_utils_1.logger.info(`Using icon from ${(_j = realIcon.path) !== null && _j !== void 0 ? _j : 'stdin'}`);
319
+ formData.append('icon', realIcon);
320
+ }
321
+ if (maskableIcon) {
322
+ const realIcon = typeof maskableIcon === 'string' ? fs_1.createReadStream(maskableIcon) : maskableIcon;
323
+ node_utils_1.logger.info(`Using icon from ${(_k = realIcon.path) !== null && _k !== void 0 ? _k : 'stdin'}`);
324
+ formData.append('icon', realIcon);
325
+ }
326
+ await authentication_1.authenticate(remote, 'apps:write', clientCredentials);
327
+ const { data } = await axios_1.default.patch(`/api/apps/${id}`, formData, { baseURL: remote });
328
+ if (file.isDirectory()) {
329
+ // After uploading the app, upload block styles and messages if they are available
330
+ await block_1.traverseBlockThemes(path, data.id, remote, force);
331
+ await uploadMessages(path, data.id, remote, force);
332
+ }
333
+ const { host, protocol } = new url_1.URL(remote);
334
+ node_utils_1.logger.info(`Successfully updated app ${data.definition.name}! 🙌`);
335
+ node_utils_1.logger.info(`App URL: ${protocol}//${data.path}.${data.OrganizationId}.${host}`);
336
+ node_utils_1.logger.info(`App store page: ${new url_1.URL(`/apps/${data.id}`, remote)}`);
337
+ }
338
+ exports.updateApp = updateApp;
339
+ /**
340
+ * Create a new App.
341
+ *
342
+ * @param options - The options to use for creating an app.
343
+ */
344
+ async function createApp({ clientCredentials, context, dryRun, modifyContext, path, resources, ...options }) {
345
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
346
+ const file = await fs_1.promises.stat(path);
347
+ const formData = new form_data_1.default();
348
+ let appsembleContext;
349
+ let rc;
350
+ if (file.isFile()) {
351
+ // Assuming file is App YAML
352
+ const [app, data] = await node_utils_1.readData(path);
353
+ formData.append('yaml', data);
354
+ formData.append('definition', JSON.stringify(app));
355
+ }
356
+ else {
357
+ [appsembleContext, rc] = await traverseAppDirectory(path, context, formData);
358
+ }
359
+ const remote = (_a = appsembleContext.remote) !== null && _a !== void 0 ? _a : options.remote;
360
+ const organizationId = (_b = appsembleContext.organization) !== null && _b !== void 0 ? _b : options.organization;
361
+ const template = (_d = (_c = appsembleContext.template) !== null && _c !== void 0 ? _c : options.template) !== null && _d !== void 0 ? _d : false;
362
+ const isPrivate = (_e = appsembleContext.private) !== null && _e !== void 0 ? _e : options.private;
363
+ const iconBackground = (_f = appsembleContext.iconBackground) !== null && _f !== void 0 ? _f : options.iconBackground;
364
+ const icon = (_g = options.icon) !== null && _g !== void 0 ? _g : appsembleContext.icon;
365
+ const maskableIcon = (_h = options.maskableIcon) !== null && _h !== void 0 ? _h : appsembleContext.maskableIcon;
366
+ node_utils_1.logger.verbose(`App remote: ${remote}`);
367
+ node_utils_1.logger.verbose(`App organzation: ${organizationId}`);
368
+ node_utils_1.logger.verbose(`App is template: ${util_1.inspect(template, { colors: true })}`);
369
+ node_utils_1.logger.verbose(`App is private: ${util_1.inspect(isPrivate, { colors: true })}`);
370
+ node_utils_1.logger.verbose(`Icon background: ${iconBackground}`);
371
+ if (!organizationId) {
372
+ throw new node_utils_1.AppsembleError('An organization id must be passed as a command line flag or in the context');
373
+ }
374
+ formData.append('OrganizationId', organizationId);
375
+ formData.append('template', String(template));
376
+ formData.append('private', String(isPrivate));
377
+ formData.append('iconBackground', iconBackground);
378
+ if (icon) {
379
+ const realIcon = typeof icon === 'string' ? fs_1.createReadStream(icon) : icon;
380
+ node_utils_1.logger.info(`Using icon from ${(_j = realIcon.path) !== null && _j !== void 0 ? _j : 'stdin'}`);
381
+ formData.append('icon', realIcon);
382
+ }
383
+ if (maskableIcon) {
384
+ const realIcon = typeof maskableIcon === 'string' ? fs_1.createReadStream(maskableIcon) : maskableIcon;
385
+ node_utils_1.logger.info(`Using icon from ${(_k = realIcon.path) !== null && _k !== void 0 ? _k : 'stdin'}`);
386
+ formData.append('icon', realIcon);
387
+ }
388
+ await authentication_1.authenticate(remote, resources ? 'apps:write resources:write' : 'apps:write', clientCredentials);
389
+ const { data } = await axios_1.default.post('/api/apps', formData, { baseURL: remote, params: { dryRun } });
390
+ if (dryRun) {
391
+ node_utils_1.logger.info('Skipped uploading block themes and app messages.');
392
+ node_utils_1.logger.info('Successfully ran dry run. The app should be valid when creating it.');
393
+ return;
394
+ }
395
+ if (file.isDirectory() && !dryRun) {
396
+ // After uploading the app, upload block styles and messages if they are available
397
+ await block_1.traverseBlockThemes(path, data.id, remote, false);
398
+ await uploadMessages(path, data.id, remote, false);
399
+ if (resources && fs_1.existsSync(path_1.join(path, 'resources'))) {
400
+ const resourcePath = path_1.join(path, 'resources');
401
+ try {
402
+ const resourceFiles = await fs_1.promises.readdir(resourcePath, { withFileTypes: true });
403
+ for (const resource of resourceFiles) {
404
+ if (resource.isFile()) {
405
+ const { name } = path_1.parse(resource.name);
406
+ await resource_1.createResource({
407
+ appId: data.id,
408
+ path: path_1.join(resourcePath, resource.name),
409
+ remote,
410
+ resourceName: name,
411
+ });
412
+ }
413
+ else if (resource.isDirectory()) {
414
+ const subDirectoryResources = await fs_extra_1.readdir(path_1.join(resourcePath, resource.name), {
415
+ withFileTypes: true,
416
+ });
417
+ for (const subResource of subDirectoryResources.filter((s) => s.isFile())) {
418
+ await resource_1.createResource({
419
+ appId: data.id,
420
+ path: path_1.join(resourcePath, resource.name, subResource.name),
421
+ remote,
422
+ resourceName: resource.name,
423
+ });
424
+ }
425
+ }
426
+ }
427
+ }
428
+ catch (error) {
429
+ node_utils_1.logger.error('Something went wrong when creating resources:');
430
+ node_utils_1.logger.error(error);
431
+ }
432
+ }
433
+ }
434
+ if (modifyContext && appsembleContext && context && !dryRun) {
435
+ rc.context[context].id = data.id;
436
+ await node_utils_1.writeData(path_1.join(path, '.appsemblerc.yaml'), rc);
437
+ node_utils_1.logger.info(`Updated .appsemblerc: Set context.${context}.id to ${data.id}`);
438
+ }
439
+ const { host, protocol } = new url_1.URL(remote);
440
+ node_utils_1.logger.info(`Successfully created app ${data.definition.name}! 🙌`);
441
+ node_utils_1.logger.info(`App URL: ${protocol}//${data.path}.${data.OrganizationId}.${host}`);
442
+ node_utils_1.logger.info(`App store page: ${new url_1.URL(`/apps/${data.id}`, remote)}`);
443
+ }
444
+ exports.createApp = createApp;
445
+ /**
446
+ * Resolve the app’s ID and remote based on the app context.
447
+ *
448
+ * @param appPath - The path to the app.
449
+ * @param name - Which context to use in the AppsembleRC file.
450
+ * @param defaultRemote - The remote to fall back to.
451
+ * @param defaultAppId - The app ID to fall back to.
452
+ * @returns The resolved app ID and remote.
453
+ */
454
+ async function resolveAppIdAndRemote(appPath, name, defaultRemote, defaultAppId) {
455
+ var _a;
456
+ let id;
457
+ let resolvedRemote = defaultRemote;
458
+ if (appPath) {
459
+ const rcPath = path_1.join(appPath, '.appsemblerc.yaml');
460
+ const [rc] = await node_utils_1.readData(rcPath);
461
+ const context = (_a = rc.context) === null || _a === void 0 ? void 0 : _a[name];
462
+ id = context === null || context === void 0 ? void 0 : context.id;
463
+ if (id == null) {
464
+ throw new node_utils_1.AppsembleError(`App ID was not found in ${rcPath} context.${name}.id`);
465
+ }
466
+ if (context.remote) {
467
+ resolvedRemote = context.remote;
468
+ }
469
+ }
470
+ return [id !== null && id !== void 0 ? id : defaultAppId, coercers_1.coerceRemote(resolvedRemote)];
471
+ }
472
+ exports.resolveAppIdAndRemote = resolveAppIdAndRemote;
150
473
  //# sourceMappingURL=app.js.map
@@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AAC,EAAE,CAAC,GAAG,MAAM,qBAAQ,CAAc,MAAM,CAAC,CAAC;QACjD,MAAM,OAAO,GAAG,MAAA,EAAE,CAAC,OAAO,0CAAG,IAAI,CAAC,CAAC;QACnC,EAAE,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,EAAE,CAAC;QAEjB,IAAI,EAAE,IAAI,IAAI,EAAE;YACd,MAAM,IAAI,2BAAc,CAAC,2BAA2B,MAAM,YAAY,IAAI,KAAK,CAAC,CAAC;SAClF;QAED,IAAI,OAAO,CAAC,MAAM,EAAE;YAClB,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;SACjC;KACF;IAED,OAAO,CAAC,EAAE,aAAF,EAAE,cAAF,EAAE,GAAI,YAAY,EAAE,uBAAY,CAAC,cAAc,CAAC,CAAC,CAAC;AAC5D,CAAC;AAzBD,sDAyBC"}
@@ -1,8 +1,9 @@
1
- interface CreateResourceParams {
1
+ interface CreateAssetParams {
2
2
  /**
3
- * The name of the resource that a new entry is being created of.
3
+ * The name of the asset being uploaded.
4
+ * This must be a unique name for the app. If left empty, the ID is used instead.
4
5
  */
5
- resourceName: string;
6
+ name: string;
6
7
  /**
7
8
  * The path in which the resource JSON is located.
8
9
  */
@@ -16,5 +17,5 @@ interface CreateResourceParams {
16
17
  */
17
18
  remote: string;
18
19
  }
19
- export declare function createResource({ appId, path, remote, resourceName, }: CreateResourceParams): Promise<void>;
20
+ export declare function createAsset({ appId, name, path, remote }: CreateAssetParams): Promise<void>;
20
21
  export {};
@@ -0,0 +1,23 @@
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.createAsset = void 0;
7
+ const fs_1 = require("fs");
8
+ const node_utils_1 = require("@appsemble/node-utils");
9
+ const utils_1 = require("@appsemble/utils");
10
+ const axios_1 = __importDefault(require("axios"));
11
+ const form_data_1 = __importDefault(require("form-data"));
12
+ async function createAsset({ appId, name, path, remote }) {
13
+ const formData = new form_data_1.default();
14
+ const file = fs_1.createReadStream(path);
15
+ formData.append('file', file);
16
+ if (name) {
17
+ formData.append('name', utils_1.normalize(name));
18
+ }
19
+ const { data: { id }, } = await axios_1.default.post(`/api/apps/${appId}/assets`, formData, { baseURL: remote });
20
+ node_utils_1.logger.info(`Created asset ${id}${name ? ` with name ${utils_1.normalize(name)}` : ''}`);
21
+ }
22
+ exports.createAsset = createAsset;
23
+ //# sourceMappingURL=asset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset.js","sourceRoot":"","sources":["../../src/lib/asset.ts"],"names":[],"mappings":";;;;;;AAAA,2BAAsC;AAEtC,sDAA+C;AAC/C,4CAA6C;AAC7C,kDAA0B;AAC1B,0DAAiC;AAyB1B,KAAK,UAAU,WAAW,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAqB;IAChF,MAAM,QAAQ,GAAG,IAAI,mBAAQ,EAAE,CAAC;IAChC,MAAM,IAAI,GAAG,qBAAgB,CAAC,IAAI,CAAC,CAAC;IACpC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC9B,IAAI,IAAI,EAAE;QACR,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAS,CAAC,IAAI,CAAC,CAAC,CAAC;KAC1C;IAED,MAAM,EACJ,IAAI,EAAE,EAAE,EAAE,EAAE,GACb,GAAG,MAAM,eAAK,CAAC,IAAI,CAAiB,aAAa,KAAK,SAAS,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IACjG,mBAAM,CAAC,IAAI,CAAC,iBAAiB,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,cAAc,iBAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACnF,CAAC;AAZD,kCAYC"}