@soleil-se/build-app 1.10.0 → 1.11.2

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/index.js CHANGED
@@ -4,10 +4,9 @@ import task from '@soleil-se/build-utils/task';
4
4
  import watch from '@soleil-se/build-utils/watch';
5
5
  import { logError, logStartup, logEnviroment, logTimestamp } from '@soleil-se/build-utils/log';
6
6
  import createChecksumChecker from '@soleil-se/build-utils/createChecksumChecker';
7
- import chalk from 'chalk';
8
- import slash from 'slash';
7
+
9
8
  import {
10
- input, manifest, addonName, env, projectRoot, rollup, watchPaths, eslintPaths,
9
+ input, manifest, addonName, env, rollup, watchPaths, eslintPaths,
11
10
  } from './config.js';
12
11
 
13
12
  import { clean, copy, files, zip, eslint } from './utils/index.js';
@@ -20,10 +19,9 @@ const zipPath = `./dist/${manifest.id}-${manifest.version}.zip`;
20
19
  async function main() {
21
20
  logTimestamp(`${addonName} (${manifest.id})`);
22
21
  logStartup(import.meta.url);
23
- if (!args.project && env) {
22
+ if (!args.project && args.sync && env) {
24
23
  logEnviroment(env);
25
24
  }
26
- logTimestamp(`Config: ${chalk.blue(slash(`${projectRoot}/project_config.json`))}`);
27
25
  const tasks = [
28
26
  task('clean', clean({ dir: './dist' })),
29
27
  args.eslint && task('eslint', eslint({ src: eslintPaths })),
@@ -64,7 +62,7 @@ async function main() {
64
62
  task('zip', zip({ src: './dist/src', dest: zipPath })),
65
63
  ];
66
64
 
67
- if (args.sign ?? env.sign ?? env.production) {
65
+ if (args.sign ?? env?.sign ?? env?.production) {
68
66
  tasks.push(task('sign', sign({ src: zipPath, addonName, manifest })));
69
67
  }
70
68
 
@@ -73,10 +71,10 @@ async function main() {
73
71
  src: zipPath,
74
72
  addonName,
75
73
  manifest,
76
- force: args.force || !env.production,
74
+ force: args.force || !env?.production,
77
75
  })));
78
76
 
79
- if (args.activate) {
77
+ if (args.sync && args.activate) {
80
78
  tasks.push(task('activate', activate(addonName)));
81
79
  }
82
80
  }
@@ -87,7 +85,7 @@ async function main() {
87
85
  } else {
88
86
  await runTasks(tasks);
89
87
  }
90
- if (args.build || args.run) await runTasks(tasks);
88
+ if (args.build) await runTasks(tasks);
91
89
  }
92
90
 
