@appsemble/cli 0.20.9 → 0.20.12
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/__fixtures__/getBlockConfigFromTypeScript/comments/index.ts +40 -0
- package/__fixtures__/getBlockConfigFromTypeScript/comments/tsconfig.json +7 -0
- package/__fixtures__/getBlockConfigFromTypeScript/duplicateActions/index.ts +34 -0
- package/__fixtures__/getBlockConfigFromTypeScript/duplicateActions/tsconfig.json +7 -0
- package/__fixtures__/getBlockConfigFromTypeScript/duplicateEventEmitters/index.ts +34 -0
- package/__fixtures__/getBlockConfigFromTypeScript/duplicateEventEmitters/tsconfig.json +7 -0
- package/__fixtures__/getBlockConfigFromTypeScript/duplicateEventListeners/index.ts +34 -0
- package/__fixtures__/getBlockConfigFromTypeScript/duplicateEventListeners/tsconfig.json +7 -0
- package/__fixtures__/getBlockConfigFromTypeScript/duplicateParameters/index.ts +34 -0
- package/__fixtures__/getBlockConfigFromTypeScript/duplicateParameters/tsconfig.json +7 -0
- package/__fixtures__/getBlockConfigFromTypeScript/fontawesomeParameters/index.ts +11 -0
- package/__fixtures__/getBlockConfigFromTypeScript/fontawesomeParameters/tsconfig.json +7 -0
- package/__fixtures__/getBlockConfigFromTypeScript/tsError/index.ts +4 -0
- package/__fixtures__/getBlockConfigFromTypeScript/tsError/tsconfig.json +8 -0
- package/__fixtures__/getBlockConfigFromTypeScript/valid/index.ts +28 -0
- package/__fixtures__/getBlockConfigFromTypeScript/valid/tsconfig.json +7 -0
- package/__fixtures__/makePayload/no-icon/output/block.js +1 -0
- package/__fixtures__/makePayload/with-icon/icon.svg +2 -0
- package/__fixtures__/makePayload/with-icon/output/block.js +1 -0
- package/assets/appsemblerc.schema.json +150 -0
- package/changed/added/.gitkeep +0 -0
- package/changed/changed/.gitkeep +0 -0
- package/changed/deprecated/.gitkeep +0 -0
- package/changed/fixed/.gitkeep +0 -0
- package/changed/removed/.gitkeep +0 -0
- package/changed/security/.gitkeep +0 -0
- package/{dist/commands → commands}/app/create.d.ts +0 -0
- package/{dist/commands → commands}/app/create.js +0 -0
- package/commands/app/create.js.map +1 -0
- package/commands/app/create.ts +104 -0
- package/{dist/commands → commands}/app/extract-messages.d.ts +0 -0
- package/{dist/commands → commands}/app/extract-messages.js +0 -0
- package/commands/app/extract-messages.js.map +1 -0
- package/commands/app/extract-messages.ts +56 -0
- package/{dist/commands → commands}/app/index.d.ts +0 -0
- package/{dist/commands → commands}/app/index.js +0 -0
- package/commands/app/index.js.map +1 -0
- package/commands/app/index.ts +14 -0
- package/{dist/commands → commands}/app/update.d.ts +0 -0
- package/{dist/commands → commands}/app/update.js +0 -0
- package/commands/app/update.js.map +1 -0
- package/commands/app/update.ts +111 -0
- package/{dist/commands → commands}/asset/create.d.ts +0 -0
- package/{dist/commands → commands}/asset/create.js +0 -0
- package/commands/asset/create.js.map +1 -0
- package/commands/asset/create.ts +84 -0
- package/{dist/commands → commands}/asset/index.d.ts +0 -0
- package/{dist/commands → commands}/asset/index.js +0 -0
- package/commands/asset/index.js.map +1 -0
- package/commands/asset/index.ts +12 -0
- package/{dist/commands → commands}/block/build.d.ts +0 -0
- package/{dist/commands → commands}/block/build.js +0 -0
- package/commands/block/build.js.map +1 -0
- package/commands/block/build.ts +32 -0
- package/{dist/commands → commands}/block/extract-messages.d.ts +0 -0
- package/{dist/commands → commands}/block/extract-messages.js +0 -0
- package/commands/block/extract-messages.js.map +1 -0
- package/commands/block/extract-messages.ts +41 -0
- package/{dist/commands → commands}/block/index.d.ts +0 -0
- package/{dist/commands → commands}/block/index.js +0 -0
- package/commands/block/index.js.map +1 -0
- package/commands/block/index.ts +14 -0
- package/{dist/commands → commands}/block/publish.d.ts +0 -0
- package/{dist/commands → commands}/block/publish.js +0 -0
- package/commands/block/publish.js.map +1 -0
- package/commands/block/publish.ts +58 -0
- package/{dist/commands → commands}/cleanupResources.d.ts +0 -0
- package/{dist/commands → commands}/cleanupResources.js +0 -0
- package/commands/cleanupResources.js.map +1 -0
- package/commands/cleanupResources.ts +45 -0
- package/{dist/commands → commands}/config/get.d.ts +0 -0
- package/{dist/commands → commands}/config/get.js +0 -0
- package/commands/config/get.js.map +1 -0
- package/commands/config/get.ts +26 -0
- package/{dist/commands → commands}/config/index.d.ts +0 -0
- package/{dist/commands → commands}/config/index.js +0 -0
- package/commands/config/index.js.map +1 -0
- package/commands/config/index.ts +13 -0
- package/{dist/commands → commands}/config/set.d.ts +0 -0
- package/{dist/commands → commands}/config/set.js +0 -0
- package/commands/config/set.js.map +1 -0
- package/commands/config/set.ts +44 -0
- package/{dist/commands → commands}/login.d.ts +0 -0
- package/{dist/commands → commands}/login.js +0 -0
- package/commands/login.js.map +1 -0
- package/commands/login.ts +5 -0
- package/{dist/commands → commands}/logout.d.ts +0 -0
- package/{dist/commands → commands}/logout.js +0 -0
- package/commands/logout.js.map +1 -0
- package/commands/logout.ts +5 -0
- package/{dist/commands → commands}/migrate.d.ts +0 -0
- package/{dist/commands → commands}/migrate.js +5 -2
- package/commands/migrate.js.map +1 -0
- package/commands/migrate.ts +50 -0
- package/{dist/commands → commands}/organization/create.d.ts +0 -0
- package/{dist/commands → commands}/organization/create.js +0 -0
- package/commands/organization/create.js.map +1 -0
- package/commands/organization/create.ts +65 -0
- package/{dist/commands → commands}/organization/index.d.ts +0 -0
- package/{dist/commands → commands}/organization/index.js +0 -0
- package/commands/organization/index.js.map +1 -0
- package/commands/organization/index.ts +13 -0
- package/{dist/commands → commands}/organization/update.d.ts +0 -0
- package/{dist/commands → commands}/organization/update.js +0 -0
- package/commands/organization/update.js.map +1 -0
- package/commands/organization/update.ts +65 -0
- package/{dist/commands → commands}/resource/create.d.ts +0 -0
- package/{dist/commands → commands}/resource/create.js +0 -0
- package/commands/resource/create.js.map +1 -0
- package/commands/resource/create.ts +78 -0
- package/{dist/commands → commands}/resource/index.d.ts +0 -0
- package/{dist/commands → commands}/resource/index.js +0 -0
- package/commands/resource/index.js.map +1 -0
- package/commands/resource/index.ts +13 -0
- package/{dist/commands → commands}/resource/update.d.ts +0 -0
- package/{dist/commands → commands}/resource/update.js +0 -0
- package/commands/resource/update.js.map +1 -0
- package/commands/resource/update.ts +77 -0
- package/{dist/commands → commands}/runCronJobs.d.ts +0 -0
- package/{dist/commands → commands}/runCronJobs.js +0 -0
- package/commands/runCronJobs.js.map +1 -0
- package/commands/runCronJobs.ts +45 -0
- package/{dist/commands → commands}/start.d.ts +0 -0
- package/{dist/commands → commands}/start.js +4 -0
- package/commands/start.js.map +1 -0
- package/commands/start.ts +140 -0
- package/{dist/commands → commands}/team/create.d.ts +0 -0
- package/{dist/commands → commands}/team/create.js +0 -0
- package/commands/team/create.js.map +1 -0
- package/commands/team/create.ts +60 -0
- package/{dist/commands → commands}/team/delete.d.ts +0 -0
- package/{dist/commands → commands}/team/delete.js +0 -0
- package/commands/team/delete.js.map +1 -0
- package/commands/team/delete.ts +54 -0
- package/{dist/commands → commands}/team/index.d.ts +0 -0
- package/{dist/commands → commands}/team/index.js +0 -0
- package/commands/team/index.js.map +1 -0
- package/commands/team/index.ts +15 -0
- package/{dist/commands → commands}/team/member/delete.d.ts +0 -0
- package/{dist/commands → commands}/team/member/delete.js +0 -0
- package/commands/team/member/delete.js.map +1 -0
- package/commands/team/member/delete.ts +61 -0
- package/{dist/commands → commands}/team/member/index.d.ts +0 -0
- package/{dist/commands → commands}/team/member/index.js +0 -0
- package/commands/team/member/index.js.map +1 -0
- package/commands/team/member/index.ts +14 -0
- package/{dist/commands → commands}/team/member/invite.d.ts +0 -0
- package/{dist/commands → commands}/team/member/invite.js +0 -0
- package/commands/team/member/invite.js.map +1 -0
- package/commands/team/member/invite.ts +61 -0
- package/{dist/commands → commands}/team/member/update.d.ts +0 -0
- package/{dist/commands → commands}/team/member/update.js +0 -0
- package/commands/team/member/update.js.map +1 -0
- package/commands/team/member/update.ts +70 -0
- package/{dist/commands → commands}/team/update.d.ts +0 -0
- package/{dist/commands → commands}/team/update.js +0 -0
- package/commands/team/update.js.map +1 -0
- package/commands/team/update.ts +60 -0
- package/index.d.ts +2 -0
- package/{dist/index.js → index.js} +2 -6
- package/index.js.map +1 -0
- package/index.ts +74 -0
- package/jest.config.js +1 -0
- package/jest.setup.d.ts +1 -0
- package/jest.setup.js +6 -0
- package/jest.setup.js.map +1 -0
- package/jest.setup.ts +4 -0
- package/lib/__snapshots__/getBlockConfigFromTypeScript.test.ts.snap +3872 -0
- package/{dist/lib → lib}/app.d.ts +17 -17
- package/{dist/lib → lib}/app.js +29 -29
- package/lib/app.js.map +1 -0
- package/lib/app.ts +797 -0
- package/{dist/lib → lib}/asset.d.ts +0 -0
- package/{dist/lib → lib}/asset.js +0 -0
- package/lib/asset.js.map +1 -0
- package/lib/asset.ts +43 -0
- package/{dist/lib → lib}/authentication.d.ts +3 -3
- package/{dist/lib → lib}/authentication.js +47 -15
- package/lib/authentication.js.map +1 -0
- package/lib/authentication.ts +193 -0
- package/{dist/lib → lib}/block.d.ts +16 -16
- package/{dist/lib → lib}/block.js +35 -26
- package/lib/block.js.map +1 -0
- package/lib/block.test.d.ts +1 -0
- package/lib/block.test.js +106 -0
- package/lib/block.test.js.map +1 -0
- package/lib/block.test.ts +103 -0
- package/lib/block.ts +384 -0
- package/{dist/lib → lib}/coercers.d.ts +2 -2
- package/{dist/lib → lib}/coercers.js +2 -2
- package/lib/coercers.js.map +1 -0
- package/lib/coercers.test.d.ts +1 -0
- package/lib/coercers.test.js +28 -0
- package/lib/coercers.test.js.map +1 -0
- package/lib/coercers.test.ts +27 -0
- package/lib/coercers.ts +57 -0
- package/{dist/lib → lib}/getBlockConfigFromTypeScript.d.ts +1 -1
- package/{dist/lib → lib}/getBlockConfigFromTypeScript.js +38 -36
- package/lib/getBlockConfigFromTypeScript.js.map +1 -0
- package/lib/getBlockConfigFromTypeScript.test.d.ts +1 -0
- package/lib/getBlockConfigFromTypeScript.test.js +238 -0
- package/lib/getBlockConfigFromTypeScript.test.js.map +1 -0
- package/lib/getBlockConfigFromTypeScript.test.ts +281 -0
- package/lib/getBlockConfigFromTypeScript.ts +354 -0
- package/{dist/lib → lib}/initAxios.d.ts +1 -1
- package/{dist/lib → lib}/initAxios.js +3 -4
- package/lib/initAxios.js.map +1 -0
- package/lib/initAxios.ts +16 -0
- package/{dist/lib → lib}/loadWebpackConfig.d.ts +3 -3
- package/{dist/lib → lib}/loadWebpackConfig.js +3 -3
- package/lib/loadWebpackConfig.js.map +1 -0
- package/lib/loadWebpackConfig.ts +59 -0
- package/{dist/lib → lib}/organization.d.ts +1 -1
- package/{dist/lib → lib}/organization.js +0 -0
- package/lib/organization.js.map +1 -0
- package/lib/organization.ts +105 -0
- package/{dist/lib → lib}/output.d.ts +0 -0
- package/{dist/lib → lib}/output.js +0 -0
- package/lib/output.js.map +1 -0
- package/lib/output.ts +19 -0
- package/{dist/lib → lib}/processCss.d.ts +1 -1
- package/{dist/lib → lib}/processCss.js +3 -3
- package/lib/processCss.js.map +1 -0
- package/lib/processCss.ts +24 -0
- package/{dist/lib → lib}/resource.d.ts +0 -0
- package/{dist/lib → lib}/resource.js +1 -1
- package/lib/resource.js.map +1 -0
- package/lib/resource.ts +128 -0
- package/{dist/lib → lib}/serverImport.d.ts +1 -1
- package/{dist/lib → lib}/serverImport.js +2 -2
- package/lib/serverImport.js.map +1 -0
- package/lib/serverImport.ts +43 -0
- package/{dist/lib → lib}/team.d.ts +0 -0
- package/{dist/lib → lib}/team.js +0 -0
- package/lib/team.js.map +1 -0
- package/lib/team.ts +152 -0
- package/package.json +14 -12
- package/tsconfig.json +10 -0
- package/{dist/types.d.ts → types.d.ts} +0 -0
- package/{dist/types.js → types.js} +0 -0
- package/types.js.map +1 -0
- package/types.ts +110 -0
- package/dist/commands/app/create.js.map +0 -1
- package/dist/commands/app/extract-messages.js.map +0 -1
- package/dist/commands/app/index.js.map +0 -1
- package/dist/commands/app/update.js.map +0 -1
- package/dist/commands/asset/create.js.map +0 -1
- package/dist/commands/asset/index.js.map +0 -1
- package/dist/commands/block/build.js.map +0 -1
- package/dist/commands/block/extract-messages.js.map +0 -1
- package/dist/commands/block/index.js.map +0 -1
- package/dist/commands/block/publish.js.map +0 -1
- package/dist/commands/cleanupResources.js.map +0 -1
- package/dist/commands/config/get.js.map +0 -1
- package/dist/commands/config/index.js.map +0 -1
- package/dist/commands/config/set.js.map +0 -1
- package/dist/commands/login.js.map +0 -1
- package/dist/commands/logout.js.map +0 -1
- package/dist/commands/migrate.js.map +0 -1
- package/dist/commands/organization/create.js.map +0 -1
- package/dist/commands/organization/index.js.map +0 -1
- package/dist/commands/organization/update.js.map +0 -1
- package/dist/commands/resource/create.js.map +0 -1
- package/dist/commands/resource/index.js.map +0 -1
- package/dist/commands/resource/update.js.map +0 -1
- package/dist/commands/runCronJobs.js.map +0 -1
- package/dist/commands/start.js.map +0 -1
- package/dist/commands/team/create.js.map +0 -1
- package/dist/commands/team/delete.js.map +0 -1
- package/dist/commands/team/index.js.map +0 -1
- package/dist/commands/team/member/delete.js.map +0 -1
- package/dist/commands/team/member/index.js.map +0 -1
- package/dist/commands/team/member/invite.js.map +0 -1
- package/dist/commands/team/member/update.js.map +0 -1
- package/dist/commands/team/update.js.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js.map +0 -1
- package/dist/lib/app.js.map +0 -1
- package/dist/lib/asset.js.map +0 -1
- package/dist/lib/authentication.js.map +0 -1
- package/dist/lib/block.js.map +0 -1
- package/dist/lib/coercers.js.map +0 -1
- package/dist/lib/getBlockConfigFromTypeScript.js.map +0 -1
- package/dist/lib/initAxios.js.map +0 -1
- package/dist/lib/loadWebpackConfig.js.map +0 -1
- package/dist/lib/organization.js.map +0 -1
- package/dist/lib/output.js.map +0 -1
- package/dist/lib/processCss.js.map +0 -1
- package/dist/lib/readPackageJson.d.ts +0 -9
- package/dist/lib/readPackageJson.js +0 -16
- package/dist/lib/readPackageJson.js.map +0 -1
- package/dist/lib/resource.js.map +0 -1
- package/dist/lib/serverImport.js.map +0 -1
- package/dist/lib/team.js.map +0 -1
- package/dist/types.js.map +0 -1
|
@@ -32,9 +32,9 @@ const node_utils_1 = require("@appsemble/node-utils");
|
|
|
32
32
|
* or asynchronous function which returns a webpack configuration object. This function supports
|
|
33
33
|
* all 3 use cases.
|
|
34
34
|
*
|
|
35
|
-
* @param block
|
|
36
|
-
* @param mode
|
|
37
|
-
* @param outputPath
|
|
35
|
+
* @param block The path to the webpack configuration file.
|
|
36
|
+
* @param mode The env that would be passed to webpack by invoking `webpack --env $env`.
|
|
37
|
+
* @param outputPath The path where the build will be output on disk.
|
|
38
38
|
* @returns The webpack configuration as exposed by the webpack configuration file.
|
|
39
39
|
*/
|
|
40
40
|
async function loadWebpackConfig(block, mode, outputPath) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadWebpackConfig.js","sourceRoot":"","sources":["loadWebpackConfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAA+C;AAI/C;;;;;;;;;;;GAWG;AACI,KAAK,UAAU,iBAAiB,CACrC,KAAkB,EAClB,IAAmC,EACnC,UAAmB;IAEnB,IAAI,UAAkB,CAAC;IACvB,MAAM,cAAc,GAAG,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;IAC9C,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,EAAE;QACrC,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;KAC7D;SAAM;QACL,IAAI;YACF,iEAAiE;YACjE,uDAAuD;YACvD,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,kBAAkB,EAAE,cAAc,CAAC,CAAC;SAClE;QAAC,OAAO,KAAc,EAAE;YACvB,IACE,CAAC,CACE,KAAa,CAAC,IAAI,KAAK,kBAAkB;gBACzC,KAAa,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,UAAU,CAC9C,EACD;gBACA,MAAM,KAAK,CAAC;aACb;YACD,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,2BAA2B,EAAE,cAAc,CAAC,CAAC;SAC3E;KACF;IACD,mBAAM,CAAC,IAAI,CAAC,6BAA6B,UAAU,EAAE,CAAC,CAAC;IACvD,MAAM,UAAU,GAAG,eAAe,KAAK,CAAC,IAAI,aAAa,KAAK,CAAC,OAAO,GAAG,CAAC;IAC1E,IAAI,MAAM,GAAG,wDAAa,UAAU,GAAC,CAAC;IACtC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,CAAC;IAC1C,MAAM,GAAG,MAAM,YAAY,QAAQ,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAEzF,8FAA8F;IAC9F,4FAA4F;IAC5F,UAAU;IACV,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC;IACpC,MAAM,CAAC,MAAM,CAAC,IAAI,GAAG,UAAU,IAAI,UAAU,CAAC;IAC9C,mBAAM,CAAC,OAAO,CAAC,yCAAyC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9E,MAAM,CAAC,MAAM,CAAC,UAAU,GAAG,UAAU,CAAC;IACtC,mBAAM,CAAC,OAAO,CAAC,+CAA+C,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;IAE1F,OAAO,MAAM,CAAC;AAChB,CAAC;AA1CD,8CA0CC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { logger } from '@appsemble/node-utils';
|
|
2
|
+
import { BlockConfig } from '@appsemble/types';
|
|
3
|
+
import { Configuration } from 'webpack';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Load a webpack configuration file.
|
|
7
|
+
*
|
|
8
|
+
* A webpack configuration file may export either an webpack configuration object, or a synchronous
|
|
9
|
+
* or asynchronous function which returns a webpack configuration object. This function supports
|
|
10
|
+
* all 3 use cases.
|
|
11
|
+
*
|
|
12
|
+
* @param block The path to the webpack configuration file.
|
|
13
|
+
* @param mode The env that would be passed to webpack by invoking `webpack --env $env`.
|
|
14
|
+
* @param outputPath The path where the build will be output on disk.
|
|
15
|
+
* @returns The webpack configuration as exposed by the webpack configuration file.
|
|
16
|
+
*/
|
|
17
|
+
export async function loadWebpackConfig(
|
|
18
|
+
block: BlockConfig,
|
|
19
|
+
mode?: 'development' | 'production',
|
|
20
|
+
outputPath?: string,
|
|
21
|
+
): Promise<Configuration> {
|
|
22
|
+
let configPath: string;
|
|
23
|
+
const requireOptions = { paths: [block.dir] };
|
|
24
|
+
if (typeof block.webpack === 'string') {
|
|
25
|
+
configPath = require.resolve(block.webpack, requireOptions);
|
|
26
|
+
} else {
|
|
27
|
+
try {
|
|
28
|
+
// This is resolved relative to the block root, not to this file.
|
|
29
|
+
// eslint-disable-next-line node/no-unpublished-require
|
|
30
|
+
configPath = require.resolve('./webpack.config', requireOptions);
|
|
31
|
+
} catch (error: unknown) {
|
|
32
|
+
if (
|
|
33
|
+
!(
|
|
34
|
+
(error as any).code === 'MODULE_NOT_FOUND' &&
|
|
35
|
+
(error as any).requireStack[0] === __filename
|
|
36
|
+
)
|
|
37
|
+
) {
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
configPath = require.resolve('@appsemble/webpack-config', requireOptions);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
logger.info(`Using webpack config from ${configPath}`);
|
|
44
|
+
const publicPath = `/api/blocks/${block.name}/versions/${block.version}/`;
|
|
45
|
+
let config = await import(configPath);
|
|
46
|
+
config = await (config.default || config);
|
|
47
|
+
config = config instanceof Function ? await config(block, { mode, publicPath }) : config;
|
|
48
|
+
|
|
49
|
+
// Koa-webpack serves assets on the `output.path` path. Normally this field describes where to
|
|
50
|
+
// output the files on the file system. This is monkey patched to support usage with our dev
|
|
51
|
+
// server.
|
|
52
|
+
config.output = config.output || {};
|
|
53
|
+
config.output.path = outputPath || publicPath;
|
|
54
|
+
logger.verbose(`Patched webpack config output.path to ${config.output.path}`);
|
|
55
|
+
config.output.publicPath = publicPath;
|
|
56
|
+
logger.verbose(`Patched webpack config output.publicPath to ${config.output.publicPath}`);
|
|
57
|
+
|
|
58
|
+
return config;
|
|
59
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization.js","sourceRoot":"","sources":["organization.ts"],"names":[],"mappings":";;;;;;AAEA,sDAA+C;AAC/C,kDAA0B;AAC1B,0DAAiC;AAoB1B,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,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,CA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AAE,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"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { ReadStream } from 'fs';
|
|
2
|
+
|
|
3
|
+
import { logger } from '@appsemble/node-utils';
|
|
4
|
+
import axios from 'axios';
|
|
5
|
+
import FormData from 'form-data';
|
|
6
|
+
|
|
7
|
+
interface CreateOrganizationArguments {
|
|
8
|
+
description: string;
|
|
9
|
+
email: string;
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
website: string;
|
|
13
|
+
icon: ReadStream;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface UpdateOrganizationArguments {
|
|
17
|
+
description: string;
|
|
18
|
+
email: string;
|
|
19
|
+
id: string;
|
|
20
|
+
icon: ReadStream;
|
|
21
|
+
name: string;
|
|
22
|
+
website: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function createOrganization({
|
|
26
|
+
description,
|
|
27
|
+
email,
|
|
28
|
+
icon,
|
|
29
|
+
id,
|
|
30
|
+
name,
|
|
31
|
+
website,
|
|
32
|
+
}: CreateOrganizationArguments): Promise<void> {
|
|
33
|
+
const formData = new FormData();
|
|
34
|
+
formData.append('id', id);
|
|
35
|
+
|
|
36
|
+
if (description) {
|
|
37
|
+
logger.info(`Setting description to ${description}`);
|
|
38
|
+
formData.append('description', description);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (email) {
|
|
42
|
+
logger.info(`Setting email to ${email}`);
|
|
43
|
+
formData.append('email', email);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (icon) {
|
|
47
|
+
logger.info(`Including icon ${icon.path || 'from stdin'}`);
|
|
48
|
+
formData.append('icon', icon);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (name) {
|
|
52
|
+
logger.info(`Setting name to ${name}`);
|
|
53
|
+
formData.append('name', name);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (website) {
|
|
57
|
+
logger.info(`Setting website to ${website}`);
|
|
58
|
+
formData.append('website', website);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
logger.info(`Creating organization ${id}${name ? ` (${name})` : ''}`);
|
|
62
|
+
await axios.post('/api/organizations', formData);
|
|
63
|
+
logger.info(`Successfully created organization ${id}${name ? ` (${name})` : ''}`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export async function updateOrganization({
|
|
67
|
+
description,
|
|
68
|
+
email,
|
|
69
|
+
icon,
|
|
70
|
+
id,
|
|
71
|
+
name,
|
|
72
|
+
website,
|
|
73
|
+
}: UpdateOrganizationArguments): Promise<void> {
|
|
74
|
+
logger.info(`Updating organization ${id}${name ? ` (${name})` : ''}`);
|
|
75
|
+
|
|
76
|
+
const formData = new FormData();
|
|
77
|
+
|
|
78
|
+
if (description) {
|
|
79
|
+
logger.info(`Setting description to ${description}`);
|
|
80
|
+
formData.append('description', description);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (email) {
|
|
84
|
+
logger.info(`Setting email to ${email}`);
|
|
85
|
+
formData.append('email', email);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (icon) {
|
|
89
|
+
logger.info(`Including icon ${icon.path || 'from stdin'}`);
|
|
90
|
+
formData.append('icon', icon);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (name) {
|
|
94
|
+
logger.info(`Setting name to ${name}`);
|
|
95
|
+
formData.append('name', name);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (website) {
|
|
99
|
+
logger.info(`Setting website to ${website}`);
|
|
100
|
+
formData.append('website', website);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
await axios.patch(`/api/organizations/${id}`, formData);
|
|
104
|
+
logger.info(`Successfully updated organization ${id}${name ? ` (${name})` : ''}`);
|
|
105
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["output.ts"],"names":[],"mappings":";;;AACA,+BAA0D;AAE1D,SAAgB,eAAe,CAAC,QAAgB,EAAE,IAAY,EAAE,MAAyB;IACvF,MAAM,WAAW,GAAG,IAAI,kBAAW,EAAE,CAAC;IACtC,MAAM,GAAG,GAAG,IAAA,oBAAa,EAAC,IAAI,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;IAEjD,OAAO,MAAM;SACV,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QACb,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACzC,IAAI,MAAM,GAAG,QAAQ,CAAC;QACtB,IAAI,IAAA,aAAM,EAAC,IAAI,CAAC,EAAE;YAChB,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YACzD,MAAM,IAAI,IAAI,IAAI,IAAI,GAAG,EAAE,CAAC;SAC7B;QACD,OAAO,GAAG,MAAM,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;IACtC,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAfD,0CAeC"}
|
package/lib/output.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ValidationError } from 'jsonschema';
|
|
2
|
+
import { isNode, LineCounter, parseDocument } from 'yaml';
|
|
3
|
+
|
|
4
|
+
export function printAxiosError(filename: string, yaml: string, errors: ValidationError[]): string {
|
|
5
|
+
const lineCounter = new LineCounter();
|
|
6
|
+
const doc = parseDocument(yaml, { lineCounter });
|
|
7
|
+
|
|
8
|
+
return errors
|
|
9
|
+
.map((error) => {
|
|
10
|
+
const node = doc.getIn(error.path, true);
|
|
11
|
+
let result = filename;
|
|
12
|
+
if (isNode(node)) {
|
|
13
|
+
const { col, line } = lineCounter.linePos(node.range[0]);
|
|
14
|
+
result += `:${line}:${col}`;
|
|
15
|
+
}
|
|
16
|
+
return `${result} ${error.message}`;
|
|
17
|
+
})
|
|
18
|
+
.join('\n');
|
|
19
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Verifies and processes a CSS file using PostCSS.
|
|
3
3
|
*
|
|
4
|
-
* @param path
|
|
4
|
+
* @param path Filepath of the CSS file
|
|
5
5
|
* @returns Processed CSS files concatenated into a single value.
|
|
6
6
|
*/
|
|
7
7
|
export declare function processCss(path: string): Promise<string>;
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.processCss = void 0;
|
|
7
|
-
const
|
|
7
|
+
const promises_1 = require("fs/promises");
|
|
8
8
|
const postcss_1 = __importDefault(require("postcss"));
|
|
9
9
|
const postcss_import_1 = __importDefault(require("postcss-import"));
|
|
10
10
|
const postcss_load_config_1 = __importDefault(require("postcss-load-config"));
|
|
@@ -12,11 +12,11 @@ const postcss_url_1 = __importDefault(require("postcss-url"));
|
|
|
12
12
|
/**
|
|
13
13
|
* Verifies and processes a CSS file using PostCSS.
|
|
14
14
|
*
|
|
15
|
-
* @param path
|
|
15
|
+
* @param path Filepath of the CSS file
|
|
16
16
|
* @returns Processed CSS files concatenated into a single value.
|
|
17
17
|
*/
|
|
18
18
|
async function processCss(path) {
|
|
19
|
-
const data = await
|
|
19
|
+
const data = await (0, promises_1.readFile)(path, 'utf8');
|
|
20
20
|
const postcssConfig = await (0, postcss_load_config_1.default)();
|
|
21
21
|
const postCss = (0, postcss_1.default)(postcssConfig.plugins);
|
|
22
22
|
postCss.use((0, postcss_url_1.default)({ url: 'inline' }));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processCss.js","sourceRoot":"","sources":["processCss.ts"],"names":[],"mappings":";;;;;;AAAA,0CAAuC;AAEvC,sDAA8B;AAC9B,oEAA2C;AAC3C,8EAA4C;AAC5C,8DAAqC;AAErC;;;;;GAKG;AACI,KAAK,UAAU,UAAU,CAAC,IAAY;IAC3C,MAAM,IAAI,GAAG,MAAM,IAAA,mBAAQ,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAE1C,MAAM,aAAa,GAAG,MAAM,IAAA,6BAAS,GAAE,CAAC;IACxC,MAAM,OAAO,GAAG,IAAA,iBAAO,EAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC/C,OAAO,CAAC,GAAG,CAAC,IAAA,qBAAU,EAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;IAC3C,OAAO,CAAC,GAAG,CAAC,IAAA,wBAAa,EAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAEzD,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IACtE,OAAO,GAAG,CAAC;AACb,CAAC;AAVD,gCAUC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { readFile } from 'fs/promises';
|
|
2
|
+
|
|
3
|
+
import postcss from 'postcss';
|
|
4
|
+
import postcssImport from 'postcss-import';
|
|
5
|
+
import postcssrc from 'postcss-load-config';
|
|
6
|
+
import postcssUrl from 'postcss-url';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Verifies and processes a CSS file using PostCSS.
|
|
10
|
+
*
|
|
11
|
+
* @param path Filepath of the CSS file
|
|
12
|
+
* @returns Processed CSS files concatenated into a single value.
|
|
13
|
+
*/
|
|
14
|
+
export async function processCss(path: string): Promise<string> {
|
|
15
|
+
const data = await readFile(path, 'utf8');
|
|
16
|
+
|
|
17
|
+
const postcssConfig = await postcssrc();
|
|
18
|
+
const postCss = postcss(postcssConfig.plugins);
|
|
19
|
+
postCss.use(postcssUrl({ url: 'inline' }));
|
|
20
|
+
postCss.use(postcssImport({ plugins: postCss.plugins }));
|
|
21
|
+
|
|
22
|
+
const { css } = await postCss.process(data, { from: path, to: null });
|
|
23
|
+
return css;
|
|
24
|
+
}
|
|
File without changes
|
|
@@ -27,7 +27,7 @@ async function createResource({ appId, path, remote, resourceName, }) {
|
|
|
27
27
|
});
|
|
28
28
|
const ids = [].concat(data).map((d) => d.id);
|
|
29
29
|
const url = new URL(`/apps/${appId}/resources/${resourceName}/`, remote);
|
|
30
|
-
node_utils_1.logger.info(`Successfully created ${ids.length
|
|
30
|
+
node_utils_1.logger.info(`Successfully created ${ids.length} resource${resources.length === 1 ? '' : 's'} at: \n${ids
|
|
31
31
|
.map((id) => `${url}${id}`)
|
|
32
32
|
.join('\n')}`);
|
|
33
33
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.js","sourceRoot":"","sources":["resource.ts"],"names":[],"mappings":";;;;;;AAAA,0CAAuC;AAEvC,sDAAy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+1,128 @@
|
|
|
1
|
+
import { readFile } from 'fs/promises';
|
|
2
|
+
|
|
3
|
+
import { AppsembleError, logger, readData } from '@appsemble/node-utils';
|
|
4
|
+
import { Resource } from '@appsemble/types';
|
|
5
|
+
import axios from 'axios';
|
|
6
|
+
|
|
7
|
+
interface UpdateResourceParams {
|
|
8
|
+
/**
|
|
9
|
+
* The name of the resource that a new entry is being created of.
|
|
10
|
+
*/
|
|
11
|
+
resourceName: string;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The path in which the resource JSON is located.
|
|
15
|
+
*/
|
|
16
|
+
path: string;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The ID of the app to create a resource entry for.
|
|
20
|
+
*/
|
|
21
|
+
appId: number;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The remote server to create the app on.
|
|
25
|
+
*/
|
|
26
|
+
remote: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface CreateResourceParams {
|
|
30
|
+
/**
|
|
31
|
+
* The name of the resource that a new entry is being created of.
|
|
32
|
+
*/
|
|
33
|
+
resourceName: string;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The path in which the resource JSON is located.
|
|
37
|
+
*/
|
|
38
|
+
path: string;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The ID of the app to create a resource entry for.
|
|
42
|
+
*/
|
|
43
|
+
appId: number;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The remote server to create the app on.
|
|
47
|
+
*/
|
|
48
|
+
remote: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export async function createResource({
|
|
52
|
+
appId,
|
|
53
|
+
path,
|
|
54
|
+
remote,
|
|
55
|
+
resourceName,
|
|
56
|
+
}: CreateResourceParams): Promise<void> {
|
|
57
|
+
const csv = path.endsWith('.csv');
|
|
58
|
+
let resources: Buffer | Resource[];
|
|
59
|
+
|
|
60
|
+
if (csv) {
|
|
61
|
+
resources = await readFile(path);
|
|
62
|
+
} else {
|
|
63
|
+
const [file] = await readData<Resource>(path);
|
|
64
|
+
|
|
65
|
+
if (typeof file !== 'object') {
|
|
66
|
+
throw new AppsembleError(`File at ${path} does not contain an object or array of objects`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
resources = [].concat(file);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
logger.info(`Creating resource(s) from ${path}`);
|
|
73
|
+
const { data } = await axios.post<Resource | Resource[]>(
|
|
74
|
+
`/api/apps/${appId}/resources/${resourceName}`,
|
|
75
|
+
resources,
|
|
76
|
+
{
|
|
77
|
+
baseURL: remote,
|
|
78
|
+
headers: { 'content-type': csv ? 'text/csv' : 'application/json' },
|
|
79
|
+
},
|
|
80
|
+
);
|
|
81
|
+
const ids: number[] = [].concat(data).map((d: Resource) => d.id);
|
|
82
|
+
const url = new URL(`/apps/${appId}/resources/${resourceName}/`, remote);
|
|
83
|
+
logger.info(
|
|
84
|
+
`Successfully created ${ids.length} resource${resources.length === 1 ? '' : 's'} at: \n${ids
|
|
85
|
+
.map((id) => `${url}${id}`)
|
|
86
|
+
.join('\n')}`,
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export async function updateResource({
|
|
91
|
+
appId,
|
|
92
|
+
path,
|
|
93
|
+
remote,
|
|
94
|
+
resourceName,
|
|
95
|
+
}: UpdateResourceParams): Promise<void> {
|
|
96
|
+
const [file] = await readData<Resource>(path);
|
|
97
|
+
|
|
98
|
+
if (typeof file !== 'object') {
|
|
99
|
+
throw new AppsembleError(`File at ${path} does not contain an object or array of objects`);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const resources = [].concat(file);
|
|
103
|
+
logger.info(`Updating ${resources.length} resource(s) from ${path}`);
|
|
104
|
+
|
|
105
|
+
for (const resource of resources) {
|
|
106
|
+
if (!resource.id) {
|
|
107
|
+
logger.info(`Skipping resource ${resources.indexOf(resource)} because it has no ID.`);
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const {
|
|
112
|
+
data: { id },
|
|
113
|
+
} = await axios.put<Resource>(
|
|
114
|
+
`/api/apps/${appId}/resources/${resourceName}/${resource.id}`,
|
|
115
|
+
resource,
|
|
116
|
+
{
|
|
117
|
+
baseURL: remote,
|
|
118
|
+
},
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
logger.info(
|
|
122
|
+
`Successfully updated resource ${id} at ${new URL(
|
|
123
|
+
`/apps/${appId}/resources/${resourceName}/${id}`,
|
|
124
|
+
remote,
|
|
125
|
+
)}`,
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Import an exported member of @appsemble/server.
|
|
3
3
|
*
|
|
4
|
-
* @param members
|
|
4
|
+
* @param members The names of the exported member to import.
|
|
5
5
|
* @returns The exported member.
|
|
6
6
|
*/
|
|
7
7
|
export declare function serverImport<T extends 'cleanupResources' | 'migrate' | 'runCronJobs' | 'setArgv' | 'start'>(...members: T[]): Promise<Record<T, any>>;
|
|
@@ -37,7 +37,7 @@ ${PROMPT} ${COMMAND} @appsemble/server
|
|
|
37
37
|
/**
|
|
38
38
|
* Import an exported member of @appsemble/server.
|
|
39
39
|
*
|
|
40
|
-
* @param members
|
|
40
|
+
* @param members The names of the exported member to import.
|
|
41
41
|
* @returns The exported member.
|
|
42
42
|
*/
|
|
43
43
|
async function serverImport(...members) {
|
|
@@ -46,7 +46,7 @@ async function serverImport(...members) {
|
|
|
46
46
|
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
|
|
47
47
|
// @ts-ignore Because the the server isn’t built and published, an error is expected here at
|
|
48
48
|
// build time, but while type checking.
|
|
49
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
49
|
+
// eslint-disable-next-line import/no-extraneous-dependencies, node/no-extraneous-import
|
|
50
50
|
const mod = await Promise.resolve().then(() => __importStar(require('@appsemble/server')));
|
|
51
51
|
for (const member of members) {
|
|
52
52
|
if (!(0, utils_1.has)(mod, member)) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serverImport.js","sourceRoot":"","sources":["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,wFAAwF;QACxF,MAAM,GAAG,GAAG,wDAAa,mBAAmB,GAAC,CAAC;QAC9C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;YAC5B,IAAI,CAAC,IAAA,WAAG,EAAC,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,43 @@
|
|
|
1
|
+
import { AppsembleError } from '@appsemble/node-utils';
|
|
2
|
+
import { has } from '@appsemble/utils';
|
|
3
|
+
|
|
4
|
+
const PROMPT = process.platform === 'win32' ? '>' : '$';
|
|
5
|
+
const COMMAND = /yarn/.test(process.env.npm_execpath)
|
|
6
|
+
? 'yarn add --dev --ignore-workspace-root-check'
|
|
7
|
+
: 'npm install --save-dev';
|
|
8
|
+
const INSTALL_MESSAGE = `This command requires the Appsemble server to be installed. It can be installed by running the following command:
|
|
9
|
+
|
|
10
|
+
${PROMPT} ${COMMAND} @appsemble/server
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Import an exported member of @appsemble/server.
|
|
15
|
+
*
|
|
16
|
+
* @param members The names of the exported member to import.
|
|
17
|
+
* @returns The exported member.
|
|
18
|
+
*/
|
|
19
|
+
export async function serverImport<
|
|
20
|
+
T extends 'cleanupResources' | 'migrate' | 'runCronJobs' | 'setArgv' | 'start',
|
|
21
|
+
>(...members: T[]): Promise<Record<T, any>> {
|
|
22
|
+
try {
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
|
|
24
|
+
// @ts-ignore Because the the server isn’t built and published, an error is expected here at
|
|
25
|
+
// build time, but while type checking.
|
|
26
|
+
// eslint-disable-next-line import/no-extraneous-dependencies, node/no-extraneous-import
|
|
27
|
+
const mod = await import('@appsemble/server');
|
|
28
|
+
for (const member of members) {
|
|
29
|
+
if (!has(mod, member)) {
|
|
30
|
+
throw new Error(`@appsemble/server does not export ${member}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return mod;
|
|
34
|
+
} catch (error: unknown) {
|
|
35
|
+
if (
|
|
36
|
+
(error as any).code !== 'MODULE_NOT_FOUND' ||
|
|
37
|
+
(error as any).requireStack?.[0] !== __filename
|
|
38
|
+
) {
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
throw new AppsembleError(INSTALL_MESSAGE);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
File without changes
|
package/{dist/lib → lib}/team.js
RENAMED
|
File without changes
|
package/lib/team.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"team.js","sourceRoot":"","sources":["team.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA+D;AAG/D,kDAA0B;AA2D1B,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,CAAC,CAAC,CACH;QACH,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAfD,gDAeC;AAEM,KAAK,UAAU,UAAU,CAAC,EAC/B,KAAK,EACL,IAAI,EACJ,MAAM,EACN,WAAW,GAAG,EAAE,GACC;IACjB,mBAAM,CAAC,IAAI,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC;IACrC,MAAM,EACJ,IAAI,EAAE,EAAE,EAAE,EAAE,GACb,GAAG,MAAM,eAAK,CAAC,IAAI,CAClB,aAAa,KAAK,QAAQ,EAC1B;QACE,IAAI;QACJ,WAAW,EAAE,kBAAkB,CAAC,WAAW,CAAC;KAC7C,EACD,EAAE,OAAO,EAAE,MAAM,EAAE,CACpB,CAAC;IACF,mBAAM,CAAC,IAA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