@naseej/blox 0.1.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/bin/run ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+
3
+ require('../dist/run')
package/bin/run.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { cli } from '@/shared/command';
2
+
3
+ import { version } from '../package.json';
4
+ import { commands } from '../src';
5
+
6
+ cli.name('blox').version(version);
7
+
8
+ commands.forEach((cmd) => cli.addCommand(cmd));
9
+
10
+ cli.parse();
package/dist/run.js ADDED
@@ -0,0 +1,513 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+
25
+ // src/shared/command/index.ts
26
+ var import_extra_typings = require("@commander-js/extra-typings");
27
+ var import_extra_typings2 = require("@commander-js/extra-typings");
28
+ var command = (name) => new import_extra_typings.Command(name);
29
+ var option = (flags, description) => {
30
+ return new import_extra_typings.Option(flags, description);
31
+ };
32
+
33
+ // package.json
34
+ var version = "0.1.0";
35
+
36
+ // src/services/git.ts
37
+ var import_node_path = __toESM(require("path"));
38
+ var import_fs_extra = __toESM(require("fs-extra"));
39
+
40
+ // src/services/shell.ts
41
+ var import_node_child_process = require("child_process");
42
+ var $ = async (bin, options = [], { cwd, onStdout } = {}) => {
43
+ return new Promise(function(resolve, reject) {
44
+ const child = (0, import_node_child_process.spawn)(bin, options, { cwd, shell: true, stdio: ["pipe", "pipe", "pipe"] });
45
+ let error2 = "";
46
+ child.stdout.on("data", (data) => {
47
+ try {
48
+ onStdout && onStdout(data.toString());
49
+ } catch (e) {
50
+ reject(e);
51
+ }
52
+ });
53
+ child.stderr.on("data", (data) => {
54
+ error2 += data.toString();
55
+ });
56
+ child.on("close", function(code) {
57
+ if (code) {
58
+ reject(error2);
59
+ } else {
60
+ resolve(code);
61
+ }
62
+ });
63
+ child.on("error", function(err) {
64
+ reject(err);
65
+ });
66
+ });
67
+ };
68
+
69
+ // src/services/git.ts
70
+ var checkAuth = (message) => {
71
+ if (message.includes("Username for")) {
72
+ throw "Login to git first";
73
+ }
74
+ };
75
+ var defaultShellOptions = {
76
+ onStdout: checkAuth
77
+ };
78
+ var clone = (repoUrl, options, shellOptions = {}) => {
79
+ return $("git", ["clone", repoUrl, options], { ...defaultShellOptions, ...shellOptions });
80
+ };
81
+ var update = (shellOptions = {}) => {
82
+ return $("git", ["pull"], { ...defaultShellOptions, ...shellOptions });
83
+ };
84
+ var getLatestCommit = async (cwd) => {
85
+ let commit = "";
86
+ await $("git", ["rev-parse", "HEAD"], {
87
+ cwd,
88
+ onStdout: (text2) => {
89
+ commit = text2;
90
+ }
91
+ });
92
+ return commit.replace(/\n/g, "");
93
+ };
94
+ var patchFileName = "diff.patch";
95
+ var createPatch = async (cwd, fromCommit, toCommit) => {
96
+ return $("git", ["diff", fromCommit, toCommit, ">", patchFileName], { cwd });
97
+ };
98
+ var applyPatch = (patch, cwd = ".") => {
99
+ const args = ["apply", "-3"];
100
+ if (cwd != ".") {
101
+ args.push("--directory");
102
+ args.push(cwd);
103
+ }
104
+ args.push(patch);
105
+ return $("git", args);
106
+ };
107
+ var unInit = (cwd) => {
108
+ return import_fs_extra.default.remove(import_node_path.default.join(cwd, ".git"));
109
+ };
110
+ var init = async (cwd) => {
111
+ await $("git", ["init"], { cwd });
112
+ await $("git", ["branch", "-m", "main"], { cwd });
113
+ await $("git", ["add", "."], { cwd });
114
+ await $("git", ["commit", "-m", "init"], { cwd });
115
+ };
116
+ var git = {
117
+ clone,
118
+ update,
119
+ unInit,
120
+ init,
121
+ getLatestCommit,
122
+ createPatch,
123
+ applyPatch
124
+ };
125
+
126
+ // src/services/registry.ts
127
+ var import_node_path3 = __toESM(require("path"));
128
+ var import_dayjs = __toESM(require("dayjs"));
129
+ var import_fs_extra4 = __toESM(require("fs-extra"));
130
+ var import_klaw = __toESM(require("klaw"));
131
+ var import_ms = __toESM(require("ms"));
132
+
133
+ // src/services/fs.ts
134
+ var import_fs_extra2 = __toESM(require("fs-extra"));
135
+ var readJsonFile = (path7, defaultValue = {}) => {
136
+ try {
137
+ return import_fs_extra2.default.readJSONSync(path7);
138
+ } catch {
139
+ return defaultValue;
140
+ }
141
+ };
142
+
143
+ // src/shared/logger.ts
144
+ var import_prompts = require("@clack/prompts");
145
+
146
+ // src/shared/spinner.ts
147
+ var import_prompts2 = require("@clack/prompts");
148
+ var import_prompts3 = require("@clack/prompts");
149
+ async function runTask(name, task) {
150
+ const taskSpinner = (0, import_prompts2.spinner)();
151
+ taskSpinner.start(name);
152
+ try {
153
+ await (typeof task === "function" ? task() : task);
154
+ taskSpinner.stop(name);
155
+ } catch (e) {
156
+ taskSpinner.stop(`Failed: ${name}`, 1);
157
+ throw e;
158
+ }
159
+ }
160
+
161
+ // src/services/config.ts
162
+ var import_node_path2 = __toESM(require("path"));
163
+ var import_env_paths = __toESM(require("env-paths"));
164
+ var import_fs_extra3 = __toESM(require("fs-extra"));
165
+
166
+ // src/config/index.ts
167
+ var defaultConfig = {
168
+ syncFrequency: "1d",
169
+ registries: ["https://tfs.aas.com.sa/Medad/BLOX/_git/default-registry"]
170
+ };
171
+ var basedOnFile = ".blox";
172
+ var blocksDir = "blocks";
173
+
174
+ // src/services/config.ts
175
+ var appPaths = (0, import_env_paths.default)("blox", { suffix: "" });
176
+ var configFilePath = import_node_path2.default.join(appPaths.config, "config.json");
177
+ var getLocalConfig = () => {
178
+ try {
179
+ return import_fs_extra3.default.readJSONSync(configFilePath);
180
+ } catch {
181
+ return defaultConfig;
182
+ }
183
+ };
184
+ var updateLocalConfig = (config) => {
185
+ import_fs_extra3.default.ensureFileSync(configFilePath);
186
+ const current = getLocalConfig();
187
+ import_fs_extra3.default.writeJsonSync(configFilePath, { ...current, ...config });
188
+ };
189
+
190
+ // src/services/registry.ts
191
+ var registriesDataPath = import_node_path3.default.join(appPaths.data, "registries");
192
+ var registriesStatPath = import_node_path3.default.join(registriesDataPath, "stats.json");
193
+ var syncRegistries = async (logProgress = true) => {
194
+ import_fs_extra4.default.ensureDirSync(registriesDataPath);
195
+ const config = getLocalConfig();
196
+ const registriesStat = readJsonFile(registriesStatPath);
197
+ return Promise.all(
198
+ config.registries.map(async (registry) => {
199
+ const task = (0, import_prompts3.spinner)();
200
+ try {
201
+ const repoName = registry.split("/").pop() || "";
202
+ logProgress && task.start(`Updating registry: ${registry}`);
203
+ const repoDir = import_node_path3.default.join(registriesDataPath, repoName);
204
+ if (!registriesStat[repoName]) {
205
+ registriesStat[repoName] = {};
206
+ }
207
+ const now = (0, import_dayjs.default)();
208
+ const lastUpdated = registriesStat[repoName].lastUpdated;
209
+ const shouldUpdate = !lastUpdated || now.isAfter((0, import_dayjs.default)(lastUpdated).add((0, import_ms.default)(config.syncFrequency)));
210
+ if (!import_fs_extra4.default.existsSync(repoDir)) {
211
+ await git.clone(registry, "--depth 1", { cwd: registriesDataPath });
212
+ registriesStat[repoName].lastUpdated = now.format();
213
+ } else if (shouldUpdate) {
214
+ await git.update({ cwd: repoDir });
215
+ registriesStat[repoName].lastUpdated = now.format();
216
+ } else {
217
+ logProgress && import_prompts.log.step(`Have recent version`);
218
+ }
219
+ import_fs_extra4.default.writeJSONSync(registriesStatPath, registriesStat);
220
+ logProgress && task.stop(`Updated registry: ${registry}`);
221
+ } catch (e) {
222
+ task.stop(`Updating registry: ${registry} failed`, 1);
223
+ throw e;
224
+ }
225
+ })
226
+ );
227
+ };
228
+ var getAvailableTemplates = async () => {
229
+ const templates = {};
230
+ for await (const file of (0, import_klaw.default)(registriesDataPath, {
231
+ filter: (item) => !item.includes(".git")
232
+ })) {
233
+ if (file.path.endsWith(".json")) {
234
+ const data = import_fs_extra4.default.readJSONSync(file.path);
235
+ Object.keys(data.templates || {}).forEach((templ) => {
236
+ templates[templ] = {
237
+ ...data.templates[templ],
238
+ source: data.templates[templ]?.source || `${data.baseUrl}/template-${templ}`
239
+ };
240
+ Object.keys(templates[templ].blocks || {}).forEach((blockName) => {
241
+ const block = templates[templ]?.blocks?.[blockName];
242
+ if (block && !block.source) {
243
+ block.source = `${data.baseUrl}/block-${templ}-${blockName}`;
244
+ }
245
+ });
246
+ });
247
+ }
248
+ }
249
+ return templates;
250
+ };
251
+ var getAvailableBlocks = async (templateName) => {
252
+ const templates = await getAvailableTemplates();
253
+ const template = templates[templateName];
254
+ return template?.blocks || {};
255
+ };
256
+
257
+ // src/services/template.ts
258
+ var import_node_path4 = __toESM(require("path"));
259
+ var import_ejs = __toESM(require("ejs"));
260
+ var import_fs_extra5 = __toESM(require("fs-extra"));
261
+ var import_klaw2 = __toESM(require("klaw"));
262
+ async function replacePlaceholders(dir, context) {
263
+ for await (const file of (0, import_klaw2.default)(dir)) {
264
+ if (file.stats.isFile()) {
265
+ const template = import_fs_extra5.default.readFileSync(file.path, "utf-8");
266
+ const rendered = import_ejs.default.render(template, context);
267
+ import_fs_extra5.default.writeFileSync(file.path, rendered, "utf-8");
268
+ }
269
+ }
270
+ }
271
+ function getPackage(cwd) {
272
+ return import_fs_extra5.default.readJSONSync(import_node_path4.default.join(cwd, "package.json"));
273
+ }
274
+ function getTemplateInfo(cwd = ".") {
275
+ return getPackage(cwd).blox;
276
+ }
277
+ function getBasedOnInfo(cwd = ".") {
278
+ return import_fs_extra5.default.readJSONSync(import_node_path4.default.join(cwd, basedOnFile));
279
+ }
280
+ function saveBasedOnInfo(info, cwd = ".") {
281
+ import_fs_extra5.default.writeJSONSync(import_node_path4.default.join(cwd, basedOnFile), info);
282
+ }
283
+ function updateBasedOnInfo(updates, cwd = ".") {
284
+ const info = getBasedOnInfo(cwd);
285
+ saveBasedOnInfo({ ...info, ...updates }, cwd);
286
+ }
287
+ function getUsedBlocks() {
288
+ const blocks = [];
289
+ import_fs_extra5.default.readdirSync(blocksDir, { withFileTypes: true }).forEach((file) => {
290
+ if (!file.isDirectory()) {
291
+ return;
292
+ }
293
+ const templateInfo = getTemplateInfo(import_node_path4.default.join(blocksDir, file.name));
294
+ if (templateInfo) {
295
+ blocks.push(templateInfo);
296
+ }
297
+ });
298
+ return blocks;
299
+ }
300
+
301
+ // src/shared/prompts/index.ts
302
+ var import_prompts4 = require("@clack/prompts");
303
+
304
+ // src/shared/terminal/index.ts
305
+ var import_ansis = __toESM(require("ansis"));
306
+ var fmt = import_ansis.default;
307
+
308
+ // src/shared/prompts/index.ts
309
+ var checkIfCanceled = (value) => {
310
+ if ((0, import_prompts4.isCancel)(value)) {
311
+ (0, import_prompts4.cancel)();
312
+ process.exit(0);
313
+ }
314
+ };
315
+ var error = (error2, exit = true) => {
316
+ import_prompts4.log.error(
317
+ typeof error2 === "string" ? error2 : error2?.shortMessage || error2?.message || JSON.stringify(error2)
318
+ );
319
+ exit && process.exit(-1);
320
+ };
321
+ var select = async (opts) => {
322
+ const value = await (0, import_prompts4.select)(opts);
323
+ checkIfCanceled(value);
324
+ return value;
325
+ };
326
+ var text = async (opts) => {
327
+ const value = await (0, import_prompts4.text)(opts);
328
+ checkIfCanceled(value);
329
+ return value;
330
+ };
331
+ var textList = async (opts) => {
332
+ opts.message = `${opts.message} ${fmt.gray('(separated with ",")')}`;
333
+ const value = await (0, import_prompts4.text)(opts);
334
+ checkIfCanceled(value);
335
+ opts.validate?.(value);
336
+ return value.split(",");
337
+ };
338
+
339
+ // src/commands/add/index.ts
340
+ var add = command("add").description("Add block to app").alias("a").argument("[block]", "Block to be added").action(async (block) => {
341
+ await syncRegistries(false);
342
+ try {
343
+ const templateInfo = getTemplateInfo();
344
+ const blocks = await getAvailableBlocks(templateInfo.name);
345
+ if (!block) {
346
+ block = await select({
347
+ message: "Select template to be used",
348
+ options: Object.entries(blocks).map(([tmpl, { description }]) => ({
349
+ value: tmpl,
350
+ label: tmpl,
351
+ hint: description
352
+ }))
353
+ });
354
+ }
355
+ if (!blocks[block]) {
356
+ error("Selected block not available, try to sync registries");
357
+ }
358
+ const task = (0, import_prompts3.spinner)();
359
+ task.start(`Fetch block`);
360
+ const blockPath = `blocks/${block}`;
361
+ await git.clone(blocks[block]?.source || "", blockPath);
362
+ const commit = await git.getLatestCommit(blockPath);
363
+ await git.unInit(blockPath);
364
+ await replacePlaceholders(blockPath, {});
365
+ saveBasedOnInfo({ commit }, blockPath);
366
+ task.stop(`Block ${block} added`);
367
+ } catch (e) {
368
+ error(e);
369
+ }
370
+ });
371
+
372
+ // src/shared/validations/required.ts
373
+ var ensureRequired = (name) => (value) => {
374
+ if (value === void 0) {
375
+ error(`Option "${name}" is required`);
376
+ }
377
+ };
378
+
379
+ // src/commands/conf/index.ts
380
+ var conf = command("conf").description("Set blox global config").alias("c").option("-r, --registries <registries...>", "Remote registries urls").option("-f, --sync-frequency <duration>", "Remote registries sync frequency").action(async ({ registries, syncFrequency }) => {
381
+ if (!syncFrequency) {
382
+ syncFrequency = await text({
383
+ message: "Sync frequency",
384
+ placeholder: "(1m, 1h,1d,...etc)",
385
+ defaultValue: defaultConfig.syncFrequency
386
+ });
387
+ }
388
+ if (!registries?.length) {
389
+ registries = await textList({
390
+ message: "Registries urls",
391
+ validate: ensureRequired("registries")
392
+ });
393
+ }
394
+ try {
395
+ updateLocalConfig({ registries, syncFrequency });
396
+ import_prompts.log.success("local config updated successfully.");
397
+ } catch (e) {
398
+ error(e);
399
+ }
400
+ });
401
+
402
+ // src/commands/init/index.ts
403
+ var init2 = command("init").description("Init new app").alias("i").option("-n, --name <name>", "App name").option("-t, --template <template>", "Template to use").action(async ({ name, template }) => {
404
+ await syncRegistries(false);
405
+ try {
406
+ if (!name) {
407
+ name = await text({ message: "Select app name" });
408
+ }
409
+ const templates = await getAvailableTemplates();
410
+ if (!template) {
411
+ template = await select({
412
+ message: "Select template to be used",
413
+ options: Object.entries(templates).map(([tmpl, { description }]) => ({
414
+ value: tmpl,
415
+ label: tmpl,
416
+ hint: description
417
+ }))
418
+ });
419
+ }
420
+ if (!templates[template]) {
421
+ error("Selected template not available, try to sync registries");
422
+ }
423
+ const task = (0, import_prompts3.spinner)();
424
+ task.start(`Fetch template`);
425
+ await git.clone(templates[template]?.source || "", name);
426
+ const commit = await git.getLatestCommit(name);
427
+ await git.unInit(name);
428
+ await replacePlaceholders(name, { app: { name } });
429
+ saveBasedOnInfo({ commit }, name);
430
+ await git.init(name);
431
+ task.stop(`App initialized in ${name}`);
432
+ } catch (e) {
433
+ error(e);
434
+ }
435
+ });
436
+
437
+ // src/commands/sync/index.ts
438
+ var sync = command("sync").description("Sync local registry with remote updates").alias("s").action(async () => {
439
+ try {
440
+ await syncRegistries();
441
+ import_prompts.log.success("Local registries synced successfully.");
442
+ } catch (e) {
443
+ error(e);
444
+ }
445
+ });
446
+
447
+ // src/commands/update/index.ts
448
+ var import_node_path6 = __toESM(require("path"));
449
+
450
+ // src/services/updater.ts
451
+ var import_node_path5 = __toESM(require("path"));
452
+ var import_fs_extra6 = __toESM(require("fs-extra"));
453
+ async function updateFromRemote(name, source = "", destPath = ".") {
454
+ import_fs_extra6.default.ensureDirSync(appPaths.temp);
455
+ const tmpClone = import_node_path5.default.join(appPaths.temp, name);
456
+ await import_fs_extra6.default.remove(tmpClone);
457
+ await git.clone(source, name, { cwd: appPaths.temp });
458
+ const fromCommit = getBasedOnInfo(destPath).commit;
459
+ const toCommit = await git.getLatestCommit(tmpClone);
460
+ await git.createPatch(tmpClone, fromCommit, toCommit);
461
+ const patchFilePath = import_node_path5.default.join(destPath, patchFileName);
462
+ import_fs_extra6.default.moveSync(import_node_path5.default.join(tmpClone, patchFileName), patchFilePath);
463
+ try {
464
+ await git.applyPatch(patchFilePath, destPath);
465
+ } catch {
466
+ }
467
+ updateBasedOnInfo({ commit: toCommit }, destPath);
468
+ await import_fs_extra6.default.unlink(patchFilePath);
469
+ await import_fs_extra6.default.remove(tmpClone);
470
+ }
471
+
472
+ // src/commands/update/index.ts
473
+ var update2 = command("update").description("Update app/block").alias("u").addOption(
474
+ option("-s, --scope <scope>", "Scope of update").default("all").choices(["app", "block", "all"])
475
+ ).option("-b, --block <name>", "Block to update, valid only with scope block").option("-i, --interactive", "Select version in interactive mode").action(async (args) => {
476
+ const templateInfo = getTemplateInfo();
477
+ if (["all", "app"].includes(args.scope)) {
478
+ await runTask("update app", async () => {
479
+ const templates = await getAvailableTemplates();
480
+ const template = templates[templateInfo.name];
481
+ if (!template) {
482
+ error("Selected template not available, try to sync registries");
483
+ return;
484
+ }
485
+ await updateFromRemote(templateInfo.name, template.source);
486
+ });
487
+ }
488
+ if (args.scope === "all") {
489
+ const blocksInfo = await getAvailableBlocks(templateInfo.name);
490
+ for (const block of getUsedBlocks()) {
491
+ await runTask(`update block: ${block.name}`, async () => {
492
+ const blockInfo = blocksInfo[block.name];
493
+ if (!blockInfo) {
494
+ error("Selected block not available, try to sync registries", false);
495
+ return;
496
+ }
497
+ await updateFromRemote(
498
+ block.name,
499
+ blockInfo.source,
500
+ import_node_path6.default.join(blocksDir, block.name)
501
+ );
502
+ });
503
+ }
504
+ }
505
+ });
506
+
507
+ // src/commands/index.ts
508
+ var commands = [init2, add, update2, sync, conf];
509
+
510
+ // bin/run.ts
511
+ import_extra_typings2.program.name("blox").version(version);
512
+ commands.forEach((cmd) => import_extra_typings2.program.addCommand(cmd));
513
+ import_extra_typings2.program.parse();
package/package.json ADDED
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "@naseej/blox",
3
+ "version": "0.1.0",
4
+ "description": "blox cli",
5
+ "bin": {
6
+ "blox": "./bin/run"
7
+ },
8
+ "directories": {
9
+ "lib": "src",
10
+ "bin": "bin"
11
+ },
12
+ "files": [
13
+ "dist",
14
+ "bin"
15
+ ],
16
+ "scripts": {
17
+ "build": "tsup-node",
18
+ "build:watch": "tsup-node --watch",
19
+ "clean": "rm -rf dist",
20
+ "commitlint": "commitlint --edit",
21
+ "compile": "tsc",
22
+ "start": "tsx ./bin/run.ts",
23
+ "start:node": "node ./bin/run",
24
+ "test": "vitest run",
25
+ "test:watch": "vitest",
26
+ "lint": "eslint \"*/**/*.{js,ts,tsx}\" --quiet --fix",
27
+ "lint:fix": "eslint \"*/**/*.{js,ts,tsx}\" --fix",
28
+ "lint:stage": "yarn lint -- -c .eslintrc.staging.cjs",
29
+ "watch": "tsc --watch",
30
+ "type-check": "tsc --noEmit",
31
+ "prepare": "husky",
32
+ "postinstall": "patch-package"
33
+ },
34
+ "devDependencies": {
35
+ "@tsconfig/node20": "^20.1.4",
36
+ "@types/node": "^20.12.12",
37
+ "@types/prompts": "^2.4.9",
38
+ "@types/signale": "^1.4.7",
39
+ "@types/yargs": "^17.0.32",
40
+ "@types/klaw": "^3.0.6",
41
+ "@types/fs-extra": "11.0.4",
42
+ "@types/ms": "0.7.34",
43
+ "@types/ejs": "3.1.5",
44
+ "eslint": "^8.57.0",
45
+ "vitest": "2.1.8",
46
+ "prettier": "^3.2.5",
47
+ "tsx": "4.19.2",
48
+ "tsup": "^8.0.2",
49
+ "typescript": "^5.7.2",
50
+ "@typescript-eslint/eslint-plugin": "^8.17.0",
51
+ "@typescript-eslint/parser": "^8.17.0",
52
+ "eslint-config-prettier": "^8.10.0",
53
+ "eslint-import-resolver-typescript": "^3.6.1",
54
+ "eslint-plugin-import": "^2.29.1",
55
+ "eslint-plugin-prettier": "^5.1.3",
56
+ "eslint-plugin-react": "^7.34.1",
57
+ "eslint-plugin-unused-imports": "^3.2.0",
58
+ "cli-docs-generator": "^1.0.7",
59
+ "husky": "^9.1.7",
60
+ "patch-package": "^8.0.0"
61
+ },
62
+ "dependencies": {
63
+ "ansis": "3.3.2",
64
+ "@clack/prompts": "^0.8.2",
65
+ "fs-extra": "^11.2.0",
66
+ "klaw": "^4.1.0",
67
+ "ejs": "^3.1.10",
68
+ "env-paths": "^2.2.1",
69
+ "@commander-js/extra-typings": "12.1.0",
70
+ "commander": "12.1.0",
71
+ "ms": "2.1.3",
72
+ "dayjs": "1.11.13"
73
+ }
74
+ }
package/readme.md ADDED
@@ -0,0 +1,123 @@
1
+ #
2
+ ![logo](./assets/blox.png)
3
+
4
+ ### Introduction and Goals
5
+
6
+ BLOX is started kit built to speed Medad Product development by providing prebuild blocks of code that can be added with all its provided functionalities in one cli command.
7
+
8
+ ### Install
9
+ It can have many way to be installed, mainly as global npm package
10
+
11
+ ```shell
12
+ yarn global add @naseej/blox
13
+ ```
14
+
15
+ ### Usage
16
+
17
+ ```sh
18
+ blox --help
19
+ ```
20
+
21
+ ```
22
+ BLOX CLI
23
+
24
+ Commands:
25
+ blox init Init new app [alias: i]
26
+ blox add Add block to app [alias: a]
27
+ blox update Update app/block [alias: u]
28
+ blox sync Sync local registry with remote updates [alias: s]
29
+ blox conf Set blox global config [alias: c]
30
+
31
+ Options:
32
+ --version Show version number [boolean]
33
+ --help Show help [boolean]
34
+ ```
35
+
36
+ ### Available commands
37
+
38
+ * [init](#init)
39
+ * [add](#add)
40
+ * [update](#update)
41
+ * [sync](#sync)
42
+ * [conf](#conf)
43
+
44
+ #### init
45
+
46
+ ```sh
47
+ blox init --help
48
+ ```
49
+
50
+ ```
51
+ blox init
52
+
53
+ Init new app
54
+
55
+ Options:
56
+ -n, --name App name
57
+ -t, --template Template to use
58
+ ```
59
+
60
+ #### add
61
+
62
+ ```sh
63
+ blox add --help
64
+ ```
65
+
66
+ ```
67
+ blox add [block]
68
+
69
+ Add block to app
70
+
71
+ Params:
72
+ block Block name (Optional)
73
+ ```
74
+
75
+ #### update
76
+
77
+ ```sh
78
+ blox update --help
79
+ ```
80
+
81
+ ```
82
+ blox update
83
+
84
+ Update app/block
85
+
86
+ Options:
87
+ -i, --interactive Select version in interactive mode [boolean] [default: "false"]
88
+ -s, --scope Scope of update [choices: "app", "block", "all"] [default: "all"]
89
+ -b, --block Block to update, valid only with scope block
90
+ ```
91
+
92
+ * Note: you may need to resolve merge conflicts if found
93
+
94
+ #### sync
95
+
96
+ ```sh
97
+ blox sync --help
98
+ ```
99
+
100
+ ```
101
+ blox sync
102
+
103
+ Sync local registry with remote updates
104
+ ```
105
+
106
+ #### conf
107
+
108
+ ```sh
109
+ blox sync --help
110
+ ```
111
+
112
+ ```
113
+ blox conf
114
+
115
+ Set blox global config
116
+
117
+ Options:
118
+ -r, --registries Remote registries urls
119
+ ```
120
+
121
+ ### Docs
122
+
123
+ - [Design](./docs/design.md)