@appsemble/cli 0.23.4 → 0.23.6
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/block/build.js +4 -3
- package/commands/block/extract-messages.js +5 -4
- package/commands/block/publish.js +6 -4
- package/commands/serve.js +11 -8
- package/commands/start.js +3 -4
- package/lib/app.js +23 -1
- package/lib/block.d.ts +9 -34
- package/lib/block.js +25 -195
- package/lib/block.test.js +10 -16
- package/lib/config.d.ts +40 -0
- package/lib/{getBlockConfigFromTypeScript.js → config.js} +164 -68
- package/lib/{getBlockConfigFromTypeScript.test.js → config.test.js} +32 -32
- package/lib/project.d.ts +12 -0
- package/lib/project.js +145 -0
- package/package.json +6 -5
- package/server/options/createSettings.js +19 -4
- package/server/options/getBlockAsset.d.ts +2 -2
- package/server/options/getBlockAsset.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/lib/getBlockConfigFromTypeScript.d.ts +0 -10
- package/lib/loadWebpackConfig.d.ts +0 -15
- package/lib/loadWebpackConfig.js +0 -45
- /package/__fixtures__/{makePayload → makeProjectPayload}/no-icon/output/block.js +0 -0
- /package/__fixtures__/{makePayload → makeProjectPayload}/with-icon/output/block.js +0 -0
- /package/lib/{getBlockConfigFromTypeScript.test.d.ts → config.test.d.ts} +0 -0
|
@@ -1,8 +1,23 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
1
3
|
import { createSettings as createUtilsSettings, } from '@appsemble/node-utils';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
import { getProjectBuildConfig } from '../../lib/config.js';
|
|
5
|
+
import { buildProject, makeProjectPayload } from '../../lib/project.js';
|
|
6
|
+
export async function createSettings({ context, host, languages, }) {
|
|
7
|
+
const { appBlocks, appPath, appsembleApp } = context;
|
|
8
|
+
const controllerPath = join(appPath, 'controller');
|
|
9
|
+
let controllerCode;
|
|
10
|
+
let controllerImplementations;
|
|
11
|
+
if (existsSync(controllerPath)) {
|
|
12
|
+
const controllerBuildConfig = await getProjectBuildConfig(controllerPath);
|
|
13
|
+
const controllerBuildResult = await buildProject(controllerBuildConfig);
|
|
14
|
+
[, controllerImplementations] = await makeProjectPayload(controllerBuildConfig);
|
|
15
|
+
controllerCode = controllerBuildResult.outputFiles[0].text;
|
|
16
|
+
}
|
|
17
|
+
return createUtilsSettings({
|
|
5
18
|
apiUrl: host,
|
|
19
|
+
appControllerCode: controllerCode,
|
|
20
|
+
appControllerImplementations: JSON.stringify(controllerImplementations),
|
|
6
21
|
blockManifests: appBlocks,
|
|
7
22
|
id: appsembleApp.id,
|
|
8
23
|
languages,
|
|
@@ -10,6 +25,6 @@ export function createSettings({ context, host, languages, }) {
|
|
|
10
25
|
appUpdated: appsembleApp.$updated,
|
|
11
26
|
logins: [],
|
|
12
27
|
development: true,
|
|
13
|
-
})
|
|
28
|
+
});
|
|
14
29
|
}
|
|
15
30
|
//# sourceMappingURL=createSettings.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export declare function getBlockAsset({ context, filename, name, version, }: GetBlockAssetParams): Promise<
|
|
1
|
+
import { type GetBlockAssetParams, type ProjectAsset } from '@appsemble/node-utils';
|
|
2
|
+
export declare function getBlockAsset({ context, filename, name, version, }: GetBlockAssetParams): Promise<ProjectAsset>;
|
|
@@ -13,6 +13,7 @@ export async function getBlockAsset({ context, filename, name, version, }) {
|
|
|
13
13
|
const mime = lookup(filename) || '';
|
|
14
14
|
return {
|
|
15
15
|
content: asset,
|
|
16
|
+
filename,
|
|
16
17
|
mime,
|
|
17
18
|
};
|
|
18
19
|
}
|
|
@@ -22,6 +23,7 @@ export async function getBlockAsset({ context, filename, name, version, }) {
|
|
|
22
23
|
const mime = lookup(filename) || '';
|
|
23
24
|
return {
|
|
24
25
|
content: asset,
|
|
26
|
+
filename,
|
|
25
27
|
mime,
|
|
26
28
|
};
|
|
27
29
|
}
|
|
@@ -6,7 +6,7 @@ pages:
|
|
|
6
6
|
- name: Example Page A
|
|
7
7
|
blocks:
|
|
8
8
|
- type: action-button
|
|
9
|
-
version: 0.23.
|
|
9
|
+
version: 0.23.6
|
|
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.23.
|
|
20
|
+
version: 0.23.6
|
|
21
21
|
parameters:
|
|
22
22
|
icon: arrow-left
|
|
23
23
|
actions:
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type BlockConfig, type BlockManifest } from '@appsemble/types';
|
|
2
|
-
/**
|
|
3
|
-
* Generate a block manifest from the block metadata and TypeScript project.
|
|
4
|
-
*
|
|
5
|
-
* Uses the .appsemblerc file and the type definitions of the block.
|
|
6
|
-
*
|
|
7
|
-
* @param blockConfig The block configuration
|
|
8
|
-
* @returns The block configuration appended from the TypeScript project.
|
|
9
|
-
*/
|
|
10
|
-
export declare function getBlockConfigFromTypeScript(blockConfig: BlockConfig): Pick<BlockManifest, 'actions' | 'events' | 'messages' | 'parameters'>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type BlockConfig } from '@appsemble/types';
|
|
2
|
-
import { type Configuration } from 'webpack';
|
|
3
|
-
/**
|
|
4
|
-
* Load a webpack configuration file.
|
|
5
|
-
*
|
|
6
|
-
* A webpack configuration file may export either an webpack configuration object, or a synchronous
|
|
7
|
-
* or asynchronous function which returns a webpack configuration object. This function supports
|
|
8
|
-
* all 3 use cases.
|
|
9
|
-
*
|
|
10
|
-
* @param block The path to the webpack configuration file.
|
|
11
|
-
* @param mode The env that would be passed to webpack by invoking `webpack --env $env`.
|
|
12
|
-
* @param outputPath The path where the build will be output on disk.
|
|
13
|
-
* @returns The webpack configuration as exposed by the webpack configuration file.
|
|
14
|
-
*/
|
|
15
|
-
export declare function loadWebpackConfig(block: BlockConfig, mode?: 'development' | 'production', outputPath?: string): Promise<Configuration>;
|
package/lib/loadWebpackConfig.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { stat } from 'node:fs/promises';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { logger } from '@appsemble/node-utils';
|
|
4
|
-
/**
|
|
5
|
-
* Load a webpack configuration file.
|
|
6
|
-
*
|
|
7
|
-
* A webpack configuration file may export either an webpack configuration object, or a synchronous
|
|
8
|
-
* or asynchronous function which returns a webpack configuration object. This function supports
|
|
9
|
-
* all 3 use cases.
|
|
10
|
-
*
|
|
11
|
-
* @param block The path to the webpack configuration file.
|
|
12
|
-
* @param mode The env that would be passed to webpack by invoking `webpack --env $env`.
|
|
13
|
-
* @param outputPath The path where the build will be output on disk.
|
|
14
|
-
* @returns The webpack configuration as exposed by the webpack configuration file.
|
|
15
|
-
*/
|
|
16
|
-
export async function loadWebpackConfig(block, mode, outputPath) {
|
|
17
|
-
let configPath;
|
|
18
|
-
if (block.webpack) {
|
|
19
|
-
configPath = join(block.dir, block.webpack);
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
configPath = join(block.dir, 'webpack.config.js');
|
|
23
|
-
try {
|
|
24
|
-
await stat(configPath);
|
|
25
|
-
}
|
|
26
|
-
catch {
|
|
27
|
-
configPath = '@appsemble/webpack-config';
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
logger.info(`Using webpack config from ${configPath}`);
|
|
31
|
-
const publicPath = `/api/blocks/${block.name}/versions/${block.version}/`;
|
|
32
|
-
let config = await import(String(configPath));
|
|
33
|
-
config = await (config.default || config);
|
|
34
|
-
config = config instanceof Function ? await config(block, { mode, publicPath }) : config;
|
|
35
|
-
// Koa-webpack serves assets on the `output.path` path. Normally this field describes where to
|
|
36
|
-
// output the files on the file system. This is monkey patched to support usage with our dev
|
|
37
|
-
// server.
|
|
38
|
-
config.output = config.output || {};
|
|
39
|
-
config.output.path = outputPath || publicPath;
|
|
40
|
-
logger.verbose(`Patched webpack config output.path to ${config.output.path}`);
|
|
41
|
-
config.output.publicPath = publicPath;
|
|
42
|
-
logger.verbose(`Patched webpack config output.publicPath to ${config.output.publicPath}`);
|
|
43
|
-
return config;
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=loadWebpackConfig.js.map
|
|
File without changes
|
|
File without changes
|
|
File without changes
|