@embeddable.com/sdk-core 1.0.0 → 2.0.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/lib/index.esm.js CHANGED
@@ -1,3 +1,5 @@
1
+ import path from 'node:path';
2
+
1
3
  var normalizeEntities = function (entities, _a) {
2
4
  var _b = _a.mapFn, mapFn = _b === void 0 ? function (x) { return x; } : _b, _c = _a.filterFn, filterFn = _c === void 0 ? Boolean : _c;
3
5
  if (!entities)
@@ -67,6 +69,32 @@ var loadData = function (requestParams) { return ({
67
69
  dataLoader: executeDataRequest,
68
70
  }); };
69
71
 
72
+ var defineConfig = function (_a) {
73
+ var plugins = _a.plugins;
74
+ var coreRoot = path.resolve(__dirname, "..");
75
+ var clientRoot = process.cwd();
76
+ return {
77
+ core: {
78
+ rootDir: coreRoot,
79
+ templatesDir: path.resolve(coreRoot, "templates"),
80
+ configsDir: path.resolve(coreRoot, "configs"),
81
+ },
82
+ client: {
83
+ rootDir: clientRoot,
84
+ buildDir: path.resolve(clientRoot, ".embeddable-build"),
85
+ srcDir: path.resolve(clientRoot, "src"),
86
+ tmpDir: path.resolve(clientRoot, ".embeddable-tmp"),
87
+ componentDir: path.resolve(clientRoot, ".embeddable-build", "component"),
88
+ stencilBuild: path.resolve(clientRoot, ".embeddable-build", "dist", "embeddable-wrapper"),
89
+ archiveFile: path.resolve(clientRoot, "embeddable-build.zip"),
90
+ },
91
+ outputOptions: {
92
+ typesEntryPointFilename: "embeddable-types-entry-point.js",
93
+ },
94
+ plugins: plugins,
95
+ };
96
+ };
97
+
70
98
  var getOperationObject = function (operation, value) { return ({
71
99
  operation: operation,
72
100
  value: value,
@@ -124,25 +152,22 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
124
152
  };
125
153
 
126
154
  var embedType = function (typeName, typeConfig) {
127
- // @ts-ignore
128
- window.__EMBEDDABLE__ = window.__EMBEDDABLE__ || {};
129
- // @ts-ignore
130
- window.__EMBEDDABLE__.types = window.__EMBEDDABLE__.types || {};
131
- // @ts-ignore
132
- window.__EMBEDDABLE__.types[typeName] = __assign({ name: typeName }, typeConfig);
155
+ globalThis.__EMBEDDABLE__ = globalThis.__EMBEDDABLE__ || {};
156
+ globalThis.__EMBEDDABLE__.types = globalThis.__EMBEDDABLE__.types || {};
157
+ globalThis.__EMBEDDABLE__.types[typeName] = __assign({ name: typeName }, typeConfig);
158
+ return {
159
+ toString: function () { return typeName; },
160
+ typeConfig: typeConfig,
161
+ };
133
162
  };
134
163
 
135
164
  var embedOption = function (typeName, option) {
136
- // @ts-ignore
137
- window.__EMBEDDABLE__ = window.__EMBEDDABLE__ || {};
138
- // @ts-ignore
139
- if (!window.__EMBEDDABLE__.types[typeName])
165
+ globalThis.__EMBEDDABLE__ = globalThis.__EMBEDDABLE__ || {};
166
+ if (!globalThis.__EMBEDDABLE__.types[typeName])
140
167
  return;
141
- // @ts-ignore
142
- window.__EMBEDDABLE__.types[typeName].options =
143
- window.__EMBEDDABLE__.types[typeName].options || [];
144
- // @ts-ignore
145
- window.__EMBEDDABLE__.types[typeName].options.push(option);
168
+ globalThis.__EMBEDDABLE__.types[typeName].options =
169
+ globalThis.__EMBEDDABLE__.types[typeName].options || [];
170
+ globalThis.__EMBEDDABLE__.types[typeName].options.push(option);
146
171
  };
147
172
 
148
- export { Value, embedOption, embedType, isLoadDataParams, loadData, setValue };
173
+ export { Value, defineConfig, embedOption, embedType, isLoadDataParams, loadData, setValue };
package/lib/index.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
- typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.embeddableSdk = {}));
5
- })(this, (function (exports) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('node:path')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'node:path'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.embeddableSdk = {}, global.path));
5
+ })(this, (function (exports, path) { 'use strict';
6
6
 
7
7
  var normalizeEntities = function (entities, _a) {
8
8
  var _b = _a.mapFn, mapFn = _b === void 0 ? function (x) { return x; } : _b, _c = _a.filterFn, filterFn = _c === void 0 ? Boolean : _c;
@@ -73,6 +73,32 @@
73
73
  dataLoader: executeDataRequest,
74
74
  }); };
75
75
 
76
+ var defineConfig = function (_a) {
77
+ var plugins = _a.plugins;
78
+ var coreRoot = path.resolve(__dirname, "..");
79
+ var clientRoot = process.cwd();
80
+ return {
81
+ core: {
82
+ rootDir: coreRoot,
83
+ templatesDir: path.resolve(coreRoot, "templates"),
84
+ configsDir: path.resolve(coreRoot, "configs"),
85
+ },
86
+ client: {
87
+ rootDir: clientRoot,
88
+ buildDir: path.resolve(clientRoot, ".embeddable-build"),
89
+ srcDir: path.resolve(clientRoot, "src"),
90
+ tmpDir: path.resolve(clientRoot, ".embeddable-tmp"),
91
+ componentDir: path.resolve(clientRoot, ".embeddable-build", "component"),
92
+ stencilBuild: path.resolve(clientRoot, ".embeddable-build", "dist", "embeddable-wrapper"),
93
+ archiveFile: path.resolve(clientRoot, "embeddable-build.zip"),
94
+ },
95
+ outputOptions: {
96
+ typesEntryPointFilename: "embeddable-types-entry-point.js",
97
+ },
98
+ plugins: plugins,
99
+ };
100
+ };
101
+
76
102
  var getOperationObject = function (operation, value) { return ({
77
103
  operation: operation,
78
104
  value: value,
@@ -130,28 +156,26 @@
130
156
  };
131
157
 
132
158
  var embedType = function (typeName, typeConfig) {
133
- // @ts-ignore
134
- window.__EMBEDDABLE__ = window.__EMBEDDABLE__ || {};
135
- // @ts-ignore
136
- window.__EMBEDDABLE__.types = window.__EMBEDDABLE__.types || {};
137
- // @ts-ignore
138
- window.__EMBEDDABLE__.types[typeName] = __assign({ name: typeName }, typeConfig);
159
+ globalThis.__EMBEDDABLE__ = globalThis.__EMBEDDABLE__ || {};
160
+ globalThis.__EMBEDDABLE__.types = globalThis.__EMBEDDABLE__.types || {};
161
+ globalThis.__EMBEDDABLE__.types[typeName] = __assign({ name: typeName }, typeConfig);
162
+ return {
163
+ toString: function () { return typeName; },
164
+ typeConfig: typeConfig,
165
+ };
139
166
  };
140
167
 
141
168
  var embedOption = function (typeName, option) {
142
- // @ts-ignore
143
- window.__EMBEDDABLE__ = window.__EMBEDDABLE__ || {};
144
- // @ts-ignore
145
- if (!window.__EMBEDDABLE__.types[typeName])
169
+ globalThis.__EMBEDDABLE__ = globalThis.__EMBEDDABLE__ || {};
170
+ if (!globalThis.__EMBEDDABLE__.types[typeName])
146
171
  return;
147
- // @ts-ignore
148
- window.__EMBEDDABLE__.types[typeName].options =
149
- window.__EMBEDDABLE__.types[typeName].options || [];
150
- // @ts-ignore
151
- window.__EMBEDDABLE__.types[typeName].options.push(option);
172
+ globalThis.__EMBEDDABLE__.types[typeName].options =
173
+ globalThis.__EMBEDDABLE__.types[typeName].options || [];
174
+ globalThis.__EMBEDDABLE__.types[typeName].options.push(option);
152
175
  };
153
176
 
154
177
  exports.Value = Value;
178
+ exports.defineConfig = defineConfig;
155
179
  exports.embedOption = embedOption;
156
180
  exports.embedType = embedType;
157
181
  exports.isLoadDataParams = isLoadDataParams;
package/lib/loadData.d.ts CHANGED
@@ -1,18 +1,22 @@
1
- declare const cubeType: {
1
+ declare const cubeNativeType: {
2
2
  readonly string: "string";
3
3
  readonly number: "number";
4
4
  readonly time: "time";
5
5
  };
6
- export type CubeType = keyof typeof cubeType;
6
+ export type NativeType = keyof typeof cubeNativeType;
7
7
  export type Dimension = {
8
8
  name: string;
9
9
  title: string;
10
- type: CubeType;
10
+ nativeType: NativeType;
11
+ description?: string;
12
+ meta?: object;
11
13
  };
12
14
  export type Measure = {
13
15
  name: string;
14
16
  title: string;
15
- type: string;
17
+ nativeType: NativeType;
18
+ description?: string;
19
+ meta?: object;
16
20
  };
17
21
  export type DimensionOrMeasure = Dimension | Measure;
18
22
  declare const timeDimensionGranularity: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embeddable.com/sdk-core",
3
- "version": "1.0.0",
3
+ "version": "2.0.0",
4
4
  "description": "Core Embeddable SDK module responsible for web-components bundling and publishing.",
5
5
  "keywords": [
6
6
  "embeddable",
@@ -21,8 +21,8 @@
21
21
  },
22
22
  "author": "Oleg Kapustin <oleg@trevor.io>",
23
23
  "files": [
24
+ "dist/",
24
25
  "lib/",
25
- "scripts/",
26
26
  "templates/",
27
27
  "configs/"
28
28
  ],
@@ -31,6 +31,7 @@
31
31
  },
32
32
  "license": "MIT",
33
33
  "dependencies": {
34
+ "@embeddable.com/sdk-utils": "*",
34
35
  "@stencil/core": "^4.0.0",
35
36
  "archiver": "^5.3.1",
36
37
  "axios": "^1.4.0",
@@ -42,5 +43,8 @@
42
43
  "*.{js,ts,json}": [
43
44
  "prettier --write"
44
45
  ]
46
+ },
47
+ "devDependencies": {
48
+ "@types/archiver": "^5.3.4"
45
49
  }
46
50
  }
@@ -22,6 +22,10 @@ export class EmbeddableComponent {
22
22
  this.handlePops();
23
23
  }
24
24
 
25
+ disconnectedCallback() {
26
+ this.rootElement.dispatchEvent(new CustomEvent('EMBEDDABLE_COMPONENT:UNMOUNT'));
27
+ }
28
+
25
29
  componentWillUpdate() {
26
30
  const event = new CustomEvent('embeddable-event:update-props', {
27
31
  bubbles: false,
package/scripts/build.js DELETED
@@ -1,20 +0,0 @@
1
- const path = require("path");
2
- const { prepare } = require("./prepare");
3
- const { generate } = require("./generate");
4
- const { cleanup } = require("./cleanup");
5
- const { createContext } = require("./createContext");
6
-
7
- async function build(pluginOptions = {}) {
8
- const ctx = {
9
- ...createContext(path.resolve(__dirname, ".."), process.cwd()),
10
- pluginOptions,
11
- };
12
-
13
- await prepare(ctx);
14
-
15
- await generate(ctx);
16
-
17
- await cleanup(ctx);
18
- }
19
-
20
- module.exports = { build };
@@ -1,61 +0,0 @@
1
- const fs = require("node:fs/promises");
2
- const path = require("node:path");
3
- const vite = require("vite");
4
-
5
- const { findEmbFiles } = require("./findEmbFiles");
6
-
7
- const EMB_TYPE_FILE_REGEX = /^(.*)\.type\.emb\.[jt]s$/;
8
- const EMB_OPTIONS_FILE_REGEX = /^(.*)\.options\.emb\.[jt]s$/;
9
-
10
- async function buildTypes(ctx) {
11
- await generate(ctx);
12
-
13
- await build(ctx);
14
-
15
- await cleanup(ctx);
16
- }
17
-
18
- module.exports = { buildTypes };
19
-
20
- async function generate(ctx) {
21
- const typeFiles = await findEmbFiles(ctx.client.srcDir, EMB_TYPE_FILE_REGEX);
22
- const optionsFiles = await findEmbFiles(
23
- ctx.client.srcDir,
24
- EMB_OPTIONS_FILE_REGEX,
25
- );
26
-
27
- const typeImports = typeFiles
28
- .concat(optionsFiles)
29
- .map(
30
- ([fileName, filePath]) =>
31
- `import './${path.relative(ctx.client.rootDir, filePath)}';`,
32
- )
33
- .join("\n");
34
-
35
- await fs.writeFile(
36
- path.resolve(ctx.client.rootDir, ctx.outputOptions.typesEntryPointFilename),
37
- typeImports,
38
- );
39
- }
40
-
41
- async function build(ctx) {
42
- process.chdir(ctx.client.rootDir);
43
-
44
- await vite.build({
45
- build: {
46
- emptyOutDir: false,
47
- lib: {
48
- entry: `./${ctx.outputOptions.typesEntryPointFilename}`,
49
- formats: ["es"],
50
- fileName: "embeddable-types",
51
- },
52
- outDir: ".embeddable-build/",
53
- },
54
- });
55
- }
56
-
57
- async function cleanup(ctx) {
58
- await fs.rm(
59
- path.resolve(ctx.client.rootDir, "embeddable-types-entry-point.js"),
60
- );
61
- }
@@ -1,27 +0,0 @@
1
- const fs = require("fs/promises");
2
- const path = require("path");
3
-
4
- async function cleanup(ctx) {
5
- await extractBuild(ctx);
6
-
7
- await removeObsoleteDir(ctx.client.buildDir);
8
-
9
- await moveBuildTOBuildDir(ctx);
10
- }
11
-
12
- module.exports = { cleanup };
13
-
14
- async function extractBuild(ctx) {
15
- await fs.rename(
16
- path.resolve(ctx.client.buildDir, ctx.client.stencilBuild),
17
- ctx.client.tmpDir,
18
- );
19
- }
20
-
21
- async function removeObsoleteDir(dir) {
22
- await fs.rm(dir, { recursive: true });
23
- }
24
-
25
- async function moveBuildTOBuildDir(ctx) {
26
- await fs.rename(ctx.client.tmpDir, ctx.client.buildDir);
27
- }
@@ -1,27 +0,0 @@
1
- const path = require("path");
2
-
3
- function createContext(coreRoot, clientRoot) {
4
- return {
5
- core: {
6
- rootDir: coreRoot,
7
- templatesDir: path.resolve(coreRoot, "templates"),
8
- configsDir: path.resolve(coreRoot, "configs"),
9
- },
10
- client: {
11
- rootDir: clientRoot,
12
- buildDir: path.resolve(clientRoot, ".embeddable-build"),
13
- srcDir: path.resolve(clientRoot, "src"),
14
- tmpDir: path.resolve(clientRoot, ".embeddable-tmp"),
15
- componentDir: path.resolve(clientRoot, ".embeddable-build", "component"),
16
- stencilBuild: path.resolve(
17
- clientRoot,
18
- ".embeddable-build",
19
- "dist",
20
- "embeddable-wrapper",
21
- ),
22
- archiveFile: path.resolve(clientRoot, "embeddable-build.zip"),
23
- },
24
- };
25
- }
26
-
27
- module.exports = { createContext };
@@ -1,32 +0,0 @@
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
- return filesList;
30
- }
31
-
32
- module.exports = { findEmbFiles };
@@ -1,72 +0,0 @@
1
- const fs = require("fs/promises");
2
- const path = require("path");
3
-
4
- const stencilNodeApi = require("@stencil/core/sys/node");
5
- const stencil = require("@stencil/core/cli");
6
-
7
- const STYLE_IMPORTS_TOKEN = "{{STYLES_IMPORT}}";
8
- const RENDER_IMPORT_TOKEN = "{{RENDER_IMPORT}}";
9
-
10
- const NODE_LOGGER = stencilNodeApi.createNodeLogger({ process: process });
11
- const NODE_SYS = stencilNodeApi.createNodeSys({
12
- process: process,
13
- logger: NODE_LOGGER,
14
- });
15
-
16
- async function generate(ctx) {
17
- await injectCSS(ctx);
18
-
19
- await injectBundleRender(ctx);
20
-
21
- await runStencil(ctx);
22
- }
23
-
24
- module.exports = { generate };
25
-
26
- async function injectCSS(ctx) {
27
- const CUSTOMER_BUILD = path.resolve(
28
- ctx.client.buildDir,
29
- ctx.pluginOptions.outDir,
30
- );
31
- const allFiles = await fs.readdir(CUSTOMER_BUILD);
32
-
33
- const cssFilesImportsStr = allFiles
34
- .filter((fileName) => fileName.endsWith(".css"))
35
- .map((fileName) => `@import '../${ctx.pluginOptions.outDir}/${fileName}';`)
36
- .join("\n");
37
-
38
- const content = await fs.readFile(
39
- path.resolve(ctx.core.templatesDir, "style.css.template"),
40
- "utf8",
41
- );
42
-
43
- await fs.writeFile(
44
- path.resolve(ctx.client.componentDir, "style.css"),
45
- content.replace(STYLE_IMPORTS_TOKEN, cssFilesImportsStr),
46
- );
47
- }
48
-
49
- async function injectBundleRender(ctx) {
50
- const importStr = `import render from '../${ctx.pluginOptions.outDir}/${ctx.pluginOptions.renderFunctionFileName}';`;
51
-
52
- const content = await fs.readFile(
53
- path.resolve(ctx.core.templatesDir, "component.tsx.template"),
54
- "utf8",
55
- );
56
-
57
- await fs.writeFile(
58
- path.resolve(ctx.client.componentDir, "component.tsx"),
59
- content.replace(RENDER_IMPORT_TOKEN, importStr),
60
- );
61
- }
62
-
63
- async function runStencil(ctx) {
64
- process.chdir(ctx.client.buildDir);
65
-
66
- await stencil.run({
67
- args: ["build"],
68
- logger: NODE_LOGGER,
69
- sys: NODE_SYS,
70
- checkVersion: stencilNodeApi.checkVersion,
71
- });
72
- }
@@ -1,13 +0,0 @@
1
- const fsP = require("node:fs/promises");
2
- const fs = require("node:fs")
3
- const path = require("node:path");
4
- async function globalCleanup(ctx) {
5
- const componentsEntryPath = path.resolve(ctx.client.rootDir, ctx.outputOptions.componentsEntryPointFilename);
6
- const typesEntryPath = path.resolve(ctx.client.rootDir, ctx.outputOptions.typesEntryPointFilename);
7
-
8
- if (fs.existsSync(ctx.client.buildDir)) await fsP.rm(ctx.client.buildDir, { recursive: true });
9
- if (fs.existsSync(componentsEntryPath)) await fsP.rm(componentsEntryPath);
10
- if (fs.existsSync(typesEntryPath)) await fsP.rm(typesEntryPath);
11
- }
12
-
13
- module.exports = { globalCleanup };
package/scripts/index.js DELETED
@@ -1,17 +0,0 @@
1
- const { build } = require("./build");
2
- const { buildTypes } = require("./buildTypes");
3
- const { findEmbFiles } = require("./findEmbFiles");
4
- const { login } = require("./login");
5
- const { push } = require("./push");
6
- const { validate } = require("./validate");
7
- const { globalCleanup } = require("./globalCleanup");
8
-
9
- module.exports = {
10
- build,
11
- buildTypes,
12
- findEmbFiles,
13
- login,
14
- push,
15
- validate,
16
- globalCleanup,
17
- };
package/scripts/login.js DELETED
@@ -1,93 +0,0 @@
1
- const path = require("path");
2
- const os = require("os");
3
- const fs = require("fs/promises");
4
- const axios = require("axios");
5
- const oraP = import("ora");
6
- const openP = import("open");
7
-
8
- const CREDENTIALS_DIR = path.resolve(os.homedir(), ".embeddable");
9
- const CREDENTIALS_FILE = path.resolve(CREDENTIALS_DIR, "credentials");
10
-
11
- const AUTH0_DOMAIN = "embeddable-dev.eu.auth0.com";
12
- const AUTH0_CLIENT_ID = "xOKco5ztFCpWn54bJbFkAcT8mV4LLcpG";
13
-
14
- async function login() {
15
- const ora = (await oraP).default;
16
- const open = (await openP).default
17
-
18
- await resolveFiles();
19
-
20
- const deviceCodePayload = {
21
- client_id: AUTH0_CLIENT_ID,
22
- audience: "https://api.embeddable.com/",
23
- };
24
-
25
- const deviceCodeResponse = await axios.post(
26
- `https://${AUTH0_DOMAIN}/oauth/device/code`,
27
- deviceCodePayload,
28
- );
29
-
30
- const tokenPayload = {
31
- grant_type: "urn:ietf:params:oauth:grant-type:device_code",
32
- device_code: deviceCodeResponse.data["device_code"],
33
- client_id: AUTH0_CLIENT_ID,
34
- };
35
-
36
- const authenticationSpinner = ora("waiting for code verification...").start();
37
-
38
- await open(deviceCodeResponse.data["verification_uri_complete"]);
39
-
40
- /**
41
- * This is a recommended way to poll, since it take some time for a user to enter a `user_code` in a browser.
42
- * deviceCodeResponse.data['interval'] is a recommended/calculated polling interval specified in seconds.
43
- */
44
- while (true) {
45
- try {
46
- const tokenResponse = await axios.post(
47
- `https://${AUTH0_DOMAIN}/oauth/token`,
48
- tokenPayload,
49
- );
50
- await fs.writeFile(CREDENTIALS_FILE, JSON.stringify(tokenResponse.data));
51
- authenticationSpinner.succeed("you are successfully authenticated now!");
52
- break;
53
- } catch (e) {
54
- if (e.response.data?.error !== "authorization_pending") {
55
- authenticationSpinner.fail("authentication failed. please try again.");
56
- process.exit(1);
57
- }
58
-
59
- await sleep(deviceCodeResponse.data["interval"] * 1000);
60
- }
61
- }
62
- }
63
-
64
- async function getToken() {
65
- try {
66
- const rawCredentials = await fs.readFile(CREDENTIALS_FILE, "utf-8");
67
- const credentials = JSON.parse(rawCredentials.toString());
68
-
69
- return credentials?.access_token ?? "";
70
- } catch (_e) {
71
- return "";
72
- }
73
- }
74
-
75
- module.exports = { login, getToken };
76
-
77
- function sleep(ms) {
78
- return new Promise((res) => setTimeout(res, ms));
79
- }
80
-
81
- async function resolveFiles() {
82
- try {
83
- await fs.access(CREDENTIALS_DIR);
84
- } catch (_e) {
85
- await fs.mkdir(CREDENTIALS_DIR);
86
- }
87
-
88
- try {
89
- await fs.access(CREDENTIALS_FILE);
90
- } catch (e) {
91
- await fs.writeFile(CREDENTIALS_FILE, "");
92
- }
93
- }
@@ -1,27 +0,0 @@
1
- const fsSync = require("fs");
2
- const fs = require("fs/promises");
3
-
4
- async function prepare(ctx) {
5
- await removeIfExists(ctx);
6
-
7
- await copyStencilConfigsToClient(ctx);
8
-
9
- await createComponentDir(ctx.client.componentDir);
10
- }
11
-
12
- module.exports = { prepare };
13
-
14
- async function removeIfExists(ctx) {
15
- if (ctx.pluginOptions) return;
16
-
17
- if (fsSync.existsSync(ctx.client.buildDir))
18
- await fs.rm(ctx.client.buildDir, { recursive: true });
19
- }
20
-
21
- async function copyStencilConfigsToClient(ctx) {
22
- await fs.cp(ctx.core.configsDir, ctx.client.buildDir, { recursive: true });
23
- }
24
-
25
- async function createComponentDir(dir) {
26
- await fs.mkdir(dir);
27
- }