@soleil-se/build-app 1.3.0 → 1.4.0
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/api/isObject.js +3 -0
- package/config.js +8 -2
- package/index.js +6 -5
- package/package.json +9 -9
- package/requests/activateAddon.js +5 -4
- package/requests/addonExists.js +2 -2
- package/requests/createAddon.js +4 -4
- package/requests/index.js +8 -8
- package/requests/signAddon.js +2 -2
- package/requests/uploadAddon.js +3 -3
package/api/isObject.js
ADDED
package/config.js
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import config from '@soleil-se/build-config';
|
|
2
|
-
|
|
3
2
|
import fse from 'fs-extra';
|
|
4
3
|
import { dirname } from 'path';
|
|
5
4
|
|
|
5
|
+
import isObject from './api/isObject.js';
|
|
6
|
+
|
|
6
7
|
function readManifestFile() {
|
|
7
8
|
if (fse.existsSync('./manifest.json')) return fse.readJsonSync('./manifest.json');
|
|
8
9
|
if (fse.existsSync('./src/manifest.json')) return fse.readJsonSync('./src/manifest.json');
|
|
9
10
|
return {};
|
|
10
11
|
}
|
|
11
12
|
|
|
13
|
+
function getAddonName(manifest, addonNameLang = 'sv') {
|
|
14
|
+
return isObject(manifest.name) ? manifest.name[addonNameLang] : manifest.name;
|
|
15
|
+
}
|
|
16
|
+
|
|
12
17
|
function getClientInput() {
|
|
13
18
|
if (fse.existsSync('./src/main.js')) return './src/main.js';
|
|
14
19
|
if (fse.existsSync('./app_src/main.js')) return './app_src/main.js';
|
|
@@ -39,8 +44,9 @@ function getGlobalConfigInput() {
|
|
|
39
44
|
return false;
|
|
40
45
|
}
|
|
41
46
|
|
|
42
|
-
export const { env, projectRoot, rollup } = config;
|
|
47
|
+
export const { env, projectRoot, rollup, addonNameLang } = config;
|
|
43
48
|
export const manifest = readManifestFile();
|
|
49
|
+
export const addonName = getAddonName(manifest, addonNameLang);
|
|
44
50
|
export const type = manifest.type.toLowerCase();
|
|
45
51
|
export const input = {
|
|
46
52
|
client: getClientInput(),
|
package/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { getTimestamp, logError, logInfo, logStartup } from '@soleil-se/build-ut
|
|
|
6
6
|
import chalk from 'chalk';
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
|
-
input, type, manifest, env, projectRoot, rollup, watchPaths, eslintPaths,
|
|
9
|
+
input, type, manifest, addonName, env, projectRoot, rollup, watchPaths, eslintPaths,
|
|
10
10
|
} from './config.js';
|
|
11
11
|
|
|
12
12
|
import { clean, copy, files, zip, eslint } from './utils/index.js';
|
|
@@ -18,7 +18,7 @@ const cssOutput = type === 'webapp' ? './dist/src/css/app.css' : './dist/src/res
|
|
|
18
18
|
const zipPath = `./dist/${manifest.id}-${manifest.version}.zip`;
|
|
19
19
|
|
|
20
20
|
async function main() {
|
|
21
|
-
console.log(getTimestamp(), `${
|
|
21
|
+
console.log(getTimestamp(), `${addonName} (${manifest.id})`);
|
|
22
22
|
logStartup(import.meta.url);
|
|
23
23
|
logInfo(`Using ${chalk.white('project_config.json')} in ${chalk.white(projectRoot)}`);
|
|
24
24
|
const tasks = [
|
|
@@ -62,18 +62,19 @@ async function main() {
|
|
|
62
62
|
];
|
|
63
63
|
|
|
64
64
|
if (args.sign ?? env.sign ?? env.production) {
|
|
65
|
-
tasks.push(task('sign', sign({ src: zipPath, manifest })));
|
|
65
|
+
tasks.push(task('sign', sign({ src: zipPath, addonName, manifest })));
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
if (args.sync) {
|
|
69
69
|
tasks.push(task('upload', upload({
|
|
70
70
|
src: zipPath,
|
|
71
|
+
addonName,
|
|
71
72
|
manifest,
|
|
72
73
|
force: args.force || !env.production,
|
|
73
74
|
})));
|
|
74
75
|
|
|
75
76
|
if (args.activate) {
|
|
76
|
-
tasks.push(task('activate', activate()));
|
|
77
|
+
tasks.push(task('activate', activate(addonName)));
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
80
|
|
|
@@ -82,7 +83,7 @@ async function main() {
|
|
|
82
83
|
} else {
|
|
83
84
|
await runTasks(tasks);
|
|
84
85
|
}
|
|
85
|
-
if (args.run) await runTasks(tasks);
|
|
86
|
+
if (args.build || args.run) await runTasks(tasks);
|
|
86
87
|
}
|
|
87
88
|
|
|
88
89
|
main().catch((e) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soleil-se/build-app",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"bin": {
|
|
5
5
|
"build-app": "./bin/index.js",
|
|
6
6
|
"sv-app-build": "./bin/index.js"
|
|
@@ -14,32 +14,32 @@
|
|
|
14
14
|
},
|
|
15
15
|
"homepage": "https://docs.soleil.se/build/app",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@babel/core": "7.17.
|
|
17
|
+
"@babel/core": "7.17.8",
|
|
18
18
|
"@babel/preset-env": "7.16.11",
|
|
19
19
|
"@rollup/plugin-alias": "3.1.9",
|
|
20
20
|
"@rollup/plugin-babel": "5.3.1",
|
|
21
|
-
"@rollup/plugin-commonjs": "21.0.
|
|
21
|
+
"@rollup/plugin-commonjs": "21.0.3",
|
|
22
22
|
"@rollup/plugin-json": "4.1.0",
|
|
23
23
|
"@rollup/plugin-node-resolve": "13.1.3",
|
|
24
24
|
"@rollup/plugin-replace": "4.0.0",
|
|
25
25
|
"@soleil-se/build-config": "1.1.1",
|
|
26
26
|
"@soleil-se/build-utils": "1.4.0",
|
|
27
27
|
"archiver": "5.3.0",
|
|
28
|
-
"autoprefixer": "10.4.
|
|
28
|
+
"autoprefixer": "10.4.4",
|
|
29
29
|
"babel-plugin-transform-async-to-promises": "0.8.18",
|
|
30
|
-
"chalk": "5.0.
|
|
30
|
+
"chalk": "5.0.1",
|
|
31
31
|
"find-up": "6.3.0",
|
|
32
32
|
"form-data": "4.0.0",
|
|
33
33
|
"fs-extra": "10.0.1",
|
|
34
34
|
"glob": "^7.2.0",
|
|
35
|
-
"got": "12.0.
|
|
35
|
+
"got": "12.0.3",
|
|
36
36
|
"gzip-size": "7.0.0",
|
|
37
37
|
"lodash-es": "4.17.21",
|
|
38
|
-
"postcss": "8.4.
|
|
38
|
+
"postcss": "8.4.12",
|
|
39
39
|
"postcss-discard-duplicates": "5.1.0",
|
|
40
40
|
"postcss-pxtorem": "6.0.0",
|
|
41
41
|
"pretty-bytes": "6.0.0",
|
|
42
|
-
"rollup": "2.
|
|
42
|
+
"rollup": "2.70.1",
|
|
43
43
|
"rollup-plugin-cleanup": "3.2.1",
|
|
44
44
|
"rollup-plugin-insert": "1.3.2",
|
|
45
45
|
"rollup-plugin-postcss": "4.0.2",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"rollup-plugin-svelte": "7.1.0",
|
|
48
48
|
"rollup-plugin-terser": "7.0.2",
|
|
49
49
|
"slash": "4.0.0",
|
|
50
|
-
"svelte-preprocess": "4.10.
|
|
50
|
+
"svelte-preprocess": "4.10.5"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"svelte": "3.46.4"
|
|
@@ -31,9 +31,10 @@ function getPropertiesUri(type, id, version) {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
export default async function activateAddon() {
|
|
34
|
+
export default async function activateAddon(addonName) {
|
|
35
35
|
try {
|
|
36
|
-
const
|
|
36
|
+
const manifest = readManifestFile();
|
|
37
|
+
const { id, version, type } = manifest;
|
|
37
38
|
|
|
38
39
|
const { 'jcr:uuid': customModuleExecutableId } = await addonRequest({
|
|
39
40
|
url: getPropertiesUri(type, id, version),
|
|
@@ -41,12 +42,12 @@ export default async function activateAddon() {
|
|
|
41
42
|
});
|
|
42
43
|
|
|
43
44
|
await addonRequest({
|
|
44
|
-
url: `Addon%20Repository/${encodeURIComponent(
|
|
45
|
+
url: `Addon%20Repository/${encodeURIComponent(addonName)}/activatecustommoduleexecutable`,
|
|
45
46
|
method: 'PUT',
|
|
46
47
|
searchParams: { customModuleExecutableId },
|
|
47
48
|
});
|
|
48
49
|
|
|
49
|
-
logSuccess(`${type} ${chalk.white(`${
|
|
50
|
+
logSuccess(`${type} ${chalk.white(`${addonName} (${id}@${version})`)} activated successfully!`);
|
|
50
51
|
} catch (error) {
|
|
51
52
|
handleError(error);
|
|
52
53
|
}
|
package/requests/addonExists.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import handleError from './api/handleError.js';
|
|
2
2
|
import addonRequest from './api/addonRequest.js';
|
|
3
3
|
|
|
4
|
-
export default async function addonExists(
|
|
4
|
+
export default async function addonExists(addonName) {
|
|
5
5
|
try {
|
|
6
6
|
const addons = await addonRequest('Addon%20Repository/nodes', {
|
|
7
7
|
method: 'GET',
|
|
8
8
|
});
|
|
9
|
-
return !!addons.find((addon) => addon.name ===
|
|
9
|
+
return !!addons.find((addon) => addon.name === addonName);
|
|
10
10
|
} catch (error) {
|
|
11
11
|
return handleError(error);
|
|
12
12
|
}
|
package/requests/createAddon.js
CHANGED
|
@@ -14,13 +14,13 @@ function getCreateUri(type) {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export default async function createAddon({
|
|
17
|
+
export default async function createAddon({ addonName, manifest }) {
|
|
18
18
|
try {
|
|
19
19
|
await addonRequest({
|
|
20
|
-
url: getCreateUri(type),
|
|
21
|
-
searchParams: { name, category: category || 'Other' },
|
|
20
|
+
url: getCreateUri(manifest.type),
|
|
21
|
+
searchParams: { name: addonName, category: manifest.category || 'Other' },
|
|
22
22
|
});
|
|
23
|
-
logSuccess(`${type} ${chalk.white(`${
|
|
23
|
+
logSuccess(`${manifest.type} ${chalk.white(`${addonName} (${manifest.id})`)} created successfully!`);
|
|
24
24
|
} catch (error) {
|
|
25
25
|
handleError(error);
|
|
26
26
|
}
|
package/requests/index.js
CHANGED
|
@@ -4,25 +4,25 @@ import uploadAddon from './uploadAddon.js';
|
|
|
4
4
|
import activateAddon from './activateAddon.js';
|
|
5
5
|
import signAddon from './signAddon.js';
|
|
6
6
|
|
|
7
|
-
export function upload({ src, manifest, force }) {
|
|
7
|
+
export function upload({ src, addonName, manifest, force }) {
|
|
8
8
|
return async () => {
|
|
9
9
|
let checkIfExists = true;
|
|
10
10
|
if (checkIfExists) {
|
|
11
|
-
const exists = await addonExists(
|
|
11
|
+
const exists = await addonExists(addonName);
|
|
12
12
|
if (!exists) {
|
|
13
|
-
await createAddon(manifest);
|
|
13
|
+
await createAddon({ addonName, manifest });
|
|
14
14
|
}
|
|
15
15
|
checkIfExists = false;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
return uploadAddon({
|
|
18
|
+
return uploadAddon({ src, addonName, manifest, force });
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export function activate() {
|
|
23
|
-
return () => activateAddon();
|
|
22
|
+
export function activate(addonName) {
|
|
23
|
+
return () => activateAddon(addonName);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export function sign({ src, manifest }) {
|
|
27
|
-
return () => signAddon({ src, manifest });
|
|
26
|
+
export function sign({ src, addonName, manifest }) {
|
|
27
|
+
return () => signAddon({ src, addonName, manifest });
|
|
28
28
|
}
|
package/requests/signAddon.js
CHANGED
|
@@ -30,14 +30,14 @@ function signRequest(path) {
|
|
|
30
30
|
}).buffer();
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export default async function signAddon({ src, manifest }) {
|
|
33
|
+
export default async function signAddon({ src, addonName, manifest }) {
|
|
34
34
|
try {
|
|
35
35
|
if (!fse.existsSync(src)) throw new Error(`Could not find ${src}`);
|
|
36
36
|
|
|
37
37
|
const response = await signRequest(src);
|
|
38
38
|
await fse.writeFile(src, response);
|
|
39
39
|
|
|
40
|
-
logSuccess(`${manifest.type} ${chalk.white(`${
|
|
40
|
+
logSuccess(`${manifest.type} ${chalk.white(`${addonName} (${manifest.id})`)} signed successfully!`);
|
|
41
41
|
} catch (error) {
|
|
42
42
|
handleError(error);
|
|
43
43
|
}
|
package/requests/uploadAddon.js
CHANGED
|
@@ -17,7 +17,7 @@ function getUploadUri(type, name) {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export default async function uploadAddon({
|
|
20
|
+
export default async function uploadAddon({ src, addonName, manifest, force }) {
|
|
21
21
|
try {
|
|
22
22
|
if (!fse.existsSync(src)) {
|
|
23
23
|
throw new Error(`Could not find ${src}`);
|
|
@@ -25,11 +25,11 @@ export default async function uploadAddon({ id, type, name, src, force }) {
|
|
|
25
25
|
const form = new FormData();
|
|
26
26
|
form.append('file', fse.createReadStream(src));
|
|
27
27
|
|
|
28
|
-
await addonRequest(getUploadUri(type,
|
|
28
|
+
await addonRequest(getUploadUri(manifest.type, addonName), {
|
|
29
29
|
searchParams: { force },
|
|
30
30
|
body: form,
|
|
31
31
|
});
|
|
32
|
-
logSuccess(`${type} ${chalk.white(`${
|
|
32
|
+
logSuccess(`${manifest.type} ${chalk.white(`${addonName} (${manifest.id})`)} uploaded successfully!`);
|
|
33
33
|
} catch (error) {
|
|
34
34
|
handleError(error);
|
|
35
35
|
}
|