@embeddable.com/sdk-core 0.0.14 → 0.0.15
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/bin/embeddable +1 -9
- package/package.json +1 -1
- package/scripts/build.js +1 -1
- package/scripts/createContext.js +1 -0
- package/scripts/findEmbFiles.js +33 -0
- package/scripts/index.js +11 -0
- package/scripts/push.js +15 -4
package/bin/embeddable
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
const { login } = require("../scripts/login");
|
|
6
|
-
const { push } = require("../scripts/push");
|
|
7
|
-
|
|
8
|
-
const COMMANDS_MAP = {
|
|
9
|
-
build,
|
|
10
|
-
login,
|
|
11
|
-
push
|
|
12
|
-
};
|
|
4
|
+
const COMMANDS_MAP = require("../scripts");
|
|
13
5
|
|
|
14
6
|
async function main () {
|
|
15
7
|
const command = process.argv[2];
|
package/package.json
CHANGED
package/scripts/build.js
CHANGED
|
@@ -2,7 +2,7 @@ const path = require("path");
|
|
|
2
2
|
const { prepare } = require("./prepare");
|
|
3
3
|
const { generate } = require("./generate");
|
|
4
4
|
const { cleanup } = require("./cleanup");
|
|
5
|
-
const {createContext} = require("./createContext");
|
|
5
|
+
const { createContext } = require("./createContext");
|
|
6
6
|
|
|
7
7
|
async function build(pluginOptions = {}) {
|
|
8
8
|
const ctx = {
|
package/scripts/createContext.js
CHANGED
|
@@ -10,6 +10,7 @@ function createContext (coreRoot, clientRoot) {
|
|
|
10
10
|
client: {
|
|
11
11
|
rootDir: clientRoot,
|
|
12
12
|
buildDir: path.resolve(clientRoot, '.embeddable-build'),
|
|
13
|
+
srcDir: path.resolve(clientRoot, 'src'),
|
|
13
14
|
tmpDir: path.resolve(clientRoot, '.embeddable-tmp'),
|
|
14
15
|
componentDir: path.resolve(clientRoot, '.embeddable-build', 'component'),
|
|
15
16
|
stencilBuild: path.resolve(clientRoot, '.embeddable-build', 'dist', 'embeddable-wrapper'),
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const fs = require("fs/promises");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
|
|
4
|
+
async function findEmbFiles (initialSrcDir, regex) {
|
|
5
|
+
const filesList = [];
|
|
6
|
+
|
|
7
|
+
async function findEmbFilesRec(srcDir) {
|
|
8
|
+
const allFiles = await fs.readdir(srcDir);
|
|
9
|
+
|
|
10
|
+
for (const file of allFiles) {
|
|
11
|
+
const filePath = path.join(srcDir, file)
|
|
12
|
+
|
|
13
|
+
const status = await fs.lstat(filePath);
|
|
14
|
+
|
|
15
|
+
if (status.isDirectory()) {
|
|
16
|
+
await findEmbFilesRec(filePath)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const fileName = file.match(regex);
|
|
20
|
+
|
|
21
|
+
if (fileName) {
|
|
22
|
+
filesList.push([fileName[1], filePath]);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
await findEmbFilesRec(initialSrcDir);
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
return filesList;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
module.exports = { findEmbFiles };
|
package/scripts/index.js
ADDED
package/scripts/push.js
CHANGED
|
@@ -5,8 +5,11 @@ const archiver = require('archiver');
|
|
|
5
5
|
const axios = require('axios');
|
|
6
6
|
const oraP = import('ora');
|
|
7
7
|
|
|
8
|
-
const {
|
|
9
|
-
const {
|
|
8
|
+
const { findEmbFiles } = require('./findEmbFiles');
|
|
9
|
+
const { createContext } = require("./createContext");
|
|
10
|
+
const { getToken } = require('./login');
|
|
11
|
+
|
|
12
|
+
const EMB_YAML_FILE_REGEX = /^(.*)\.emb\.ya?ml$/;
|
|
10
13
|
|
|
11
14
|
async function push () {
|
|
12
15
|
const ora = (await oraP).default;
|
|
@@ -16,7 +19,10 @@ async function push () {
|
|
|
16
19
|
const token = await verify(ctx);
|
|
17
20
|
|
|
18
21
|
const spinnerArchive = ora("archivation...").start();
|
|
19
|
-
|
|
22
|
+
|
|
23
|
+
const filesList = await findEmbFiles(ctx.client.srcDir, EMB_YAML_FILE_REGEX);
|
|
24
|
+
|
|
25
|
+
await archive(ctx, filesList);
|
|
20
26
|
spinnerArchive.succeed("archivation competed");
|
|
21
27
|
|
|
22
28
|
const spinnerPushing = ora("publishing...").start();
|
|
@@ -45,7 +51,7 @@ async function verify(ctx) {
|
|
|
45
51
|
return token;
|
|
46
52
|
}
|
|
47
53
|
|
|
48
|
-
function archive(ctx) {
|
|
54
|
+
function archive(ctx, yamlFiles) {
|
|
49
55
|
const output = fsSync.createWriteStream(ctx.client.archiveFile);
|
|
50
56
|
const _archiver = archiver('zip', {
|
|
51
57
|
zlib: { level: 9 }
|
|
@@ -53,6 +59,11 @@ function archive(ctx) {
|
|
|
53
59
|
|
|
54
60
|
_archiver.pipe(output);
|
|
55
61
|
_archiver.directory(ctx.client.buildDir, false);
|
|
62
|
+
|
|
63
|
+
for (const fileData of yamlFiles) {
|
|
64
|
+
_archiver.file(fileData[1], { name: `${fileData[0]}.emb.yaml` })
|
|
65
|
+
}
|
|
66
|
+
|
|
56
67
|
_archiver.finalize();
|
|
57
68
|
|
|
58
69
|
return new Promise((resolve, _reject) => {
|