create-dokio 0.1.7 → 0.1.9
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.js +293 -65
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
-
import
|
|
4
|
+
import prompts3 from "prompts";
|
|
5
|
+
import kleur6 from "kleur";
|
|
6
|
+
|
|
7
|
+
// src/template.ts
|
|
8
|
+
import { join as join3 } from "path";
|
|
9
|
+
import fse3 from "fs-extra";
|
|
10
|
+
import kleur4 from "kleur";
|
|
5
11
|
|
|
6
12
|
// src/prompts.ts
|
|
7
13
|
import prompts from "prompts";
|
|
@@ -21,6 +27,46 @@ function buildPages(pageCount) {
|
|
|
21
27
|
return Array.from({ length: pageCount }, (_, i) => getPageName(i, pageCount));
|
|
22
28
|
}
|
|
23
29
|
|
|
30
|
+
// src/hubs.ts
|
|
31
|
+
var HUBS = [
|
|
32
|
+
{ id: "meridianenergy", title: "Meridian Energy Hub" },
|
|
33
|
+
{ id: "aexp", title: "Amex Global" },
|
|
34
|
+
{ id: "ipa", title: "IPA LAM Hub" },
|
|
35
|
+
{ id: "bupa-sam", title: "Bupa Sales And Marketing Hub" },
|
|
36
|
+
{ id: "gwm", title: "GWM Advertising Studio" },
|
|
37
|
+
{ id: "knowledgebase", title: "KB Hub" },
|
|
38
|
+
{ id: "vidacorp", title: "VidaDesign Hub" },
|
|
39
|
+
{ id: "mi", title: "Measurable Impact" },
|
|
40
|
+
{ id: "bupa-hs", title: "Bupa Health Services" },
|
|
41
|
+
{ id: "originloopvpp-partnerships-hub", title: "Origin Loop VPP Partnerships Hub" },
|
|
42
|
+
{ id: "amazon-devices", title: "Amazon Devices" },
|
|
43
|
+
{ id: "belmond", title: "Belmond" },
|
|
44
|
+
{ id: "origin", title: "Origin" },
|
|
45
|
+
{ id: "shell-au", title: "Shell Australia Brand Templates" },
|
|
46
|
+
{ id: "nissan", title: "Nissan" },
|
|
47
|
+
{ id: "bupa-agedcare", title: "Bupa Aged Care" },
|
|
48
|
+
{ id: "australian-unity", title: "Australian Unity" },
|
|
49
|
+
{ id: "poolwerx", title: "Poolwerx Loop" },
|
|
50
|
+
{ id: "scimmer", title: "Scimmer" },
|
|
51
|
+
{ id: "sandbox", title: "Sandbox" },
|
|
52
|
+
{ id: "bupa-healthy-cities", title: "Bupa Healthy Cities" },
|
|
53
|
+
{ id: "eabrandhub", title: "EnergyAustralia's Brand Hub" },
|
|
54
|
+
{ id: "origin-fugu", title: "Origin Fugu" },
|
|
55
|
+
{ id: "fridas", title: "Frida's Luxe Sip n' Paint" },
|
|
56
|
+
{ id: "headspace", title: "Headspace" },
|
|
57
|
+
{ id: "iris-samsung", title: "Iris | Samsung" },
|
|
58
|
+
{ id: "bupa-marketing", title: "Bupa Marketing" },
|
|
59
|
+
{ id: "bupa-retail", title: "Bupa Retail" },
|
|
60
|
+
{ id: "designsystem", title: "Design System" },
|
|
61
|
+
{ id: "hellofresh", title: "HelloFresh" }
|
|
62
|
+
];
|
|
63
|
+
function hubRepoUrl(hubId) {
|
|
64
|
+
return `https://github.com/dokioco/${hubId}-templates`;
|
|
65
|
+
}
|
|
66
|
+
function hubRepoDirName(hubId) {
|
|
67
|
+
return `${hubId}-templates`;
|
|
68
|
+
}
|
|
69
|
+
|
|
24
70
|
// src/prompts.ts
|
|
25
71
|
var onCancel = () => {
|
|
26
72
|
console.log(kleur.yellow("\n Cancelled.\n"));
|
|
@@ -29,12 +75,18 @@ var onCancel = () => {
|
|
|
29
75
|
async function runPrompts(nameArg) {
|
|
30
76
|
const base = await prompts(
|
|
31
77
|
[
|
|
78
|
+
{
|
|
79
|
+
type: "text",
|
|
80
|
+
name: "templateId",
|
|
81
|
+
message: "Template ID (e.g. HW485)",
|
|
82
|
+
validate: (v) => /^[A-Za-z0-9]+$/.test(v.trim()) || "Alphanumeric only"
|
|
83
|
+
},
|
|
32
84
|
{
|
|
33
85
|
type: nameArg ? null : "text",
|
|
34
86
|
name: "name",
|
|
35
|
-
message:
|
|
36
|
-
initial: "
|
|
37
|
-
validate: (v) =>
|
|
87
|
+
message: "Template name (e.g. My Cool Template)",
|
|
88
|
+
initial: "My Template",
|
|
89
|
+
validate: (v) => v.trim().length > 0 || "Required"
|
|
38
90
|
},
|
|
39
91
|
{
|
|
40
92
|
type: "select",
|
|
@@ -48,17 +100,19 @@ async function runPrompts(nameArg) {
|
|
|
48
100
|
]
|
|
49
101
|
},
|
|
50
102
|
{
|
|
51
|
-
type: "
|
|
52
|
-
name: "
|
|
53
|
-
message: "
|
|
54
|
-
|
|
103
|
+
type: "select",
|
|
104
|
+
name: "hubId",
|
|
105
|
+
message: "Hub",
|
|
106
|
+
choices: HUBS.map((h) => ({ title: h.title, value: h.id }))
|
|
55
107
|
}
|
|
56
108
|
],
|
|
57
109
|
{ onCancel }
|
|
58
110
|
);
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
const
|
|
111
|
+
const templateId = base.templateId.trim();
|
|
112
|
+
const name = nameArg ? nameArg.trim() : base.name.trim();
|
|
113
|
+
const fullName = `${templateId}-${toKebab(name)}`;
|
|
114
|
+
const hubId = base.hubId;
|
|
115
|
+
const subdomain = hubId;
|
|
62
116
|
if (base.mode === "pdf") {
|
|
63
117
|
const pdf = await prompts(
|
|
64
118
|
[
|
|
@@ -103,9 +157,11 @@ async function runPrompts(nameArg) {
|
|
|
103
157
|
);
|
|
104
158
|
return {
|
|
105
159
|
mode: "pdf",
|
|
160
|
+
templateId,
|
|
106
161
|
name,
|
|
107
162
|
fullName,
|
|
108
163
|
subdomain,
|
|
164
|
+
hubId,
|
|
109
165
|
width: pdf.width,
|
|
110
166
|
height: pdf.height,
|
|
111
167
|
pageCount: pdf.pageCount,
|
|
@@ -142,9 +198,11 @@ async function runPrompts(nameArg) {
|
|
|
142
198
|
);
|
|
143
199
|
return {
|
|
144
200
|
mode: "general",
|
|
201
|
+
templateId,
|
|
145
202
|
name,
|
|
146
203
|
fullName,
|
|
147
204
|
subdomain,
|
|
205
|
+
hubId,
|
|
148
206
|
width: gen.width,
|
|
149
207
|
height: gen.height,
|
|
150
208
|
pageCount: gen.pageCount,
|
|
@@ -152,16 +210,11 @@ async function runPrompts(nameArg) {
|
|
|
152
210
|
};
|
|
153
211
|
}
|
|
154
212
|
if (base.mode === "video") {
|
|
155
|
-
return { mode: "video", name, fullName, subdomain };
|
|
213
|
+
return { mode: "video", templateId, name, fullName, subdomain, hubId };
|
|
156
214
|
}
|
|
157
|
-
return { mode: "email", name, fullName, subdomain };
|
|
215
|
+
return { mode: "email", templateId, name, fullName, subdomain, hubId };
|
|
158
216
|
}
|
|
159
217
|
|
|
160
|
-
// src/scaffold.ts
|
|
161
|
-
import { join } from "path";
|
|
162
|
-
import fse from "fs-extra";
|
|
163
|
-
import kleur2 from "kleur";
|
|
164
|
-
|
|
165
218
|
// src/templates/shared.ts
|
|
166
219
|
function changelog(fullName) {
|
|
167
220
|
return `# Changelog
|
|
@@ -216,6 +269,29 @@ function fontsScssEmpty() {
|
|
|
216
269
|
// }
|
|
217
270
|
`;
|
|
218
271
|
}
|
|
272
|
+
function commitMsgHook() {
|
|
273
|
+
return `#!/usr/bin/env sh
|
|
274
|
+
|
|
275
|
+
commit_msg=$(cat "$1")
|
|
276
|
+
first_line=$(printf '%s' "$commit_msg" | head -n 1)
|
|
277
|
+
pattern='^(feat|fix|chore|docs|style|refactor|test|perf|ci|build|revert)(\\(.+\\))?: .+'
|
|
278
|
+
|
|
279
|
+
if ! printf '%s' "$first_line" | grep -qE "$pattern"; then
|
|
280
|
+
printf '\\n \u2717 Invalid commit message.\\n\\n'
|
|
281
|
+
printf ' Must follow Conventional Commits:\\n\\n'
|
|
282
|
+
printf ' feat: add new feature\\n'
|
|
283
|
+
printf ' fix: resolve a bug\\n'
|
|
284
|
+
printf ' chore: maintenance task\\n'
|
|
285
|
+
printf ' docs: update documentation\\n'
|
|
286
|
+
printf ' style: formatting only\\n'
|
|
287
|
+
printf ' refactor: code change, no feature/fix\\n'
|
|
288
|
+
printf ' test: add or update tests\\n'
|
|
289
|
+
printf ' perf: performance improvement\\n\\n'
|
|
290
|
+
printf ' Your message: "%s"\\n\\n' "$first_line"
|
|
291
|
+
exit 1
|
|
292
|
+
fi
|
|
293
|
+
`;
|
|
294
|
+
}
|
|
219
295
|
function mixinsScss() {
|
|
220
296
|
return `@mixin absolute($top: auto, $right: auto, $bottom: auto, $left: auto) {
|
|
221
297
|
position: absolute;
|
|
@@ -250,7 +326,7 @@ function mixinsScss() {
|
|
|
250
326
|
// src/templates/pdf.ts
|
|
251
327
|
function pdfFiles(config, pages) {
|
|
252
328
|
return {
|
|
253
|
-
"CHANGELOG.md": changelog(config.
|
|
329
|
+
"CHANGELOG.md": changelog(`${config.templateId} - ${config.name}`),
|
|
254
330
|
"data.yaml": pdfYaml(config),
|
|
255
331
|
"index.html": pdfHtml(pages),
|
|
256
332
|
"assets/.gitkeep": gitkeep(),
|
|
@@ -263,9 +339,9 @@ function pdfFiles(config, pages) {
|
|
|
263
339
|
};
|
|
264
340
|
}
|
|
265
341
|
function pdfYaml(config) {
|
|
266
|
-
const {
|
|
342
|
+
const { templateId, name, subdomain, width, height, pageCount, princeVersion, resizable, proofable, orderable } = config;
|
|
267
343
|
const lines = [
|
|
268
|
-
`name:
|
|
344
|
+
`name: ${templateId} - ${name}`,
|
|
269
345
|
`mode: pdf`,
|
|
270
346
|
`prince_version: ${princeVersion}`,
|
|
271
347
|
`status: 0`,
|
|
@@ -443,7 +519,7 @@ function pdfPageScss(pages) {
|
|
|
443
519
|
// src/templates/general.ts
|
|
444
520
|
function generalFiles(config, pages) {
|
|
445
521
|
return {
|
|
446
|
-
"CHANGELOG.md": changelog(config.
|
|
522
|
+
"CHANGELOG.md": changelog(`${config.templateId} - ${config.name}`),
|
|
447
523
|
"data.yaml": generalYaml(config),
|
|
448
524
|
"index.html": generalHtml(pages),
|
|
449
525
|
"assets/.gitkeep": gitkeep(),
|
|
@@ -456,9 +532,9 @@ function generalFiles(config, pages) {
|
|
|
456
532
|
};
|
|
457
533
|
}
|
|
458
534
|
function generalYaml(config) {
|
|
459
|
-
const {
|
|
535
|
+
const { templateId, name, subdomain, width, height, pageCount, exportFormats } = config;
|
|
460
536
|
const lines = [
|
|
461
|
-
`name:
|
|
537
|
+
`name: ${templateId} - ${name}`,
|
|
462
538
|
`mode: general`,
|
|
463
539
|
`subdomain: ${subdomain}`,
|
|
464
540
|
`dimension_mode: px`,
|
|
@@ -589,7 +665,7 @@ function generalPageScss(pages) {
|
|
|
589
665
|
// src/templates/video.ts
|
|
590
666
|
function videoFiles(config) {
|
|
591
667
|
return {
|
|
592
|
-
"CHANGELOG.md": changelog(config.
|
|
668
|
+
"CHANGELOG.md": changelog(`${config.templateId} - ${config.name}`),
|
|
593
669
|
"data.yaml": videoYaml(config),
|
|
594
670
|
"index.html": videoHtml(),
|
|
595
671
|
"assets/.gitkeep": gitkeep(),
|
|
@@ -605,7 +681,7 @@ function videoFiles(config) {
|
|
|
605
681
|
}
|
|
606
682
|
function videoYaml(config) {
|
|
607
683
|
return `# TODO: Video template support is WIP
|
|
608
|
-
name:
|
|
684
|
+
name: ${config.templateId} - ${config.name}
|
|
609
685
|
mode: video
|
|
610
686
|
subdomain: ${config.subdomain}
|
|
611
687
|
duration: '30'
|
|
@@ -674,7 +750,7 @@ $color-accent: #0079C8;
|
|
|
674
750
|
// src/templates/email.ts
|
|
675
751
|
function emailFiles(config) {
|
|
676
752
|
return {
|
|
677
|
-
"CHANGELOG.md": changelog(config.
|
|
753
|
+
"CHANGELOG.md": changelog(`${config.templateId} - ${config.name}`),
|
|
678
754
|
"data.yaml": emailYaml(config),
|
|
679
755
|
"index.html": emailHtml(),
|
|
680
756
|
"assets/.gitkeep": gitkeep(),
|
|
@@ -689,7 +765,7 @@ function emailFiles(config) {
|
|
|
689
765
|
};
|
|
690
766
|
}
|
|
691
767
|
function emailYaml(config) {
|
|
692
|
-
return `name:
|
|
768
|
+
return `name: ${config.templateId} - ${config.name}
|
|
693
769
|
mode: email
|
|
694
770
|
status: 0
|
|
695
771
|
subdomain: ${config.subdomain}
|
|
@@ -792,55 +868,207 @@ $color-accent: #0079C8;
|
|
|
792
868
|
`;
|
|
793
869
|
}
|
|
794
870
|
|
|
871
|
+
// src/files.ts
|
|
872
|
+
function buildFiles(config) {
|
|
873
|
+
if (config.mode === "pdf") return pdfFiles(config, buildPages(config.pageCount));
|
|
874
|
+
if (config.mode === "general") return generalFiles(config, buildPages(config.pageCount));
|
|
875
|
+
if (config.mode === "video") return videoFiles(config);
|
|
876
|
+
return emailFiles(config);
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
// src/git.ts
|
|
880
|
+
import { join, basename } from "path";
|
|
881
|
+
import { execSync } from "child_process";
|
|
882
|
+
import fse from "fs-extra";
|
|
883
|
+
import kleur2 from "kleur";
|
|
884
|
+
async function ensureHubRepo(hubId) {
|
|
885
|
+
const cwd = process.cwd();
|
|
886
|
+
const dirName = hubRepoDirName(hubId);
|
|
887
|
+
const alreadyInside = basename(cwd) === dirName;
|
|
888
|
+
const hubDir = alreadyInside ? cwd : join(cwd, dirName);
|
|
889
|
+
if (alreadyInside || await fse.pathExists(hubDir)) {
|
|
890
|
+
console.log(kleur2.dim(`
|
|
891
|
+
\u21BB Pulling latest ${dirName}...`));
|
|
892
|
+
execSync("git pull", { cwd: hubDir, stdio: "ignore" });
|
|
893
|
+
} else {
|
|
894
|
+
console.log(kleur2.dim(`
|
|
895
|
+
\u2193 Cloning ${hubRepoUrl(hubId)}...`));
|
|
896
|
+
execSync(`git clone ${hubRepoUrl(hubId)}`, { stdio: "inherit" });
|
|
897
|
+
}
|
|
898
|
+
return hubDir;
|
|
899
|
+
}
|
|
900
|
+
async function setupHooks(hubDir) {
|
|
901
|
+
const hookPath = join(hubDir, ".githooks", "commit-msg");
|
|
902
|
+
if (!await fse.pathExists(hookPath)) {
|
|
903
|
+
await fse.ensureDir(join(hookPath, ".."));
|
|
904
|
+
await fse.writeFile(hookPath, commitMsgHook(), "utf8");
|
|
905
|
+
await fse.chmod(hookPath, 493);
|
|
906
|
+
console.log(kleur2.dim(` + .githooks/commit-msg`));
|
|
907
|
+
}
|
|
908
|
+
execSync("git config core.hooksPath .githooks", { cwd: hubDir, stdio: "ignore" });
|
|
909
|
+
}
|
|
910
|
+
|
|
795
911
|
// src/scaffold.ts
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
912
|
+
import { join as join2 } from "path";
|
|
913
|
+
import fse2 from "fs-extra";
|
|
914
|
+
import kleur3 from "kleur";
|
|
915
|
+
async function writeFiles(outDir, files, fullName) {
|
|
916
|
+
for (const [rel, content] of Object.entries(files)) {
|
|
917
|
+
const fullPath = join2(outDir, rel);
|
|
918
|
+
await fse2.ensureDir(join2(fullPath, ".."));
|
|
919
|
+
await fse2.writeFile(fullPath, content, "utf8");
|
|
920
|
+
console.log(kleur3.dim(` + ${fullName}/${rel}`));
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
// src/template.ts
|
|
925
|
+
async function runTemplate(nameArg) {
|
|
926
|
+
console.log(kleur4.bold().cyan("\n \u25C6 dokio create template\n"));
|
|
927
|
+
const config = await runPrompts(nameArg);
|
|
928
|
+
const files = buildFiles(config);
|
|
929
|
+
const hubDir = await ensureHubRepo(config.hubId);
|
|
930
|
+
const hubDirName = hubRepoDirName(config.hubId);
|
|
931
|
+
const outDir = join3(hubDir, "templates", config.fullName);
|
|
932
|
+
if (await fse3.pathExists(outDir)) {
|
|
933
|
+
console.error(kleur4.red(`
|
|
934
|
+
Error: "${config.fullName}" already exists in ${hubDirName}/templates/.
|
|
801
935
|
`));
|
|
802
936
|
process.exit(1);
|
|
803
937
|
}
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
938
|
+
console.log("");
|
|
939
|
+
await writeFiles(outDir, files, config.fullName);
|
|
940
|
+
await setupHooks(hubDir);
|
|
941
|
+
const templatePath = `${hubDirName}/templates/${config.fullName}`;
|
|
942
|
+
console.log(kleur4.green(`
|
|
943
|
+
\u2713 Created ${kleur4.bold(templatePath)}
|
|
944
|
+
`));
|
|
945
|
+
if (config.mode === "video") {
|
|
946
|
+
console.log(kleur4.yellow(` \u26A0 video support is WIP \u2014 check data.yaml for TODOs
|
|
947
|
+
`));
|
|
813
948
|
}
|
|
949
|
+
console.log(kleur4.dim(` Next steps:`));
|
|
950
|
+
console.log(kleur4.dim(` cd ${templatePath}`));
|
|
951
|
+
console.log(kleur4.dim(` Edit data.yaml \u2014 set your template ID`));
|
|
952
|
+
console.log(kleur4.dim(` Add assets to assets/`));
|
|
953
|
+
console.log("");
|
|
954
|
+
console.log(kleur4.dim(` When ready to commit:`));
|
|
955
|
+
console.log(kleur4.dim(` cd ../../ (back to ${hubDirName}/)`));
|
|
956
|
+
console.log(kleur4.dim(` git add templates/${config.fullName}/`));
|
|
957
|
+
console.log(kleur4.dim(` git commit -m "feat: add ${config.name} template"`));
|
|
958
|
+
console.log(kleur4.dim(` git push`));
|
|
959
|
+
console.log("");
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
// src/hub.ts
|
|
963
|
+
import { join as join4 } from "path";
|
|
964
|
+
import { execSync as execSync2 } from "child_process";
|
|
965
|
+
import fse4 from "fs-extra";
|
|
966
|
+
import kleur5 from "kleur";
|
|
967
|
+
import prompts2 from "prompts";
|
|
968
|
+
var onCancel2 = () => {
|
|
969
|
+
console.log(kleur5.yellow("\n Cancelled.\n"));
|
|
970
|
+
process.exit(0);
|
|
971
|
+
};
|
|
972
|
+
async function runHub() {
|
|
973
|
+
console.log(kleur5.bold().cyan("\n \u25C6 dokio create hub\n"));
|
|
974
|
+
const answers = await prompts2(
|
|
975
|
+
[
|
|
976
|
+
{
|
|
977
|
+
type: "text",
|
|
978
|
+
name: "hubId",
|
|
979
|
+
message: "Hub ID (kebab-case, e.g. bupa-sam)",
|
|
980
|
+
validate: (v) => /^[a-z0-9-]+$/.test(v.trim()) || "Lowercase letters, numbers, hyphens only"
|
|
981
|
+
},
|
|
982
|
+
{
|
|
983
|
+
type: "text",
|
|
984
|
+
name: "hubName",
|
|
985
|
+
message: "Hub display name (e.g. Bupa Sales And Marketing Hub)",
|
|
986
|
+
validate: (v) => v.trim().length > 0 || "Required"
|
|
987
|
+
}
|
|
988
|
+
],
|
|
989
|
+
{ onCancel: onCancel2 }
|
|
990
|
+
);
|
|
991
|
+
const hubId = answers.hubId.trim();
|
|
992
|
+
const hubName = answers.hubName.trim();
|
|
993
|
+
const dirName = `${hubId}-templates`;
|
|
994
|
+
const outDir = join4(process.cwd(), dirName);
|
|
995
|
+
if (await fse4.pathExists(outDir)) {
|
|
996
|
+
console.error(kleur5.red(`
|
|
997
|
+
Error: "${dirName}" already exists.
|
|
998
|
+
`));
|
|
999
|
+
process.exit(1);
|
|
1000
|
+
}
|
|
1001
|
+
const files = {
|
|
1002
|
+
".githooks/commit-msg": commitMsgHook(),
|
|
1003
|
+
".vscode/settings.json": JSON.stringify({ "scss.validate": false, "css.validate": false }, null, 2) + "\n",
|
|
1004
|
+
"templates/.gitkeep": "",
|
|
1005
|
+
"tools/.gitkeep": "",
|
|
1006
|
+
".gitignore": `.DS_Store
|
|
1007
|
+
node_modules/
|
|
1008
|
+
*.log
|
|
1009
|
+
`,
|
|
1010
|
+
"README.md": `# ${hubName}
|
|
1011
|
+
|
|
1012
|
+
Templates for ${hubName} on Dokio.
|
|
1013
|
+
|
|
1014
|
+
## Creating a new template
|
|
1015
|
+
|
|
1016
|
+
Run \`create-dokio template\` from inside this repo.
|
|
1017
|
+
`
|
|
1018
|
+
};
|
|
814
1019
|
console.log("");
|
|
815
1020
|
for (const [rel, content] of Object.entries(files)) {
|
|
816
|
-
const fullPath =
|
|
817
|
-
await
|
|
818
|
-
await
|
|
819
|
-
|
|
1021
|
+
const fullPath = join4(outDir, rel);
|
|
1022
|
+
await fse4.ensureDir(join4(fullPath, ".."));
|
|
1023
|
+
await fse4.writeFile(fullPath, content, "utf8");
|
|
1024
|
+
if (rel === ".githooks/commit-msg") await fse4.chmod(fullPath, 493);
|
|
1025
|
+
console.log(kleur5.dim(` + ${rel}`));
|
|
820
1026
|
}
|
|
1027
|
+
execSync2("git init", { cwd: outDir, stdio: "ignore" });
|
|
1028
|
+
execSync2("git config core.hooksPath .githooks", { cwd: outDir, stdio: "ignore" });
|
|
1029
|
+
execSync2("git add .", { cwd: outDir, stdio: "ignore" });
|
|
1030
|
+
execSync2('git commit -m "chore: init Dokio Hub"', { cwd: outDir, stdio: "ignore" });
|
|
1031
|
+
console.log(kleur5.green(`
|
|
1032
|
+
\u2713 Created ${kleur5.bold(dirName)}
|
|
1033
|
+
`));
|
|
1034
|
+
console.log(kleur5.dim(` Next steps:`));
|
|
1035
|
+
console.log(kleur5.dim(` cd ${dirName}`));
|
|
1036
|
+
console.log(kleur5.dim(` Create a GitHub repo: github.com/dokioco/${dirName}`));
|
|
1037
|
+
console.log(kleur5.dim(` git remote add origin https://github.com/dokioco/${dirName}`));
|
|
1038
|
+
console.log(kleur5.dim(` git push -u origin main`));
|
|
1039
|
+
console.log("");
|
|
821
1040
|
}
|
|
822
1041
|
|
|
823
1042
|
// src/index.ts
|
|
824
|
-
async function
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
const isWip = config.mode === "video";
|
|
829
|
-
console.log(kleur3.green(`
|
|
830
|
-
\u2713 Created ${kleur3.bold(config.fullName)}
|
|
831
|
-
`));
|
|
832
|
-
if (isWip) {
|
|
833
|
-
console.log(
|
|
834
|
-
kleur3.yellow(` \u26A0 ${config.mode} support is WIP \u2014 check data.yaml for TODOs
|
|
835
|
-
`)
|
|
836
|
-
);
|
|
1043
|
+
async function main(argv) {
|
|
1044
|
+
const subcommand = argv[0];
|
|
1045
|
+
if (subcommand === "template") {
|
|
1046
|
+
return runTemplate(argv[1]);
|
|
837
1047
|
}
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
console.log(
|
|
842
|
-
|
|
1048
|
+
if (subcommand === "hub") {
|
|
1049
|
+
return runHub();
|
|
1050
|
+
}
|
|
1051
|
+
console.log(kleur6.bold().cyan("\n \u25C6 dokio create\n"));
|
|
1052
|
+
const { action } = await prompts3(
|
|
1053
|
+
{
|
|
1054
|
+
type: "select",
|
|
1055
|
+
name: "action",
|
|
1056
|
+
message: "What are you creating?",
|
|
1057
|
+
choices: [
|
|
1058
|
+
{ title: "Template", value: "template", description: "Scaffold a new template inside a hub repo" },
|
|
1059
|
+
{ title: "Hub", value: "hub", description: "Create a new hub repository" }
|
|
1060
|
+
]
|
|
1061
|
+
},
|
|
1062
|
+
{
|
|
1063
|
+
onCancel: () => {
|
|
1064
|
+
console.log(kleur6.yellow("\n Cancelled.\n"));
|
|
1065
|
+
process.exit(0);
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
);
|
|
1069
|
+
if (action === "hub") return runHub();
|
|
1070
|
+
return runTemplate();
|
|
843
1071
|
}
|
|
844
1072
|
|
|
845
1073
|
// bin/index.ts
|
|
846
|
-
|
|
1074
|
+
main(process.argv.slice(2));
|