creatium 0.2.5 → 0.2.6
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/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.mjs +42 -42
- package/dist/shared/creatium.DU0m1vqH.mjs +6454 -0
- package/dist/utils.d.mts +13 -11
- package/dist/utils.d.ts +13 -11
- package/dist/utils.mjs +1 -1
- package/package.json +5 -5
- package/dist/shared/creatium.CDlxh6tN.mjs +0 -5912
package/dist/index.d.mts
CHANGED
|
@@ -4,8 +4,10 @@ import '@visulima/boxen';
|
|
|
4
4
|
import 'cli-table3';
|
|
5
5
|
import 'columnify';
|
|
6
6
|
import '@clack/prompts';
|
|
7
|
-
import '
|
|
7
|
+
import 'node:util';
|
|
8
|
+
import 'node:fs';
|
|
8
9
|
import 'node:fs/promises';
|
|
10
|
+
import 'node:path';
|
|
9
11
|
import 'tiny-glob';
|
|
10
12
|
import 'node:os';
|
|
11
13
|
import 'node:process';
|
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,10 @@ import '@visulima/boxen';
|
|
|
4
4
|
import 'cli-table3';
|
|
5
5
|
import 'columnify';
|
|
6
6
|
import '@clack/prompts';
|
|
7
|
-
import '
|
|
7
|
+
import 'node:util';
|
|
8
|
+
import 'node:fs';
|
|
8
9
|
import 'node:fs/promises';
|
|
10
|
+
import 'node:path';
|
|
9
11
|
import 'tiny-glob';
|
|
10
12
|
import 'node:os';
|
|
11
13
|
import 'node:process';
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { formatter } from '@clippium/preset-colored';
|
|
2
2
|
import { hideBin, Clippium } from 'clippium';
|
|
3
3
|
import { Updater } from '@clippium/updater';
|
|
4
|
-
import {
|
|
4
|
+
import { S as Sr, j as jr, z as zr, V as Vr, G as Gr, _ as _r, I as Ir, a2 as Sn, i as xn, ae as Hn, T as Tr, H as Hr, D as Dn, ab as Ln, ag as Vn, ac as Pn, W as Wr, a4 as Tn } from './shared/creatium.DU0m1vqH.mjs';
|
|
5
5
|
import 'module';
|
|
6
6
|
|
|
7
7
|
const updater = async (name, version) => {
|
|
@@ -11,7 +11,7 @@ const updater = async (name, version) => {
|
|
|
11
11
|
gray,
|
|
12
12
|
green,
|
|
13
13
|
italic
|
|
14
|
-
} =
|
|
14
|
+
} = Sr;
|
|
15
15
|
const _updater = new Updater({
|
|
16
16
|
version,
|
|
17
17
|
name
|
|
@@ -329,7 +329,7 @@ const name = "creatium";
|
|
|
329
329
|
|
|
330
330
|
const SELECT_BASE_OPTS = { NONE: "none" };
|
|
331
331
|
const mergeSelectBaseOptions = (config, defaultOptions) => {
|
|
332
|
-
const options =
|
|
332
|
+
const options = jr(defaultOptions || {}, config.options || {});
|
|
333
333
|
const filteredOptions = config.onlyOptions && config.onlyOptions.length > 1 ? Object.entries(options).reduce((acc, [key, value]) => {
|
|
334
334
|
if (key === SELECT_BASE_OPTS.NONE || config.onlyOptions.includes(key))
|
|
335
335
|
acc[key] = value;
|
|
@@ -367,7 +367,7 @@ class Editor extends Select {
|
|
|
367
367
|
async validateInitialValue(data) {
|
|
368
368
|
const validateValue = await super.validateInitialValue({ showSuccess: false });
|
|
369
369
|
if (!validateValue) return void 0;
|
|
370
|
-
if (validateValue && await
|
|
370
|
+
if (validateValue && await zr(validateValue)) {
|
|
371
371
|
if (data?.showSuccess !== false)
|
|
372
372
|
this._utils.prompt.log.success(this._text.initialValueSuccess(this.config.promptMsg || this.config.desc, validateValue));
|
|
373
373
|
return validateValue;
|
|
@@ -379,7 +379,7 @@ class Editor extends Select {
|
|
|
379
379
|
async prompt() {
|
|
380
380
|
let value = await super.prompt();
|
|
381
381
|
if (value === TEXT_EDITOR.NONE) return value;
|
|
382
|
-
const exists = await
|
|
382
|
+
const exists = await zr(value);
|
|
383
383
|
if (!exists) {
|
|
384
384
|
this.config.options = Object.fromEntries(
|
|
385
385
|
Object.entries(this.config.options).filter(([key]) => key !== value)
|
|
@@ -421,7 +421,7 @@ class Install extends Select {
|
|
|
421
421
|
async validateInitialValue(data) {
|
|
422
422
|
const validateValue = await super.validateInitialValue({ showSuccess: false });
|
|
423
423
|
if (!validateValue) return void 0;
|
|
424
|
-
const exists = await
|
|
424
|
+
const exists = await zr(validateValue);
|
|
425
425
|
if (validateValue && exists) {
|
|
426
426
|
if (data?.showSuccess !== false)
|
|
427
427
|
this._utils.prompt.log.success(this._text.initialValueSuccess(this.config.promptMsg || this.config.desc, validateValue));
|
|
@@ -434,7 +434,7 @@ class Install extends Select {
|
|
|
434
434
|
async prompt() {
|
|
435
435
|
let value = await super.prompt();
|
|
436
436
|
if (value === INSTALLER.NONE) return value;
|
|
437
|
-
const exists = await
|
|
437
|
+
const exists = await zr(value);
|
|
438
438
|
if (!exists) {
|
|
439
439
|
this.config.options = Object.fromEntries(
|
|
440
440
|
Object.entries(this.config.options).filter(([key]) => key !== value)
|
|
@@ -512,7 +512,7 @@ class Path extends Text {
|
|
|
512
512
|
async #validatePath(path) {
|
|
513
513
|
const mustExists = this.#existsPath;
|
|
514
514
|
const type = this.#pathType;
|
|
515
|
-
const existsPath = type === PATH_TYPE.file ? await
|
|
515
|
+
const existsPath = type === PATH_TYPE.file ? await Vr(path) : await Gr(path);
|
|
516
516
|
const validation = mustExists === existsPath;
|
|
517
517
|
console.debug({ pathValueData: {
|
|
518
518
|
validatePath: path,
|
|
@@ -645,7 +645,7 @@ class Options {
|
|
|
645
645
|
}, {});
|
|
646
646
|
};
|
|
647
647
|
if (!this.cache) return;
|
|
648
|
-
return await
|
|
648
|
+
return await _r({
|
|
649
649
|
projectName: this.projectName,
|
|
650
650
|
id: "create-prompts",
|
|
651
651
|
values: resetObjectValues(this.config)
|
|
@@ -740,9 +740,9 @@ const OPTION = {
|
|
|
740
740
|
};
|
|
741
741
|
|
|
742
742
|
const utils = {
|
|
743
|
-
color:
|
|
744
|
-
line:
|
|
745
|
-
prompt:
|
|
743
|
+
color: Sr,
|
|
744
|
+
line: xn,
|
|
745
|
+
prompt: Sn
|
|
746
746
|
};
|
|
747
747
|
class CreatiumCore {
|
|
748
748
|
#core;
|
|
@@ -750,7 +750,7 @@ class CreatiumCore {
|
|
|
750
750
|
utils;
|
|
751
751
|
config;
|
|
752
752
|
#style;
|
|
753
|
-
#cwd =
|
|
753
|
+
#cwd = Ir.cwd();
|
|
754
754
|
constructor(config) {
|
|
755
755
|
this.#core = new Options(config.prompt, utils);
|
|
756
756
|
this.config = config;
|
|
@@ -793,12 +793,12 @@ class CreatiumCore {
|
|
|
793
793
|
console.debug({ afterPromptData: this.#data });
|
|
794
794
|
return answers;
|
|
795
795
|
} catch (err) {
|
|
796
|
-
if (err instanceof Error) throw new Error(
|
|
796
|
+
if (err instanceof Error) throw new Error(Hn(err.message, 200, "..."));
|
|
797
797
|
throw new Error("Unexpected error in execution");
|
|
798
798
|
}
|
|
799
799
|
}
|
|
800
800
|
#getCliArgs(props) {
|
|
801
|
-
return props?.args && props.hideBin ? hideBin(props.args) ? props.args : props?.args : hideBin(
|
|
801
|
+
return props?.args && props.hideBin ? hideBin(props.args) ? props.args : props?.args : hideBin(Ir.argv);
|
|
802
802
|
}
|
|
803
803
|
async #initCli(props) {
|
|
804
804
|
if (this.config.updater) await this.updateNotify();
|
|
@@ -827,27 +827,27 @@ class CreatiumCore {
|
|
|
827
827
|
}
|
|
828
828
|
}
|
|
829
829
|
}, { help: { formatter: formatter({
|
|
830
|
-
title: (v) =>
|
|
831
|
-
bin:
|
|
832
|
-
version: (v) =>
|
|
833
|
-
name:
|
|
834
|
-
positionals: (v) =>
|
|
835
|
-
commands:
|
|
836
|
-
flags:
|
|
837
|
-
desc: (v) =>
|
|
838
|
-
examples:
|
|
839
|
-
sectionTitle: (v) =>
|
|
830
|
+
title: (v) => Sr.cyan(Sr.inverse(Sr.bold(v))),
|
|
831
|
+
bin: Sr.cyan,
|
|
832
|
+
version: (v) => Sr.cyan(Sr.dim(Sr.italic(v))),
|
|
833
|
+
name: Sr.bold,
|
|
834
|
+
positionals: (v) => Sr.green(Sr.dim(v)),
|
|
835
|
+
commands: Sr.green,
|
|
836
|
+
flags: Sr.yellow,
|
|
837
|
+
desc: (v) => Sr.white(Sr.dim(v)),
|
|
838
|
+
examples: Sr.cyan,
|
|
839
|
+
sectionTitle: (v) => Sr.white(Sr.bold(Sr.underline(v))),
|
|
840
840
|
//color.white.bold.underline,
|
|
841
|
-
sectionDesc: (v) =>
|
|
842
|
-
sectionsProps: (v) =>
|
|
841
|
+
sectionDesc: (v) => Sr.white(Sr.dim(v)),
|
|
842
|
+
sectionsProps: (v) => Sr.white(Sr.dim(Sr.italic(v)))
|
|
843
843
|
}) } });
|
|
844
844
|
const { flags } = await cli.parse(args);
|
|
845
845
|
if (flags.help) {
|
|
846
846
|
console.log(cli.getHelp(args));
|
|
847
|
-
|
|
847
|
+
Ir.exit(0);
|
|
848
848
|
} else if (flags.version) {
|
|
849
849
|
console.log(cli.getVersion());
|
|
850
|
-
|
|
850
|
+
Ir.exit(0);
|
|
851
851
|
}
|
|
852
852
|
if (!flags.debug) this.debugMode = false;
|
|
853
853
|
else this.debugMode = true;
|
|
@@ -877,13 +877,13 @@ class CreatiumCore {
|
|
|
877
877
|
if (message) {
|
|
878
878
|
this.utils.prompt.log.step("");
|
|
879
879
|
this.utils.prompt.cancel(message);
|
|
880
|
-
|
|
880
|
+
Ir.exit(0);
|
|
881
881
|
} else if (this.config.onCancel && this.#data)
|
|
882
882
|
await this.config.onCancel(this.#data);
|
|
883
883
|
else if (this.config.onCancel === void 0) {
|
|
884
884
|
this.utils.prompt.log.step("");
|
|
885
885
|
this.utils.prompt.cancel("Canceled \u{1F494}");
|
|
886
|
-
|
|
886
|
+
Ir.exit(0);
|
|
887
887
|
}
|
|
888
888
|
}
|
|
889
889
|
/**
|
|
@@ -953,7 +953,7 @@ class CreatiumCore {
|
|
|
953
953
|
*/
|
|
954
954
|
async copyDir(data) {
|
|
955
955
|
console.debug({ copyDirData: data });
|
|
956
|
-
return await
|
|
956
|
+
return await Tr(data);
|
|
957
957
|
}
|
|
958
958
|
/**
|
|
959
959
|
* Installs the project with the given package manager.
|
|
@@ -987,7 +987,7 @@ class CreatiumCore {
|
|
|
987
987
|
};
|
|
988
988
|
try {
|
|
989
989
|
s.start(`Installing with ${installer}`);
|
|
990
|
-
await
|
|
990
|
+
await Hr(command[installer]);
|
|
991
991
|
s.stop(`${this.#style.tick} Package installed with [${installer}] successfully`);
|
|
992
992
|
} catch (_e) {
|
|
993
993
|
if (this.debugMode)
|
|
@@ -1022,7 +1022,7 @@ class CreatiumCore {
|
|
|
1022
1022
|
const s = this.utils.prompt.spinner();
|
|
1023
1023
|
try {
|
|
1024
1024
|
s.start(`Opening in ${editor}`);
|
|
1025
|
-
await
|
|
1025
|
+
await Hr(`${editor} ${input}`);
|
|
1026
1026
|
s.stop(`${this.#style.tick} Text editor [${editor}] opened successfully`);
|
|
1027
1027
|
} catch (_e) {
|
|
1028
1028
|
if (this.debugMode)
|
|
@@ -1061,13 +1061,13 @@ class CreatiumCore {
|
|
|
1061
1061
|
if (!params) return;
|
|
1062
1062
|
const getContent = async (filePath) => {
|
|
1063
1063
|
try {
|
|
1064
|
-
const content = await
|
|
1064
|
+
const content = await Tn(filePath, "utf-8");
|
|
1065
1065
|
return typeof content === "string" && content.trim().length > 0 ? content : void 0;
|
|
1066
1066
|
} catch (_e) {
|
|
1067
1067
|
return void 0;
|
|
1068
1068
|
}
|
|
1069
1069
|
};
|
|
1070
|
-
const paths = await
|
|
1070
|
+
const paths = await Dn("**", {
|
|
1071
1071
|
filesOnly: true,
|
|
1072
1072
|
cwd: input,
|
|
1073
1073
|
absolute: true,
|
|
@@ -1081,11 +1081,11 @@ class CreatiumCore {
|
|
|
1081
1081
|
await Promise.all(paths.map(async (path) => {
|
|
1082
1082
|
const content = await getContent(path);
|
|
1083
1083
|
if (!content) return;
|
|
1084
|
-
const res = await
|
|
1084
|
+
const res = await Ln({
|
|
1085
1085
|
content,
|
|
1086
1086
|
params
|
|
1087
1087
|
});
|
|
1088
|
-
await
|
|
1088
|
+
await Vn(path, res, "utf-8");
|
|
1089
1089
|
}));
|
|
1090
1090
|
}
|
|
1091
1091
|
/**
|
|
@@ -1112,7 +1112,7 @@ class CreatiumCore {
|
|
|
1112
1112
|
templates
|
|
1113
1113
|
} });
|
|
1114
1114
|
if (input && templates[input].input) return templates[input].input;
|
|
1115
|
-
if (input && await
|
|
1115
|
+
if (input && await Gr(input)) return input;
|
|
1116
1116
|
this.utils.prompt.log.error(`Error creating Template: template input "${input}" not found`);
|
|
1117
1117
|
return;
|
|
1118
1118
|
}
|
|
@@ -1149,7 +1149,7 @@ class CreatiumCore {
|
|
|
1149
1149
|
} = values;
|
|
1150
1150
|
const data = {
|
|
1151
1151
|
input: await this.getTemplateInput({ input }),
|
|
1152
|
-
output: output ?
|
|
1152
|
+
output: output ? Pn(output) : void 0
|
|
1153
1153
|
};
|
|
1154
1154
|
console.debug({ createTemplate: {
|
|
1155
1155
|
values,
|
|
@@ -1183,7 +1183,7 @@ class CreatiumCore {
|
|
|
1183
1183
|
} catch (e) {
|
|
1184
1184
|
const error = e instanceof Error ? e.message : e?.toString();
|
|
1185
1185
|
this.utils.prompt.log.error(`Unexpected error creating template:
|
|
1186
|
-
${
|
|
1186
|
+
${Hn(error || "", 100, "...")}
|
|
1187
1187
|
|
|
1188
1188
|
`);
|
|
1189
1189
|
await this.#core.onCancel();
|
|
@@ -1198,7 +1198,7 @@ ${Hi(error || "", 100, "...")}
|
|
|
1198
1198
|
*/
|
|
1199
1199
|
async build(values, opts) {
|
|
1200
1200
|
const cliValues = opts?.activeCli !== false ? await this.#initCli(opts) : {};
|
|
1201
|
-
const config = values ?
|
|
1201
|
+
const config = values ? Wr({})(values, cliValues) : cliValues;
|
|
1202
1202
|
return await this.#exec(config);
|
|
1203
1203
|
}
|
|
1204
1204
|
/**
|