ecomiq 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 +8 -151
- package/dist/platform.js +2 -2
- package/dist/tar.d.ts +4 -0
- package/dist/tar.js +86 -0
- package/dist/zip.d.ts +2 -0
- package/dist/zip.js +68 -0
- package/package.json +9 -1
package/dist/cli.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { platformFiles } from "./platform.js";
|
|
3
|
+
import { buildFiles, pack, projectFiles } from "./tar.js";
|
|
4
|
+
import { zip } from "./zip.js";
|
|
3
5
|
import { spawn } from "node:child_process";
|
|
4
6
|
import { createHash, randomBytes } from "node:crypto";
|
|
5
|
-
import { chmodSync, existsSync, mkdirSync, readFileSync, readdirSync,
|
|
6
|
-
import { basename, dirname, join,
|
|
7
|
+
import { chmodSync, existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
8
|
+
import { basename, dirname, join, resolve, sep } from "node:path";
|
|
7
9
|
import { createServer } from "node:http";
|
|
8
10
|
import { homedir } from "node:os";
|
|
9
|
-
import { crc32, deflateRawSync, gzipSync } from "node:zlib";
|
|
10
11
|
// ../ecomiq-core/package.json
|
|
11
12
|
var version$2 = "1.0.0";
|
|
12
|
-
// ../
|
|
13
|
-
var version$1 = "
|
|
13
|
+
// ../storefront/package.json
|
|
14
|
+
var version$1 = "3.0.0";
|
|
14
15
|
// package.json
|
|
15
|
-
var version = "0.
|
|
16
|
+
var version = "0.2.0";
|
|
16
17
|
// src/auth.ts
|
|
17
18
|
const CALLBACK = "/ecomiq/cli/callback";
|
|
18
19
|
const SCOPES = "openid profile email offline_access api_admin";
|
|
@@ -289,150 +290,6 @@ async function call(apiUrl, path, init = () => ({})) {
|
|
|
289
290
|
if (!response.ok) throw new Error(await problem(response));
|
|
290
291
|
return await response.json();
|
|
291
292
|
}
|
|
292
|
-
// src/tar.ts
|
|
293
|
-
const BLOCK = 512;
|
|
294
|
-
const SKIP = /* @__PURE__ */ new Set([
|
|
295
|
-
"node_modules",
|
|
296
|
-
"build",
|
|
297
|
-
"dist",
|
|
298
|
-
".react-router",
|
|
299
|
-
".wrangler",
|
|
300
|
-
".git",
|
|
301
|
-
".dev.vars",
|
|
302
|
-
".DS_Store"
|
|
303
|
-
]);
|
|
304
|
-
const ROOT_DOTFILES = /* @__PURE__ */ new Set([".gitignore"]);
|
|
305
|
-
function octal(value, length) {
|
|
306
|
-
return value.toString(8).padStart(length - 1, "0") + "\0";
|
|
307
|
-
}
|
|
308
|
-
function split(path) {
|
|
309
|
-
if (Buffer.byteLength(path) <= 100) return {
|
|
310
|
-
name: path,
|
|
311
|
-
prefix: ""
|
|
312
|
-
};
|
|
313
|
-
const cut = path.lastIndexOf("/", path.length - 1);
|
|
314
|
-
for (let index = cut; index > 0; index = path.lastIndexOf("/", index - 1)) {
|
|
315
|
-
const prefix = path.slice(0, index);
|
|
316
|
-
const name = path.slice(index + 1);
|
|
317
|
-
if (Buffer.byteLength(prefix) <= 155 && Buffer.byteLength(name) <= 100) return {
|
|
318
|
-
name,
|
|
319
|
-
prefix
|
|
320
|
-
};
|
|
321
|
-
}
|
|
322
|
-
throw new Error(`Ruta demasiado larga para empaquetar: ${path}`);
|
|
323
|
-
}
|
|
324
|
-
function header(path, size) {
|
|
325
|
-
const block = Buffer.alloc(BLOCK);
|
|
326
|
-
const { name, prefix } = split(path);
|
|
327
|
-
block.write(name, 0, 100, "utf8");
|
|
328
|
-
block.write(octal(420, 8), 100, 8, "ascii");
|
|
329
|
-
block.write(octal(0, 8), 108, 8, "ascii");
|
|
330
|
-
block.write(octal(0, 8), 116, 8, "ascii");
|
|
331
|
-
block.write(octal(size, 12), 124, 12, "ascii");
|
|
332
|
-
block.write(octal(0, 12), 136, 12, "ascii");
|
|
333
|
-
block.fill(" ", 148, 156);
|
|
334
|
-
block.write("0", 156, 1, "ascii");
|
|
335
|
-
block.write("ustar\0", 257, 6, "ascii");
|
|
336
|
-
block.write("00", 263, 2, "ascii");
|
|
337
|
-
block.write(prefix, 345, 155, "utf8");
|
|
338
|
-
let checksum = 0;
|
|
339
|
-
for (const byte of block) checksum += byte;
|
|
340
|
-
block.write(octal(checksum, 7) + " ", 148, 8, "ascii");
|
|
341
|
-
return block;
|
|
342
|
-
}
|
|
343
|
-
function walk(root, skipped) {
|
|
344
|
-
const found = [];
|
|
345
|
-
const visit = (directory) => {
|
|
346
|
-
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
|
347
|
-
const absolute = join(directory, entry.name);
|
|
348
|
-
const path = relative(root, absolute).split(sep).join("/");
|
|
349
|
-
if (entry.name.startsWith(".env") || skipped(path, entry.name)) continue;
|
|
350
|
-
if (entry.isDirectory()) visit(absolute);
|
|
351
|
-
else if (entry.isFile()) found.push(path);
|
|
352
|
-
}
|
|
353
|
-
};
|
|
354
|
-
visit(root);
|
|
355
|
-
return found.sort();
|
|
356
|
-
}
|
|
357
|
-
function projectFiles(root) {
|
|
358
|
-
return walk(root, (path, name) => SKIP.has(name) || path === name && name.startsWith(".") && !ROOT_DOTFILES.has(name));
|
|
359
|
-
}
|
|
360
|
-
function buildFiles(root) {
|
|
361
|
-
return walk(root, (_path, name) => name === ".dev.vars" || name === ".DS_Store" || name.endsWith(".map"));
|
|
362
|
-
}
|
|
363
|
-
function pack(root, paths) {
|
|
364
|
-
const chunks = [];
|
|
365
|
-
for (const path of paths) {
|
|
366
|
-
const content = readFileSync(join(root, path));
|
|
367
|
-
if (!statSync(join(root, path)).isFile()) continue;
|
|
368
|
-
chunks.push(header(path, content.length), content, Buffer.alloc((BLOCK - content.length % BLOCK) % BLOCK));
|
|
369
|
-
}
|
|
370
|
-
chunks.push(Buffer.alloc(BLOCK * 2));
|
|
371
|
-
return gzipSync(Buffer.concat(chunks), { level: 9 });
|
|
372
|
-
}
|
|
373
|
-
// src/zip.ts
|
|
374
|
-
function dosTime(date) {
|
|
375
|
-
const year = Math.max(1980, date.getFullYear());
|
|
376
|
-
return {
|
|
377
|
-
time: date.getHours() << 11 | date.getMinutes() << 5 | Math.floor(date.getSeconds() / 2),
|
|
378
|
-
day: year - 1980 << 9 | date.getMonth() + 1 << 5 | date.getDate()
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
|
-
function zip(root, paths, folder) {
|
|
382
|
-
const locals = [];
|
|
383
|
-
const centrals = [];
|
|
384
|
-
let offset = 0;
|
|
385
|
-
for (const path of paths) {
|
|
386
|
-
const content = readFileSync(join(root, path));
|
|
387
|
-
const deflated = deflateRawSync(content, { level: 9 });
|
|
388
|
-
const method = deflated.length < content.length ? 8 : 0;
|
|
389
|
-
const data = method === 8 ? deflated : content;
|
|
390
|
-
const name = Buffer.from(`${folder}/${path}`, "utf8");
|
|
391
|
-
const checksum = crc32(content);
|
|
392
|
-
const { time, day } = dosTime(statSync(join(root, path)).mtime);
|
|
393
|
-
const local = Buffer.alloc(30);
|
|
394
|
-
local.writeUInt32LE(67324752, 0);
|
|
395
|
-
local.writeUInt16LE(20, 4);
|
|
396
|
-
local.writeUInt16LE(2048, 6);
|
|
397
|
-
local.writeUInt16LE(method, 8);
|
|
398
|
-
local.writeUInt16LE(time, 10);
|
|
399
|
-
local.writeUInt16LE(day, 12);
|
|
400
|
-
local.writeUInt32LE(checksum, 14);
|
|
401
|
-
local.writeUInt32LE(data.length, 18);
|
|
402
|
-
local.writeUInt32LE(content.length, 22);
|
|
403
|
-
local.writeUInt16LE(name.length, 26);
|
|
404
|
-
const central = Buffer.alloc(46);
|
|
405
|
-
central.writeUInt32LE(33639248, 0);
|
|
406
|
-
central.writeUInt16LE(798, 4);
|
|
407
|
-
central.writeUInt16LE(20, 6);
|
|
408
|
-
central.writeUInt16LE(2048, 8);
|
|
409
|
-
central.writeUInt16LE(method, 10);
|
|
410
|
-
central.writeUInt16LE(time, 12);
|
|
411
|
-
central.writeUInt16LE(day, 14);
|
|
412
|
-
central.writeUInt32LE(checksum, 16);
|
|
413
|
-
central.writeUInt32LE(data.length, 20);
|
|
414
|
-
central.writeUInt32LE(content.length, 24);
|
|
415
|
-
central.writeUInt16LE(name.length, 28);
|
|
416
|
-
central.writeUInt32LE(33188 << 16 >>> 0, 38);
|
|
417
|
-
central.writeUInt32LE(offset, 42);
|
|
418
|
-
locals.push(local, name, data);
|
|
419
|
-
centrals.push(central, name);
|
|
420
|
-
offset += local.length + name.length + data.length;
|
|
421
|
-
if (offset > 4294967295) throw new Error("El tema es demasiado grande para comprimirlo.");
|
|
422
|
-
}
|
|
423
|
-
const directory = Buffer.concat(centrals);
|
|
424
|
-
const end = Buffer.alloc(22);
|
|
425
|
-
end.writeUInt32LE(101010256, 0);
|
|
426
|
-
end.writeUInt16LE(paths.length, 8);
|
|
427
|
-
end.writeUInt16LE(paths.length, 10);
|
|
428
|
-
end.writeUInt32LE(directory.length, 12);
|
|
429
|
-
end.writeUInt32LE(offset, 16);
|
|
430
|
-
return Buffer.concat([
|
|
431
|
-
...locals,
|
|
432
|
-
directory,
|
|
433
|
-
end
|
|
434
|
-
]);
|
|
435
|
-
}
|
|
436
293
|
// src/cli.ts
|
|
437
294
|
const HELP = `Uso: ecomiq <comando>
|
|
438
295
|
|
|
@@ -448,7 +305,7 @@ const HELP = `Uso: ecomiq <comando>
|
|
|
448
305
|
`;
|
|
449
306
|
const RELEASED = {
|
|
450
307
|
"@ecomiq/core": version$2,
|
|
451
|
-
"@ecomiq/
|
|
308
|
+
"@ecomiq/storefront": version$1,
|
|
452
309
|
ecomiq: version
|
|
453
310
|
};
|
|
454
311
|
function binary(name) {
|
package/dist/platform.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// src/platform.ts
|
|
3
|
-
const VITE_CONFIG = String.raw`import { publicAssets, catalogLinks, paymentLogos, sectionLoaders, themeUi } from "@ecomiq/
|
|
3
|
+
const VITE_CONFIG = String.raw`import { publicAssets, catalogLinks, paymentLogos, sectionLoaders, themeUi } from "@ecomiq/storefront/vite";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
import { cloudflare } from "@cloudflare/vite-plugin";
|
|
6
6
|
import { reactRouter } from "@react-router/dev/vite";
|
|
@@ -19,7 +19,7 @@ export default {
|
|
|
19
19
|
ssr: true,
|
|
20
20
|
} satisfies Config;
|
|
21
21
|
`;
|
|
22
|
-
const WORKER = `import { createRequestHandler } from "@ecomiq/
|
|
22
|
+
const WORKER = `import { createRequestHandler } from "@ecomiq/storefront";
|
|
23
23
|
|
|
24
24
|
export default createRequestHandler(() => import("virtual:react-router/server-build"), import.meta.env.MODE);
|
|
25
25
|
`;
|
package/dist/tar.d.ts
ADDED
package/dist/tar.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { readFileSync, readdirSync, statSync } from "node:fs";
|
|
3
|
+
import { join, relative, sep } from "node:path";
|
|
4
|
+
import { gzipSync } from "node:zlib";
|
|
5
|
+
// src/tar.ts
|
|
6
|
+
const BLOCK = 512;
|
|
7
|
+
const SKIP = /* @__PURE__ */ new Set([
|
|
8
|
+
"node_modules",
|
|
9
|
+
"build",
|
|
10
|
+
"dist",
|
|
11
|
+
".react-router",
|
|
12
|
+
".wrangler",
|
|
13
|
+
".git",
|
|
14
|
+
".dev.vars",
|
|
15
|
+
".DS_Store"
|
|
16
|
+
]);
|
|
17
|
+
const ROOT_DOTFILES = /* @__PURE__ */ new Set([".gitignore"]);
|
|
18
|
+
function octal(value, length) {
|
|
19
|
+
return value.toString(8).padStart(length - 1, "0") + "\0";
|
|
20
|
+
}
|
|
21
|
+
function split(path) {
|
|
22
|
+
if (Buffer.byteLength(path) <= 100) return {
|
|
23
|
+
name: path,
|
|
24
|
+
prefix: ""
|
|
25
|
+
};
|
|
26
|
+
const cut = path.lastIndexOf("/", path.length - 1);
|
|
27
|
+
for (let index = cut; index > 0; index = path.lastIndexOf("/", index - 1)) {
|
|
28
|
+
const prefix = path.slice(0, index);
|
|
29
|
+
const name = path.slice(index + 1);
|
|
30
|
+
if (Buffer.byteLength(prefix) <= 155 && Buffer.byteLength(name) <= 100) return {
|
|
31
|
+
name,
|
|
32
|
+
prefix
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
throw new Error(`Ruta demasiado larga para empaquetar: ${path}`);
|
|
36
|
+
}
|
|
37
|
+
function header(path, size) {
|
|
38
|
+
const block = Buffer.alloc(BLOCK);
|
|
39
|
+
const { name, prefix } = split(path);
|
|
40
|
+
block.write(name, 0, 100, "utf8");
|
|
41
|
+
block.write(octal(420, 8), 100, 8, "ascii");
|
|
42
|
+
block.write(octal(0, 8), 108, 8, "ascii");
|
|
43
|
+
block.write(octal(0, 8), 116, 8, "ascii");
|
|
44
|
+
block.write(octal(size, 12), 124, 12, "ascii");
|
|
45
|
+
block.write(octal(0, 12), 136, 12, "ascii");
|
|
46
|
+
block.fill(" ", 148, 156);
|
|
47
|
+
block.write("0", 156, 1, "ascii");
|
|
48
|
+
block.write("ustar\0", 257, 6, "ascii");
|
|
49
|
+
block.write("00", 263, 2, "ascii");
|
|
50
|
+
block.write(prefix, 345, 155, "utf8");
|
|
51
|
+
let checksum = 0;
|
|
52
|
+
for (const byte of block) checksum += byte;
|
|
53
|
+
block.write(octal(checksum, 7) + " ", 148, 8, "ascii");
|
|
54
|
+
return block;
|
|
55
|
+
}
|
|
56
|
+
function walk(root, skipped) {
|
|
57
|
+
const found = [];
|
|
58
|
+
const visit = (directory) => {
|
|
59
|
+
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
|
60
|
+
const absolute = join(directory, entry.name);
|
|
61
|
+
const path = relative(root, absolute).split(sep).join("/");
|
|
62
|
+
if (entry.name.startsWith(".env") || skipped(path, entry.name)) continue;
|
|
63
|
+
if (entry.isDirectory()) visit(absolute);
|
|
64
|
+
else if (entry.isFile()) found.push(path);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
visit(root);
|
|
68
|
+
return found.sort();
|
|
69
|
+
}
|
|
70
|
+
function projectFiles(root) {
|
|
71
|
+
return walk(root, (path, name) => SKIP.has(name) || path === name && name.startsWith(".") && !ROOT_DOTFILES.has(name));
|
|
72
|
+
}
|
|
73
|
+
function buildFiles(root) {
|
|
74
|
+
return walk(root, (_path, name) => name === ".dev.vars" || name === ".DS_Store" || name.endsWith(".map"));
|
|
75
|
+
}
|
|
76
|
+
function pack(root, paths) {
|
|
77
|
+
const chunks = [];
|
|
78
|
+
for (const path of paths) {
|
|
79
|
+
const content = readFileSync(join(root, path));
|
|
80
|
+
if (!statSync(join(root, path)).isFile()) continue;
|
|
81
|
+
chunks.push(header(path, content.length), content, Buffer.alloc((BLOCK - content.length % BLOCK) % BLOCK));
|
|
82
|
+
}
|
|
83
|
+
chunks.push(Buffer.alloc(BLOCK * 2));
|
|
84
|
+
return gzipSync(Buffer.concat(chunks), { level: 9 });
|
|
85
|
+
}
|
|
86
|
+
export { buildFiles, pack, projectFiles };
|
package/dist/zip.d.ts
ADDED
package/dist/zip.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { readFileSync, statSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { crc32, deflateRawSync } from "node:zlib";
|
|
5
|
+
// src/zip.ts
|
|
6
|
+
function dosTime(date) {
|
|
7
|
+
const year = Math.max(1980, date.getFullYear());
|
|
8
|
+
return {
|
|
9
|
+
time: date.getHours() << 11 | date.getMinutes() << 5 | Math.floor(date.getSeconds() / 2),
|
|
10
|
+
day: year - 1980 << 9 | date.getMonth() + 1 << 5 | date.getDate()
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function zip(root, paths, folder) {
|
|
14
|
+
const locals = [];
|
|
15
|
+
const centrals = [];
|
|
16
|
+
let offset = 0;
|
|
17
|
+
for (const path of paths) {
|
|
18
|
+
const content = readFileSync(join(root, path));
|
|
19
|
+
const deflated = deflateRawSync(content, { level: 9 });
|
|
20
|
+
const method = deflated.length < content.length ? 8 : 0;
|
|
21
|
+
const data = method === 8 ? deflated : content;
|
|
22
|
+
const name = Buffer.from(`${folder}/${path}`, "utf8");
|
|
23
|
+
const checksum = crc32(content);
|
|
24
|
+
const { time, day } = dosTime(statSync(join(root, path)).mtime);
|
|
25
|
+
const local = Buffer.alloc(30);
|
|
26
|
+
local.writeUInt32LE(67324752, 0);
|
|
27
|
+
local.writeUInt16LE(20, 4);
|
|
28
|
+
local.writeUInt16LE(2048, 6);
|
|
29
|
+
local.writeUInt16LE(method, 8);
|
|
30
|
+
local.writeUInt16LE(time, 10);
|
|
31
|
+
local.writeUInt16LE(day, 12);
|
|
32
|
+
local.writeUInt32LE(checksum, 14);
|
|
33
|
+
local.writeUInt32LE(data.length, 18);
|
|
34
|
+
local.writeUInt32LE(content.length, 22);
|
|
35
|
+
local.writeUInt16LE(name.length, 26);
|
|
36
|
+
const central = Buffer.alloc(46);
|
|
37
|
+
central.writeUInt32LE(33639248, 0);
|
|
38
|
+
central.writeUInt16LE(798, 4);
|
|
39
|
+
central.writeUInt16LE(20, 6);
|
|
40
|
+
central.writeUInt16LE(2048, 8);
|
|
41
|
+
central.writeUInt16LE(method, 10);
|
|
42
|
+
central.writeUInt16LE(time, 12);
|
|
43
|
+
central.writeUInt16LE(day, 14);
|
|
44
|
+
central.writeUInt32LE(checksum, 16);
|
|
45
|
+
central.writeUInt32LE(data.length, 20);
|
|
46
|
+
central.writeUInt32LE(content.length, 24);
|
|
47
|
+
central.writeUInt16LE(name.length, 28);
|
|
48
|
+
central.writeUInt32LE(33188 << 16 >>> 0, 38);
|
|
49
|
+
central.writeUInt32LE(offset, 42);
|
|
50
|
+
locals.push(local, name, data);
|
|
51
|
+
centrals.push(central, name);
|
|
52
|
+
offset += local.length + name.length + data.length;
|
|
53
|
+
if (offset > 4294967295) throw new Error("El tema es demasiado grande para comprimirlo.");
|
|
54
|
+
}
|
|
55
|
+
const directory = Buffer.concat(centrals);
|
|
56
|
+
const end = Buffer.alloc(22);
|
|
57
|
+
end.writeUInt32LE(101010256, 0);
|
|
58
|
+
end.writeUInt16LE(paths.length, 8);
|
|
59
|
+
end.writeUInt16LE(paths.length, 10);
|
|
60
|
+
end.writeUInt32LE(directory.length, 12);
|
|
61
|
+
end.writeUInt32LE(offset, 16);
|
|
62
|
+
return Buffer.concat([
|
|
63
|
+
...locals,
|
|
64
|
+
directory,
|
|
65
|
+
end
|
|
66
|
+
]);
|
|
67
|
+
}
|
|
68
|
+
export { zip };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ecomiq",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "CLI de Ecomiq para bajar, probar y publicar la tienda online",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,6 +19,14 @@
|
|
|
19
19
|
"types": "./dist/platform.d.ts",
|
|
20
20
|
"import": "./dist/platform.js"
|
|
21
21
|
},
|
|
22
|
+
"./tar": {
|
|
23
|
+
"types": "./dist/tar.d.ts",
|
|
24
|
+
"import": "./dist/tar.js"
|
|
25
|
+
},
|
|
26
|
+
"./zip": {
|
|
27
|
+
"types": "./dist/zip.d.ts",
|
|
28
|
+
"import": "./dist/zip.js"
|
|
29
|
+
},
|
|
22
30
|
"./package.json": "./package.json"
|
|
23
31
|
},
|
|
24
32
|
"files": [
|