93
91
  main().catch((e) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soleil-se/build-app",
3
- "version": "1.10.0",
3
+ "version": "1.11.2",
4
4
  "bin": {
5
5
  "build-app": "./bin/index.js",
6
6
  "sv-app-build": "./bin/index.js"
@@ -14,12 +14,12 @@
14
14
  },
15
15
  "homepage": "https://docs.soleil.se/build/app",
16
16
  "dependencies": {
17
- "@babel/core": "7.23.3",
18
- "@babel/preset-env": "7.23.3",
19
- "@rollup/plugin-alias": "5.0.1",
17
+ "@babel/core": "7.23.6",
18
+ "@babel/preset-env": "7.23.6",
19
+ "@rollup/plugin-alias": "5.1.0",
20
20
  "@rollup/plugin-babel": "6.0.4",
21
21
  "@rollup/plugin-commonjs": "25.0.7",
22
- "@rollup/plugin-json": "6.0.1",
22
+ "@rollup/plugin-json": "6.1.0",
23
23
  "@rollup/plugin-node-resolve": "15.2.3",
24
24
  "@rollup/plugin-replace": "5.0.5",
25
25
  "@rollup/plugin-terser": "0.4.4",
@@ -29,26 +29,28 @@
29
29
  "chalk": "5.3.0",
30
30
  "find-up": "6.3.0",
31
31
  "form-data": "4.0.0",
32
- "fs-extra": "11.1.1",
32
+ "fs-extra": "11.2.0",
33
33
  "glob": "^10.3.10",
34
34
  "got": "13.0.0",
35
35
  "gzip-size": "7.0.0",
36
36
  "lodash-es": "4.17.21",
37
- "postcss": "8.4.31",
37
+ "minimist": "^1.2.8",
38
+ "postcss": "8.4.32",
38
39
  "postcss-pxtorem": "6.0.0",
39
40
  "pretty-bytes": "6.1.1",
41
+ "prompts": "^2.4.2",
40
42
  "rollup": "3.29.4",
41
43
  "rollup-plugin-cleanup": "3.2.1",
42
44
  "rollup-plugin-postcss": "4.0.2",
43
45
  "rollup-plugin-string": "3.0.0",
44
46
  "rollup-plugin-svelte": "7.1.6",
45
47
  "slash": "5.1.0",
46
- "svelte-preprocess": "5.1.0",
47
- "@soleil-se/build-config": "1.1.3",
48
- "@soleil-se/build-utils": "1.5.1"
48
+ "svelte-preprocess": "5.1.3",
49
+ "@soleil-se/build-config": "1.2.0",
50
+ "@soleil-se/build-utils": "1.6.0"
49
51
  },
50
52
  "devDependencies": {
51
- "svelte": "4.2.7"
53
+ "svelte": "4.2.8"
52
54
  },
53
55
  "scripts": {},
54
56
  "description": "Script for building WebApps, RESTApps and Widgets with Svelte in Sitevision.",
@@ -1,17 +1,38 @@
1
1
  import { basename } from 'path';
2
2
  import fse from 'fs-extra';
3
3
  import chalk from 'chalk';
4
+ import prompts from 'prompts';
4
5
  import got from 'got';
5
6
  import FormData from 'form-data';
6
7
  import { logSuccess } from '@soleil-se/build-utils/log';
7
8
  import config from '@soleil-se/build-config';
8
-
9
9
  import handleError from './api/handleError.js';
10
10
 
11
- const { certificate, auth } = config.webappSign;
12
- const [username, password] = Buffer.from(auth || '', 'base64').toString().split(':');
11
+ function getCertificate() {
12
+ if (config.webappSign) return config.webappSign.certificate || '';
13
+ return prompts({
14
+ type: 'text',
15
+ name: 'certificate',
16
+ message: 'Certificate name? (Leave empty for default)',
17
+ }).then(({ certificate }) => certificate);
18
+ }
19
+
20
+ function getAuth() {
21
+ const { auth } = config.webappSign || {};
22
+ if (auth) {
23
+ const [username, password] = Buffer.from(auth || '', 'base64').toString().split(':');
24
+ return { username, password };
25
+ }
26
+ return prompts([
27
+ { type: 'text', name: 'username', message: 'Username?', validate: (value) => (value ? true : 'Username is required.') },
28
+ { type: 'password', name: 'password', message: 'Password?', validate: (value) => (value ? true : 'Password is required.') },
29
+ ]);
30
+ }
13
31
 
14
- function signRequest(path) {
32
+ async function signRequest(path) {
33
+ const { username, password } = await getAuth();
34
+ if (!username || !password) throw new Error('Signing aborted...');
35
+ const certificate = await getCertificate();
15
36
  const form = new FormData();
16
37
  const filename = basename(path);
17
38
  form.append('file', fse.createReadStream(path), {
@@ -8,24 +8,24 @@ const resolveAlias = (root, aliases = {}) => Object.entries(aliases)
8
8
  [key]: path.resolve(root, value),
9
9
  }), {});
10
10
 
11
- const clientAlias = resolveAlias(config.projectRoot, {
11
+ const clientAlias = config?.projectRoot ? resolveAlias(config.projectRoot, {
12
12
  '#api/webapps': './server_src/webapps/api',
13
13
  '#api': './server_src/api',
14
14
  '#components': './server_src/webapps/components',
15
15
  ...config?.rollup?.client?.alias,
16
- });
16
+ }) : {};
17
17
 
18
18
  export function getAliasClientPlugin() {
19
19
  return alias({ entries: clientAlias });
20
20
  }
21
21
 
22
- const serverAlias = resolveAlias(config.projectRoot, {
22
+ const serverAlias = config?.projectRoot ? resolveAlias(config.projectRoot, {
23
23
  '#api/webapps': './server_src/webapps/api',
24
24
  '#api/restapps': './server_src/restapps/api',
25
25
  '#api': './server_src/api',
26
26
  '#components': './server_src/webapps/components',
27
27
  ...config?.rollup?.server?.alias,
28
- });
28
+ }) : {};
29
29
 
30
30
  export function getAliasServerPlugin() {
31
31
  return alias({ entries: serverAlias });
@@ -6,7 +6,7 @@ export function getReplaceClientPlugin() {
6
6
  "typeof process !== 'undefined' ? process.server : typeof window === 'undefined'": false,
7
7
  'process.server': false,
8
8
  'process.browser': true,
9
- 'process.env.NODE_ENV': JSON.stringify(config.env.production ? 'production' : 'development'),
9
+ 'process.env.NODE_ENV': JSON.stringify(config?.env?.production ? 'production' : 'development'),
10
10
  preventAssignment: true,
11
11
  delimiters: ['', ''],
12
12
  });
package/rollup/client.js CHANGED
@@ -16,8 +16,9 @@ import getPostcssPlugin from './api/getPostcssPlugin.js';
16
16
  import getTerserPlugin from './api/getTerserPlugin.js';
17
17
  import getStringPlugin from './api/getStringPlugin.js';
18
18
 
19
- import sitevision from './plugins/sitevisionClient.js';
20
- import bundleSize from './plugins/bundleSize.js';
19
+ import sitevisionPlugin from './plugins/sitevisionClient.js';
20
+ import bundleSizePlugin from './plugins/bundleSize.js';
21
+ import amdGlobalsPlugin from './plugins/amdGlobals.js';
21
22
 
22
23
  export default function rollupClient({
23
24
  debug,
@@ -35,14 +36,14 @@ export default function rollupClient({
35
36
  let bundleCache;
36
37
  let plugins;
37
38
 
38
- const external = Object.keys(globals);
39
- if (bundled) external.push(...getSitevisionClientPackages());
39
+ const external = bundled ? getSitevisionClientPackages() : Object.keys(globals);
40
40
 
41
41
  return async () => {
42
42
  if (!fse.existsSync(input)) return Promise.resolve();
43
43
 
44
44
  plugins = plugins || [
45
- bundled ? sitevision() : false,
45
+ bundled ? sitevisionPlugin() : false,
46
+ bundled ? amdGlobalsPlugin({ globals }) : false,
46
47
  getReplaceClientPlugin(),
47
48
  getAliasClientPlugin(),
48
49
  getNodeResolvePlugin({ input }),
@@ -52,7 +53,7 @@ export default function rollupClient({
52
53
  getBabelClientPlugin(),
53
54
  json(),
54
55
  getStringPlugin(),
55
- showSize && bundleSize(),
56
+ showSize && bundleSizePlugin(),
56
57
  getTerserPlugin({ debug }),
57
58
  ];
58
59
 
@@ -0,0 +1,32 @@
1
+ export default function amdGlobals({ globals } = {}) {
2
+ const ignored = [];
3
+
4
+ function shouldLoad(id) {
5
+ return !ignored.includes(id);
6
+ }
7
+
8
+ return {
9
+ name: 'rollup-plugin-amd-globals',
10
+ resolveId(importee) {
11
+ if (!Object.keys(globals).includes(importee)) {
12
+ // Should be handled as usual.
13
+ return null;
14
+ }
15
+ // Most likely a global dependency.
16
+ // Do not ask other plugins or check the file system to find it.
17
+ if (!ignored.includes(importee)) {
18
+ ignored.push(importee);
19
+ }
20
+ return importee;
21
+ },
22
+ load(id) {
23
+ if (shouldLoad(id)) {
24
+ return null;
25
+ }
26
+ // The virtual source code for the provided global dependency.
27
+ return {
28
+ code: `export default window['${globals[id]}'];`,
29
+ };
30
+ },
31
+ };
32
+ }