@envodium/envodium-cli 0.1.0 → 0.2.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/dist/cli.js +5 -1
- package/dist/core.js +18 -0
- package/dist/http.js +29 -0
- package/package.json +3 -1
package/dist/cli.js
CHANGED
|
@@ -34,7 +34,11 @@ async function main() {
|
|
|
34
34
|
await (0, core_1.sync)({ cwd });
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
if (cmd === "init") {
|
|
38
|
+
await (0, core_1.init)({ cwd });
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
console.log("Usage: envodium build | test | sync | meta <input> | init");
|
|
38
42
|
}
|
|
39
43
|
catch (err) {
|
|
40
44
|
const e = err;
|
package/dist/core.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.build = build;
|
|
7
7
|
exports.meta = meta;
|
|
8
|
+
exports.init = init;
|
|
8
9
|
exports.sync = sync;
|
|
9
10
|
const path_1 = __importDefault(require("path"));
|
|
10
11
|
const url_1 = require("url");
|
|
@@ -13,6 +14,7 @@ const http_1 = require("./http");
|
|
|
13
14
|
const files_1 = require("./files");
|
|
14
15
|
const util_1 = require("./util");
|
|
15
16
|
const browser_1 = require("./browser");
|
|
17
|
+
const adm_zip_1 = __importDefault(require("adm-zip"));
|
|
16
18
|
async function build(opts) {
|
|
17
19
|
const { cwd, addTestParam, headless, noBrowser } = opts;
|
|
18
20
|
const cfg = await (0, config_1.readProjectConfig)(cwd);
|
|
@@ -166,6 +168,22 @@ function ensureExtension(name, fallbackExt = ".html") {
|
|
|
166
168
|
return name;
|
|
167
169
|
return name + (fallbackExt.startsWith(".") ? fallbackExt : "." + fallbackExt);
|
|
168
170
|
}
|
|
171
|
+
async function init(opts) {
|
|
172
|
+
const { cwd } = opts;
|
|
173
|
+
const zipUrl = "http://support.hr-appen.se/custom/cli/agents.zip";
|
|
174
|
+
console.log("Laddar ner agents.zip...");
|
|
175
|
+
const buffer = await (0, http_1.httpDownload)(zipUrl);
|
|
176
|
+
console.log("Packar upp...");
|
|
177
|
+
const zip = new adm_zip_1.default(buffer);
|
|
178
|
+
zip.extractAllTo(cwd, true);
|
|
179
|
+
const entries = zip.getEntries();
|
|
180
|
+
for (const entry of entries) {
|
|
181
|
+
if (!entry.isDirectory) {
|
|
182
|
+
console.log(` ${entry.entryName}`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
console.log(`\nInit klar – ${entries.filter(e => !e.isDirectory).length} filer extraherade.`);
|
|
186
|
+
}
|
|
169
187
|
async function sync(opts) {
|
|
170
188
|
const { cwd } = opts;
|
|
171
189
|
const cfg = await (0, config_1.readProjectConfig)(cwd);
|
package/dist/http.js
CHANGED
|
@@ -33,11 +33,40 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.httpDownload = httpDownload;
|
|
36
37
|
exports.httpSend = httpSend;
|
|
37
38
|
const http = __importStar(require("http"));
|
|
38
39
|
const https = __importStar(require("https"));
|
|
39
40
|
const dns = __importStar(require("dns"));
|
|
40
41
|
const url_1 = require("url");
|
|
42
|
+
function httpDownload(url) {
|
|
43
|
+
return new Promise((resolve, reject) => {
|
|
44
|
+
const parsed = new url_1.URL(url);
|
|
45
|
+
const lib = parsed.protocol === "https:" ? https : http;
|
|
46
|
+
const req = lib.get({
|
|
47
|
+
hostname: parsed.hostname,
|
|
48
|
+
port: parsed.port ? Number(parsed.port) : undefined,
|
|
49
|
+
path: parsed.pathname + parsed.search,
|
|
50
|
+
lookup: (hostname, options, callback) => {
|
|
51
|
+
dns.lookup(hostname, { ...options, family: 4 }, callback);
|
|
52
|
+
}
|
|
53
|
+
}, (res) => {
|
|
54
|
+
if (res.statusCode && res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
55
|
+
httpDownload(res.headers.location).then(resolve, reject);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (!res.statusCode || res.statusCode < 200 || res.statusCode >= 300) {
|
|
59
|
+
reject(new Error(`HTTP ${res.statusCode} vid nedladdning av ${url}`));
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const chunks = [];
|
|
63
|
+
res.on("data", (chunk) => chunks.push(chunk));
|
|
64
|
+
res.on("end", () => resolve(Buffer.concat(chunks)));
|
|
65
|
+
});
|
|
66
|
+
req.on("error", reject);
|
|
67
|
+
req.setTimeout(60000, () => req.destroy(new Error("Timeout (60s)")));
|
|
68
|
+
});
|
|
69
|
+
}
|
|
41
70
|
function httpSend(endpoint, method, headers, body) {
|
|
42
71
|
return new Promise((resolve, reject) => {
|
|
43
72
|
const url = new url_1.URL(endpoint);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@envodium/envodium-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "CLI for Envodium build, test, sync and meta commands",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"bin": {
|
|
@@ -22,10 +22,12 @@
|
|
|
22
22
|
],
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"devDependencies": {
|
|
25
|
+
"@types/adm-zip": "^0.5.7",
|
|
25
26
|
"@types/node": "^25.3.0",
|
|
26
27
|
"typescript": "^5.5.4"
|
|
27
28
|
},
|
|
28
29
|
"dependencies": {
|
|
30
|
+
"adm-zip": "^0.5.16",
|
|
29
31
|
"puppeteer": "^24.37.4"
|
|
30
32
|
}
|
|
31
33
|
}
|