@appsemble/cli 0.24.8 → 0.24.10

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 CHANGED
@@ -1,9 +1,9 @@
1
- # ![](https://gitlab.com/appsemble/appsemble/-/raw/0.24.8/config/assets/logo.svg) Appsemble CLI
1
+ # ![](https://gitlab.com/appsemble/appsemble/-/raw/0.24.10/config/assets/logo.svg) Appsemble CLI
2
2
 
3
3
  > Manage apps and blocks from the command line.
4
4
 
5
5
  [![npm](https://img.shields.io/npm/v/@appsemble/cli)](https://www.npmjs.com/package/@appsemble/cli)
6
- [![GitLab CI](https://gitlab.com/appsemble/appsemble/badges/0.24.8/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.24.8)
6
+ [![GitLab CI](https://gitlab.com/appsemble/appsemble/badges/0.24.10/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.24.10)
7
7
  [![Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://prettier.io)
8
8
 
9
9
  ## Table of Contents
@@ -304,5 +304,5 @@ appsemble run-cronjobs --interval 30
304
304
 
305
305
  ## License
306
306
 
307
- [LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.24.8/LICENSE.md) ©
307
+ [LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.24.10/LICENSE.md) ©
308
308
  [Appsemble](https://appsemble.com)
@@ -15,6 +15,8 @@ interface PublishAppArguments extends BaseArguments {
15
15
  demoMode: boolean;
16
16
  dryRun: boolean;
17
17
  resources: boolean;
18
+ assets: boolean;
19
+ assetsClonable: boolean;
18
20
  modifyContext: boolean;
19
21
  visibility: AppVisibility;
20
22
  sentryDsn: string;
@@ -48,6 +48,14 @@ export function builder(yargs) {
48
48
  .option('resources', {
49
49
  describe: 'Whether the resources from the `resources` directory should be created after publishing the app. The names of subdirectories are used as the name of the resource, otherwise the names of top level resource .json files are used instead.',
50
50
  type: 'boolean',
51
+ })
52
+ .option('assets', {
53
+ describe: 'Whether the assets from the `assets` directory should be created after publishing the app.',
54
+ type: 'boolean',
55
+ })
56
+ .option('assets-clonable', {
57
+ describe: 'Whether published assets should be clonable. Ignored if assets equals false.',
58
+ type: 'boolean',
51
59
  })
52
60
  .option('modify-context', {
53
61
  describe: 'If the app context is specified, modify it for the current context to include the id of the published app.',
package/commands/serve.js CHANGED
@@ -67,7 +67,8 @@ export async function handler(argv) {
67
67
  const appSecurity = appsembleApp.definition.security;
68
68
  const appMembers = [
69
69
  {
70
- id: '1',
70
+ userId: '1',
71
+ memberId: '1',
71
72
  name: 'dev',
72
73
  primaryEmail: 'dev@example.com',
73
74
  role: passedUserRole || (appSecurity === null || appSecurity === void 0 ? void 0 : appSecurity.default.role),
package/lib/app.d.ts CHANGED
@@ -56,6 +56,14 @@ interface PublishAppParams {
56
56
  * Whether resources from the `resources` directory should be published after publishing the app.
57
57
  */
58
58
  resources: boolean;
59
+ /**
60
+ * Whether assets from the `assets` directory should be published after publishing the app.
61
+ */
62
+ assets: boolean;
63
+ /**
64
+ * Whether published assets should be clonable. Ignored if `assets` equals false.
65
+ */
66
+ assetsClonable: boolean;
59
67
  /**
60
68
  * If the app context is specified,
61
69
  * modify it for the current context to include the id of the published app.
@@ -182,7 +190,7 @@ export declare function updateApp({ clientCredentials, context, force, path, ...
182
190
  *
183
191
  * @param options The options to use for publishing an app.
184
192
  */
185
- export declare function publishApp({ clientCredentials, context, dryRun, modifyContext, path, resources, ...options }: PublishAppParams): Promise<void>;
193
+ export declare function publishApp({ assets, assetsClonable, clientCredentials, context, dryRun, modifyContext, path, resources, ...options }: PublishAppParams): Promise<void>;
186
194
  /**
187
195
  * Resolve the app’s ID and remote based on the app context.
188
196
  *
package/lib/app.js CHANGED
@@ -5,7 +5,10 @@ import { inspect } from 'node:util';
5
5
  import { AppsembleError, authenticate, logger, opendirSafe, readData, writeData, } from '@appsemble/node-utils';
6
6
  import { extractAppMessages, has, normalizeBlockName } from '@appsemble/utils';
7
7
  import axios from 'axios';
8
+ import fg from 'fast-glob';
8
9
  import FormData from 'form-data';
10
+ import normalizePath from 'normalize-path';
11
+ import { publishAsset } from './asset.js';
9
12
  import { traverseBlockThemes } from './block.js';
10
13
  import { coerceRemote } from './coercers.js';
11
14
  import { getProjectBuildConfig } from './config.js';
@@ -416,7 +419,7 @@ export async function updateApp({ clientCredentials, context, force, path, ...op
416
419
  *
417
420
  * @param options The options to use for publishing an app.
418
421
  */
419
- export async function publishApp({ clientCredentials, context, dryRun, modifyContext, path, resources, ...options }) {
422
+ export async function publishApp({ assets, assetsClonable, clientCredentials, context, dryRun, modifyContext, path, resources, ...options }) {
420
423
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
421
424
  const file = await stat(path);
422
425
  const formData = new FormData();
@@ -509,6 +512,28 @@ export async function publishApp({ clientCredentials, context, dryRun, modifyCon
509
512
  // After uploading the app, upload block styles and messages if they are available
510
513
  await traverseBlockThemes(path, data.id, remote, false);
511
514
  await uploadMessages(path, data.id, remote, false);
515
+ if (assets && existsSync(join(path, 'assets'))) {
516
+ const assetsPath = join(path, 'assets');
517
+ const assetFiles = await readdir(assetsPath);
518
+ const normalizedPaths = assetFiles.map((assetFile) => normalizePath(join(assetsPath, assetFile)));
519
+ const files = await fg(normalizedPaths, { absolute: true, onlyFiles: true });
520
+ try {
521
+ logger.info(`Publishing ${files.length} asset(s)`);
522
+ for (const assetFilePath of files) {
523
+ await publishAsset({
524
+ name: parse(assetFilePath).name,
525
+ appId: data.id,
526
+ path: assetFilePath,
527
+ remote,
528
+ clonable: assetsClonable,
529
+ });
530
+ }
531
+ }
532
+ catch (error) {
533
+ logger.error('Something went wrong when creating assets:');
534
+ logger.error(error);
535
+ }
536
+ }
512
537
  if (resources && existsSync(join(path, 'resources'))) {
513
538
  const resourcePath = join(path, 'resources');
514
539
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appsemble/cli",
3
- "version": "0.24.8",
3
+ "version": "0.24.10",
4
4
  "description": "The CLI for developing with Appsemble apps and blocks",
5
5
  "keywords": [
6
6
  "app",
@@ -42,9 +42,9 @@
42
42
  "test": "vitest"
43
43
  },
44
44
  "dependencies": {
45
- "@appsemble/node-utils": "0.24.8",
46
- "@appsemble/types": "0.24.8",
47
- "@appsemble/utils": "0.24.8",
45
+ "@appsemble/node-utils": "0.24.10",
46
+ "@appsemble/types": "0.24.10",
47
+ "@appsemble/utils": "0.24.10",
48
48
  "@fortawesome/fontawesome-common-types": "^6.0.0",
49
49
  "@koa/cors": "^4.0.0",
50
50
  "@odata/parser": "^0.2.0",
@@ -86,7 +86,7 @@
86
86
  "yargs": "^17.0.0"
87
87
  },
88
88
  "devDependencies": {
89
- "@appsemble/types": "0.24.8",
89
+ "@appsemble/types": "0.24.10",
90
90
  "@types/concat-stream": "^2.0.0",
91
91
  "@types/inquirer": "^9.0.0",
92
92
  "@types/normalize-path": "^3.0.0",
@@ -6,7 +6,7 @@ pages:
6
6
  - name: Example Page A
7
7
  blocks:
8
8
  - type: action-button
9
- version: 0.24.8
9
+ version: 0.24.10
10
10
  parameters:
11
11
  icon: arrow-right
12
12
  actions:
@@ -17,7 +17,7 @@ pages:
17
17
  - name: Example Page B
18
18
  blocks:
19
19
  - type: action-button
20
- version: 0.24.8
20
+ version: 0.24.10
21
21
  parameters:
22
22
  icon: arrow-left
23
23
  actions:
@@ -2,7 +2,7 @@
2
2
  "private": true,
3
3
  "type": "module",
4
4
  "dependencies": {
5
- "@appsemble/sdk": "0.24.8",
5
+ "@appsemble/sdk": "0.24.10",
6
6
  "mini-jsx": "^4.0.0"
7
7
  }
8
8
  }
@@ -2,8 +2,8 @@
2
2
  "private": true,
3
3
  "type": "module",
4
4
  "dependencies": {
5
- "@appsemble/preact": "0.24.8",
6
- "@appsemble/sdk": "0.24.8",
5
+ "@appsemble/preact": "0.24.10",
6
+ "@appsemble/sdk": "0.24.10",
7
7
  "preact": "^10.0.0"
8
8
  }
9
9
  }
@@ -2,6 +2,6 @@
2
2
  "private": true,
3
3
  "type": "module",
4
4
  "dependencies": {
5
- "@appsemble/sdk": "0.24.8"
5
+ "@appsemble/sdk": "0.24.10"
6
6
  }
7
7
  }