@syncify/cli 1.0.0-alpha.1 → 1.0.0-unstable.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/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2024 Νίκος Σαβίδης
1
+ Copyright 2025 Νίκος Σαβίδης
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
package/dist/api.js ADDED
@@ -0,0 +1,36 @@
1
+ 'use strict';
2
+
3
+ var syncify_js = require('./syncify.js');
4
+
5
+ // syncify/api.ts
6
+ function api(resource, options) {
7
+ if (syncify_js.isString(resource)) {
8
+ if (resource === "watch" || resource === "build" || resource === "export" || resource === "import" || resource === "upload") {
9
+ return (cb) => syncify_js.syncify();
10
+ } else {
11
+ throw new Error([
12
+ "Invalid Resource, available resource modes via API:",
13
+ "",
14
+ '- "watch"',
15
+ '- "build"',
16
+ '- "export"',
17
+ '- "import"',
18
+ '- "upload"',
19
+ ""
20
+ ].join("\n"));
21
+ }
22
+ } else if (syncify_js.isObject(resource)) {
23
+ if (!syncify_js.isUndefined(options)) {
24
+ throw new Error("You cannot provide options when running instance");
25
+ }
26
+ return {
27
+ watch: (cb) => syncify_js.syncify(),
28
+ build: (cb) => syncify_js.syncify(),
29
+ download: (cb) => syncify_js.syncify(),
30
+ upload: (cb) => syncify_js.syncify()
31
+ };
32
+ }
33
+ }
34
+ var api_default = api;
35
+
36
+ module.exports = api_default;
package/dist/cli.js ADDED
@@ -0,0 +1,615 @@
1
+ 'use strict';
2
+
3
+ var syncify_js = require('./syncify.js');
4
+ var node_path = require('node:path');
5
+ var node_process = require('node:process');
6
+ var node_util = require('node:util');
7
+
8
+ // syncify/cli/help/utils.ts
9
+ function describe(message) {
10
+ return syncify_js.$.terminal.cols < 75 ? "" : syncify_js.gray2(`\u203A ${message}`);
11
+ }
12
+ function highlight(input) {
13
+ return input.replace(/([${}<>])/g, syncify_js.gray2("$1")).replace(/(,)(?= -)/g, syncify_js.gray2("$1")).replace(/(\[options\])/g, `${syncify_js.LSB}options${syncify_js.RSB}`).replace(/(?<= )(-|--)(?=[a-zA-Z]+)/g, syncify_js.gray2("$1"));
14
+ }
15
+ function encase({ banner = false }) {
16
+ const arrow = `${syncify_js.Encase("SB", syncify_js.gray2("\u25B2"))} AND DOWN ${syncify_js.Encase("SB", syncify_js.gray2("\u25BC"))}`;
17
+ const label = syncify_js.gray2(`UP ${arrow} ARROW KEYS TO SCROLL`);
18
+ const header = syncify_js.Create().Break(2).Top(label, false).Newline();
19
+ const footer = syncify_js.Create().Newline(2).End(label, false).Break();
20
+ if (banner) {
21
+ header.Line("\u2588\u2580\u2580 \u2588 \u2588 \u2588\u2580\u2588 \u2588\u2580\u2580 \u2580\u2588\u2580 \u2588\u2580\u2580 \u2588 \u2588", syncify_js.lightGray).Line("\u2580\u2580\u2588 \u2580\u2580\u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2580\u2580 \u2580\u2580\u2588", syncify_js.lightGray).Line("\u2580\u2580\u2580 \u2580\u2580\u2580 \u2580 \u2580 \u2580\u2580\u2580 \u2580\u2580\u2580 \u2580 \u2580\u2580\u2580", syncify_js.lightGray).Newline();
22
+ }
23
+ return [header.toString(), footer];
24
+ }
25
+
26
+ // syncify/cli/help/default.ts
27
+ function Default() {
28
+ syncify_js.Create().Header(`HELP${syncify_js.COL}`, syncify_js.bold2).Line(` $ sy help ${describe("Prints this screen")}`).Line(` $ sy help {mode} ${describe("Pick a mode and view usage guide")}`).Line(` $ sy help examples ${describe("Real world command line examples")}`).Header(`USAGE${syncify_js.COL}`, syncify_js.bold2).Line(` $ sy {mode} ${describe("Command mode is required")}`).Line(` $ sy {mode} --flags ${describe("Flags can be provided to modes")}`).Line(` $ sy {mode} [options] ${describe("Some modes accept positionals")}`).Line(` $ sy {mode} [options] --flags ${describe("Mode with positional and flags")}`).Header("MODES" + syncify_js.COL, syncify_js.bold2).Line(` $ sy init ${describe("Setup Syncify in existing project")}`).Line(` $ sy build ${describe("Build theme from source")}`).Line(` $ sy watch ${describe("Watch and rebuild changes")}`).Line(` $ sy pull ${describe("Download from a store theme")}`).Line(` $ sy push ${describe("Upload to a store theme")}`).Line(` $ sy create ${describe("Create a new Syncify project")}`).Line(` $ sy publish ${describe("Changes a theme role to and makes it main")}`, syncify_js.dim2).Line(` $ sy delete ${describe("Remove files/resources from a store or theme")}`, syncify_js.dim2).Line(` $ sy pack ${describe("Generate a .zip package of the current theme")}`, syncify_js.dim2).Line(` $ sy link ${describe("Link existing themes/s from a store")}`).Line(` $ sy unlink ${describe("Remove a linked theme/s from project")}`, syncify_js.dim2).Line(` $ sy duplicate ${describe("Duplicates an existing theme in a store")}`).Line(` $ sy keychain ${describe("Access the global token keychain")}`).Line(` $ sy git ${describe("Git integration configuration and information")}`, syncify_js.dim2).Line(` $ sy prune ${describe("Clears internal project caches from disk")}`, syncify_js.dim2).Line(` $ sy inspect ${describe("Prints information about Syncify installation")}`).Line(` $ sy projects ${describe("Lists all Syncify projects on this device")}`).Line(` $ sy doctor ${describe("Diagnostics and fixable operations")}`, syncify_js.dim2).Line(` $ sy help ${describe("Print complete command list")}`).Header(`FLAGS${syncify_js.COL}`, syncify_js.bold2).Line(` --input, -i ${describe("Define input (source) directory")}`).Line(` --output, -o ${describe("Define output directory")}`).Line(` --config, -c ${describe("Define config directory")}`).Line(` --hot, -h ${describe("HOT Reload when running watch mode")}`).Line(` --target, -T ${describe("Theme and store targeting")}`).Line(` --filter, -F ${describe("File filtering and globs")}`).Line(` --align ${describe("Subset theme file merge with remote sources")}`).Line(` --new ${describe("Used with sy pull to create a new theme")}`).Line(` --bind ${describe("Live bindings in watch mode")}`).Line(` --dev ${describe("Development environment (default)")}`).Line(` --prod ${describe("Production environment")}`).Line(` --terse ${describe("Terse distribution (minification)")}`).Line(` --clean ${describe("Clean output directory")}`).Line(` --silent ${describe("Suppress logging via stdout")}`).Line(` --patch ${describe("Apply a patch version bump")}`).Line(` --minor ${describe("Apply a minor version bump")}`).Line(` --major ${describe("Apply a major version bump")}`).Line(` --force ${describe("Force overwrite or action (caution)")}`).Line(` --batch ${describe("Control batch limit (default is 10)")}`).Ruler().Append("\xA9 2025 \u039D\u03B9\u03BA\u03BF\u03BB\u03B1\u03C2 \u03A3\u03B1\u03B2\u03B2\u03B9\u03B4\u03B7\u03C2", syncify_js.gray2.bold).Line(`Version${syncify_js.COL} ${syncify_js.$.version}`, syncify_js.gray2).Line(`License${syncify_js.COL} Apache 2.0`, syncify_js.gray2).Line(`Website${syncify_js.COL} ${syncify_js.underline2("https://syncify.sh")}`, syncify_js.gray2).Line(`Github${syncify_js.COL} ${syncify_js.underline2("https://github.com/panoply/syncify")}`, syncify_js.gray2).Line(`Discord${syncify_js.COL} ${syncify_js.underline2("https://discord.gg/shopify-developers-597504637167468564")}`, syncify_js.gray2).Newline().toString((input) => {
29
+ const [header, footer] = encase({ banner: true });
30
+ const heading = syncify_js.Scroll({ input: header, height: 8 });
31
+ const content = syncify_js.Scroll({
32
+ input: highlight(input),
33
+ yPos: 8,
34
+ height: syncify_js.$.terminal.rows - 12
35
+ });
36
+ heading.print();
37
+ content.print();
38
+ content.setKeypress(syncify_js.$.terminal.rows, content.maxHeight);
39
+ footer.toLog();
40
+ });
41
+ }
42
+
43
+ // syncify/cli/help/information.ts
44
+ function Inspect() {
45
+ syncify_js.log.clear();
46
+ syncify_js.Create().BR.Top("Inspect").Header(`${syncify_js.white2.bold("@syncify/cli")}`).Line(`${syncify_js.gray2("VERSION")}${syncify_js.COL} v${syncify_js.whiteBright2("1.0.0-alpha.1")}`).Line(`${syncify_js.gray2("HOT")}${syncify_js.COL} v${syncify_js.whiteBright2("0.4.9")}`).Line(`${syncify_js.gray2("LICENSE")}${syncify_js.COL} ${syncify_js.whiteBright2("Apache 2.0")}`).Line(`${syncify_js.gray2("AUTHOR")}${syncify_js.COL} ${syncify_js.whiteBright2("\u039D\u03B9\u03BA\u03BF\u03BB\u03B1\u03C2 \u03A3\u03B1\u03B2\u03B2\u03B9\u03B4\u03B7\u03C2")}`).Line(`${syncify_js.gray2("PM")}${syncify_js.COL} ${syncify_js.whiteBright2(syncify_js.$.pm)}`).Line(`${syncify_js.gray2("OS")}${syncify_js.COL} ${syncify_js.whiteBright2(syncify_js.$.platform)}`).Line(`${syncify_js.gray2("BINARY")}${syncify_js.COL} ${syncify_js.whiteBright2(syncify_js.$.using)}`).Line(`${syncify_js.gray2("CWD")}${syncify_js.COL} ${syncify_js.whiteBright2(syncify_js.$.cwd)}`).Line(`${syncify_js.gray2("HASH")}${syncify_js.COL} ${syncify_js.whiteBright2(syncify_js.$.hash)}`).Line(`${syncify_js.gray2("SCRIPT")}${syncify_js.COL} ${syncify_js.whiteBright2(syncify_js.$.bin)}`).Line(`${syncify_js.gray2("MODULE")}${syncify_js.COL} ${syncify_js.whiteBright2(syncify_js.$.dirs.module)}`).Line(`${syncify_js.gray2("STORE")}${syncify_js.COL} ${syncify_js.whiteBright2(syncify_js.$.home)}`).Line(`${syncify_js.gray2("KEYCHAIN")}${syncify_js.COL} ${syncify_js.whiteBright2(`${syncify_js.$.file.keychain}`)}`).Line(`${syncify_js.gray2("GITHUB")}${syncify_js.COL} ${syncify_js.whiteBright2(syncify_js.$.github)}`).Line(`${syncify_js.gray2("WEBSITE")}${syncify_js.COL} ${syncify_js.whiteBright2("https://syncify.sh")}`).NL.End("Inspect").BR.toLog().Break();
47
+ }
48
+ function Version() {
49
+ syncify_js.log.clear();
50
+ syncify_js.Create().BR.Top("Versions", false).NL.Line(`${syncify_js.whiteBright2("@syncify/cli")} ${syncify_js.ARR} ${syncify_js.whiteBright2("v1.0.0-alpha.1")}`).Line(`${syncify_js.whiteBright2("@syncify/hot")} ${syncify_js.ARR} ${syncify_js.whiteBright2("v0.4.9")}`).NL.End("Versions", false).BR.toLog().Break();
51
+ }
52
+
53
+ // syncify/cli/help/descriptions.ts
54
+ var description = (mode) => ({
55
+ create: {
56
+ reference: "https://syncify.sh/cli/sy-create",
57
+ overview: "The create command is an interactive command prompt. You can (optionally) provide a strap name option to skip choice selection. Options with strikethrough are either deprecated or not yet available for use."
58
+ },
59
+ build: {
60
+ reference: "https://syncify.sh/cli/sy-build",
61
+ overview: "Runs Syncify in build mode, processing files from the input directory to create a Shopify-compliant theme structure in the output directory, ready for deployment."
62
+ },
63
+ watch: {
64
+ reference: "https://syncify.sh/cli/sy-watch",
65
+ overview: "Runs Syncify in watch mode, monitors the input directory for file changes. On modification, it updates the output directory and uploads to a Shopify theme/store, keeping both in sync with local files."
66
+ },
67
+ push: {
68
+ reference: "https://syncify.sh/cli/sy-push",
69
+ overview: "Upload theme files and/or resources to an online store. Use the push command to perform various sync operations with local versions."
70
+ },
71
+ pull: {
72
+ reference: "https://syncify.sh/cli/sy-pull",
73
+ overview: "Download theme files and/or resources from an online store. This command can be used to align remote versions with local ones and carry out merge operations."
74
+ },
75
+ projects: {
76
+ reference: "https://syncify.sh/cli/sy-projects",
77
+ overview: "Lists details of all Syncify projects on the device. Syncify maintains a hard cache in the OS home directory, which is accessed when the command runs. Optionally, specify a project directory name to retrieve info for that project."
78
+ },
79
+ inspect: {
80
+ reference: "https://syncify.sh/cli/sy-inspect",
81
+ overview: "Prints information about the Syncify installation on your device or within your project. This information can be provided when submitting issues or reporting bugs."
82
+ },
83
+ __: null
84
+ })[mode || "__"];
85
+
86
+ // syncify/cli/help/modes.ts
87
+ function Modes(mode) {
88
+ if (mode in Modes) return Modes[mode]();
89
+ const tui = syncify_js.Create().Top(`Syncify ${syncify_js.CHV} Error`, false).Header("NOT YET AVAILABLE", syncify_js.yellowBright2.bold);
90
+ if (syncify_js.COMMAND_MODES.has(mode)) {
91
+ const message = [
92
+ `Help reference for the ${syncify_js.bold2(`sy help ${mode}`)} command is not yet available to`,
93
+ `${syncify_js.bold2("sy help")} but is slated for inclusion in upcoming releases.`,
94
+ "The command itself is valid and functional, only the help information is unavailable."
95
+ ];
96
+ const modes = syncify_js.toArray(syncify_js.COMMAND_MODES).filter((n) => n !== "help").sort((a, b) => a in Modes === b in Modes ? 0 : a in Modes ? -1 : 1);
97
+ const equal = syncify_js.eqWS(modes, { padding: 0 });
98
+ tui.Wrap(message, syncify_js.yellowBright2).Newline().Each(modes, (name) => name in Modes ? tui.Line(`$ sy help ${name} ${equal(name) + syncify_js.CHK}`, syncify_js.whiteBright2) : tui.Line(`$ ${syncify_js.strikethrough2(`sy help ${name}`)}`, syncify_js.gray2));
99
+ }
100
+ tui.Newline().End(`Syncify ${syncify_js.CHV} Error`, false).BR.toLog(highlight);
101
+ }
102
+ Modes.push = () => {
103
+ const info = description("push");
104
+ syncify_js.Create().BR.Top(`help ${syncify_js.TLD} sy push`, false).True(info, (tui) => tui.Header(`DESCRIPTION${syncify_js.COL}`, syncify_js.bold2).Wrap(syncify_js.gray2, info.overview)).True(info, (tui) => tui.Prepend(info.reference, syncify_js.gray2.underline)).Header(`COMMANDS${syncify_js.COL}`, syncify_js.bold2).Line(" $ sy push").Line(" $ sy push --flags").Header(`FLAGS${syncify_js.COL}`, syncify_js.bold2).Line(` --force ${describe("Skips diffing and force overwrites")}`).Line(` --filter, -F ${describe("filter specific files/directories")}`).Line(` --target, -T ${describe("Target a theme or store")}`).Line(` --batch <number> ${describe("Upsert batch limits (default 10)")}`).Newline().End(`help ${syncify_js.TLD} sy push`, false).BR.toLog(highlight);
105
+ syncify_js.kill.exit(0);
106
+ };
107
+ Modes.pull = () => {
108
+ const info = description("pull");
109
+ syncify_js.Create().BR.Top(`help ${syncify_js.TLD} sy pull`, false).True(info, (tui) => tui.Header(`DESCRIPTION${syncify_js.COL}`, syncify_js.bold2).Wrap(syncify_js.gray2, info.overview)).True(info, (tui) => tui.Prepend(info.reference, syncify_js.gray2.underline)).Header(`COMMANDS${syncify_js.COL}`, syncify_js.bold2).Line(" $ sy pull").Line(" $ sy pull --flags").Header(`FLAGS${syncify_js.COL}`, syncify_js.bold2).Line(` --filter, -F ${describe("Filter specific files/directories")}`).Line(` --target, -T ${describe("Target a theme or store")}`).Line(` --merge ${describe(`Merges local ${syncify_js.ARL} remote theme`)}`).Line(` --align ${describe(`Align local ${syncify_js.ARL} remote theme JSON files`)}`).Line(` --force ${describe("Skips diffing and force overwrites")}`).Line(` --output, -o ${describe("Controls where theme file/s are written")}`).Line(` --batch <number> ${describe("Upsert batch limits (default 10)")}`).Line(` --help ${describe("Show this screen")}`).NL.End(`help ${syncify_js.TLD} sy push`, false).BR.toLog(highlight);
110
+ };
111
+ Modes.watch = () => {
112
+ const info = description("watch");
113
+ syncify_js.Create().BR.Top(`help ${syncify_js.TLD} sy watch`, false).True(info, (tui) => tui.Header(`DESCRIPTION${syncify_js.COL}`, syncify_js.bold2).Wrap(syncify_js.gray2, info.overview)).True(info, (tui) => tui.Prepend(info.reference, syncify_js.gray2.underline)).Header(`COMMANDS${syncify_js.COL}`, syncify_js.bold2).Line(" $ sy watch").Line(" $ sy watch --flags").Header(`FLAGS${syncify_js.COL}`, syncify_js.bold2).Line(` --target, -T ${describe("Target a theme or store")}`).Line(` --filter, -F ${describe("Filter specific files/directories")}`).Line(` --hot ${describe("Activates HOT Reloading")}`).Line(` --align ${describe("Align local theme JSON files before watching")}`).Line(` --bind ${describe("Activates 2 way bindings")}`).Line(` --terse ${describe("Terse minification")}`).Line(` --dev ${describe("Development build mode (default)")}`).Line(` --prod ${describe("Production build mode")}`).Line(` --help ${describe("Show this screen")}`).NL.End(`help ${syncify_js.TLD} sy watch`, false).BR.toLog(highlight);
114
+ };
115
+ Modes.inspect = () => {
116
+ const info = description("watch");
117
+ syncify_js.Create().BR.Top(`help ${syncify_js.TLD} sy inspect`, false).True(info, (tui) => tui.Header(`DESCRIPTION${syncify_js.COL}`, syncify_js.bold2).Wrap(syncify_js.gray2, info.overview)).True(info, (tui) => tui.Prepend(info.reference, syncify_js.gray2.underline)).Header(`COMMANDS${syncify_js.COL}`, syncify_js.bold2).Line(" $ sy inspect").NL.End(`help ${syncify_js.TLD} sy inspect`, false).BR.toLog(highlight);
118
+ };
119
+ Modes.create = () => {
120
+ const info = description("build");
121
+ const message = syncify_js.Create().BR.Top(`help ${syncify_js.TLD} sy create`, false).True(info, (tui) => tui.Header(`DESCRIPTION${syncify_js.COL}`, syncify_js.bold2).Wrap(syncify_js.gray2, info.overview)).True(info, (tui) => tui.Prepend(info.reference, syncify_js.gray2.underline)).Header(`COMMANDS${syncify_js.COL}`, syncify_js.bold2).Line(" $ sy create").Line(` $ sy create ${syncify_js.Encase("AN", "strap")}`).Header(`OPTIONS${syncify_js.COL}`, syncify_js.bold2);
122
+ const straps = [...syncify_js.STRAP_THEMES, ...syncify_js.STRAP_EXAMPLES];
123
+ const eq = syncify_js.eqWS(straps.map(([name]) => name), { padding: 2 });
124
+ syncify_js.forEach(([name, desc, unavilable]) => {
125
+ const line = unavilable ? ` $ ${syncify_js.strikethrough2(`sy create ${name}`)}${eq(name)} ${describe("unavilable")}` : ` $ sy create ${name}${eq(name)} ${describe(desc.trim())}`;
126
+ message.Line(line);
127
+ }, straps);
128
+ message.NL.End(`help ${syncify_js.TLD} sy push`, false).BR.toLog(highlight);
129
+ };
130
+ Modes.projects = () => {
131
+ const info = description("projects");
132
+ syncify_js.Create().BR.Top(`help ${syncify_js.TLD} sy projects`, false).True(info, (tui) => tui.Header(`DESCRIPTION${syncify_js.COL}`, syncify_js.bold2).Wrap(syncify_js.gray2, info.overview)).True(info, (tui) => tui.Prepend(info.reference, syncify_js.gray2.underline)).Header(`COMMANDS${syncify_js.COL}`, syncify_js.bold2).Line(" $ sy projects").Line(` $ sy projects ${syncify_js.Encase("AN", syncify_js.magenta2("name"))}`).NL.End(`help ${syncify_js.TLD} sy push`, false).BR.toLog(highlight);
133
+ };
134
+ Modes.build = () => {
135
+ const info = description("build");
136
+ syncify_js.Create().BR.Top(`help ${syncify_js.TLD} sy build`, false).True(info, (tui) => tui.Header(`DESCRIPTION${syncify_js.COL}`, syncify_js.bold2).Wrap(syncify_js.gray2, info.overview)).True(info, (tui) => tui.Prepend(info.reference, syncify_js.gray2.underline)).Header(`COMMANDS${syncify_js.COL}`, syncify_js.bold2).Line(" $ sy build").Line(" $ sy build --flags").Line(` $ sy build ${syncify_js.Encase("SB", "option")}`).Line(` $ sy build ${syncify_js.Encase("SB", "option")} --flags`).Header(`OPTIONS${syncify_js.COL}`, syncify_js.bold2).Line(` $ sy build script ${describe("Run build on script transform")}`).Line(` $ sy build style ${describe("Run build on style transform")}`).Line(` $ sy build svg ${describe("Run build on svg transform")}`).Line(` $ sy build liquid ${describe("Run build on liquid transform")}`).Line(` $ sy build json ${describe("Run build on json transform")}`).Header(`FLAGS${syncify_js.COL}`, syncify_js.bold2).Line(` --terse ${describe("Terse minification")}`).Line(` --dev ${describe("Development build mode (default)")}`).Line(` --prod ${describe("Production build mode")}`).Line(` --help ${describe("Show this screen")}`).NL.End(`help ${syncify_js.TLD} sy build`, false).BR.toLog(highlight);
137
+ };
138
+
139
+ // syncify/cli/help/suggest.ts
140
+ function Suggest() {
141
+ syncify_js.Create().Top(`Syncify ${syncify_js.CHV} Error`, false).Header("1.0.0-alpha.1", syncify_js.gray2).Error("MISSING COMMAND " + syncify_js.BAD, syncify_js.bold2.redBright).Newline("red").Error("Please provide a command line argument", syncify_js.redBright2).Header(`USAGE${syncify_js.COL}`, syncify_js.bold2).Line(` $ sy <${syncify_js.magenta2("mode")}>`).Line(` $ sy <${syncify_js.magenta2("mode")}> --flags`).Line(` $ sy <${syncify_js.magenta2("mode")}> [options]`).Line(` $ sy <${syncify_js.magenta2("mode")}> [options] --flags`).Header(`HELP${syncify_js.COL}`, syncify_js.bold2).Line(" $ sy help").Line(` $ sy <${syncify_js.magenta2("mode")}> --help`).NL.End(`Syncify ${syncify_js.CHV} Error`, false).BR.toLog(highlight).Break();
142
+ }
143
+
144
+ // syncify/mode/help.ts
145
+ function Help(mode) {
146
+ syncify_js.log.clear();
147
+ if (mode.suggest) {
148
+ Suggest();
149
+ } else if (mode.inspect) {
150
+ Inspect();
151
+ } else if (mode.version) {
152
+ Version();
153
+ } else if (syncify_js.isNull(mode._)) {
154
+ Default();
155
+ } else {
156
+ Modes(mode._);
157
+ }
158
+ }
159
+
160
+ // syncify/options/command.ts
161
+ var flags = () => ({
162
+ input: { type: "string", short: "i" },
163
+ output: { type: "string", short: "o" },
164
+ config: { type: "string", short: "c" },
165
+ target: { type: "string", multiple: true, short: "T" },
166
+ filter: { type: "string", multiple: true, short: "F" },
167
+ help: { type: "boolean", short: "h" },
168
+ version: { type: "boolean", short: "v" },
169
+ align: { type: "boolean" },
170
+ merge: { type: "boolean" },
171
+ dev: { type: "boolean" },
172
+ prod: { type: "boolean" },
173
+ terse: { type: "boolean" },
174
+ clean: { type: "boolean" },
175
+ silent: { type: "boolean" },
176
+ batch: { type: "string" },
177
+ hot: { type: "boolean" },
178
+ bind: { type: "boolean" },
179
+ force: { type: "boolean" },
180
+ patch: { type: "boolean" },
181
+ minor: { type: "boolean" },
182
+ major: { type: "boolean" },
183
+ main: { type: "boolean" },
184
+ unpublished: { type: "boolean" }
185
+ });
186
+ function parse(cmd) {
187
+ syncify_js.log.clear();
188
+ const fallback = [
189
+ { mode: "suggest" },
190
+ { values: null, positionals: null, tokens: null }
191
+ ];
192
+ if (node_process.argv.length === 2) {
193
+ syncify_js.$.mode.suggest = true;
194
+ return fallback;
195
+ } else {
196
+ const find = node_process.argv[2];
197
+ switch (find) {
198
+ case "-v":
199
+ case "--version":
200
+ syncify_js.$.mode.help = true;
201
+ syncify_js.$.mode.version = true;
202
+ fallback[0].mode = "version";
203
+ return fallback;
204
+ case "-h":
205
+ case "--help":
206
+ syncify_js.$.mode.help = true;
207
+ fallback[0].mode = "help";
208
+ return fallback;
209
+ }
210
+ let i = -1;
211
+ let s = cmd.length;
212
+ while (++i < s) if (cmd[i].mode === find) break;
213
+ if (i === s) {
214
+ syncify_js.throwCommand([
215
+ `Invalid positional or mode${syncify_js.COL} "${syncify_js.red2.bold(find)}"
216
+ `,
217
+ "You must provide a known and valid execution mode.",
218
+ `For a list of available modes, run the help command${syncify_js.COL}
219
+
220
+ `,
221
+ `${syncify_js.gray2("$")} ${syncify_js.blue2("sy help modes")}`
222
+ ]);
223
+ }
224
+ const flag = flags();
225
+ const mode = cmd[i];
226
+ const options = syncify_js.o();
227
+ if ("flags" in mode) {
228
+ i = -1;
229
+ s = mode.flags.length;
230
+ while (++i < s) {
231
+ if (mode.flags[i] in flag) {
232
+ options[mode.flags[i]] = flag[mode.flags[i]];
233
+ } else {
234
+ syncify_js.throwCommand([
235
+ `Unknown flag expression provided "${syncify_js.bold2(`--${mode.flags[i]}`)}"
236
+ `,
237
+ `Accepted flags for ${syncify_js.bold2(mode.mode)} mode${syncify_js.COL}
238
+
239
+ `,
240
+ `${syncify_js.g.nl(mode.flags.map((v) => syncify_js.gray2("--") + syncify_js.blue2(v)))}`
241
+ ]);
242
+ }
243
+ }
244
+ }
245
+ try {
246
+ const args = node_util.parseArgs({
247
+ args: node_process.argv,
248
+ allowPositionals: true,
249
+ tokens: true,
250
+ options
251
+ });
252
+ return [mode, args];
253
+ } catch (error) {
254
+ syncify_js.throwCommand(error.message.replace(/(--?)([a-z-]+)?/g, syncify_js.red2.bold("$1$2")));
255
+ }
256
+ }
257
+ }
258
+ function positional(cmd, tokens) {
259
+ function parseBuild() {
260
+ if (tokens.length > 1) {
261
+ syncify_js.throwCommand([
262
+ `Invalid positional ${syncify_js.bold2("build")} arguments expression provided. No more than 1 transform`,
263
+ `can be passed. Use comma ${syncify_js.bold2(",")} separated expression instead, e.g:
264
+
265
+ `,
266
+ `${syncify_js.gray2("$")} ${syncify_js.blue2(`sy build ${syncify_js.bold2(tokens.join(syncify_js.gray2(",")))}`)}`
267
+ ]);
268
+ return false;
269
+ } else {
270
+ if (tokens[0].indexOf(",") > -1) {
271
+ for (const transform of tokens[0].split(",")) {
272
+ if (!syncify_js.includes(transform, cmd.accepts)) {
273
+ syncify_js.throwCommand([
274
+ `Invalid ${syncify_js.bold2("sy build")} transform "${syncify_js.bold2(transform)}" provided.`,
275
+ `Must be one of the following${syncify_js.COL}
276
+
277
+ `,
278
+ `${syncify_js.g.nl(cmd.accepts.map((v) => syncify_js.blue2(v)))}`
279
+ ]);
280
+ return false;
281
+ } else {
282
+ syncify_js.$.mode[transform] = true;
283
+ return true;
284
+ }
285
+ }
286
+ } else {
287
+ if (!syncify_js.includes(tokens[0], cmd.accepts)) {
288
+ syncify_js.throwCommand([
289
+ `Invalid ${syncify_js.bold2("sy build")} transform "${syncify_js.bold2(tokens[0])}"`,
290
+ `Must be one of the following${syncify_js.COL}
291
+
292
+ `,
293
+ `${syncify_js.g.nl(cmd.accepts.map((v) => syncify_js.blue2(v)))}`
294
+ ]);
295
+ return false;
296
+ } else {
297
+ syncify_js.$.mode[tokens[0]] = true;
298
+ return true;
299
+ }
300
+ }
301
+ }
302
+ }
303
+ function parseHelp() {
304
+ if (cmd.accepts.includes(tokens[0])) {
305
+ syncify_js.$.mode._ = tokens[0];
306
+ return true;
307
+ } else {
308
+ syncify_js.throwCommand([
309
+ `Invalid ${syncify_js.bold2("sy help")} argument "${syncify_js.bold2(tokens[0])}" ${syncify_js.TLD}`,
310
+ `Must be one of the following${syncify_js.COL}
311
+
312
+ `,
313
+ `${syncify_js.g.nl(cmd.accepts.map((v) => `${syncify_js.DSH} sy help ${v}`))}`
314
+ ]);
315
+ return false;
316
+ }
317
+ }
318
+ function parseKeychain() {
319
+ if (cmd.accepts.includes(tokens[0])) {
320
+ syncify_js.$.mode._ = tokens[0];
321
+ return true;
322
+ } else {
323
+ syncify_js.throwCommand([
324
+ `Invalid ${syncify_js.bold2("keychain")} argument "${syncify_js.bold2(tokens[0])}" ${syncify_js.TLD}`,
325
+ `Must be one of the following${syncify_js.COL}
326
+
327
+ `,
328
+ `${syncify_js.g.nl(cmd.accepts.map((v) => `${syncify_js.DSH} ${syncify_js.blue2(v)}`))}`
329
+ ]);
330
+ return false;
331
+ }
332
+ }
333
+ if (syncify_js.$.mode.build) return parseBuild();
334
+ if (syncify_js.$.mode.help) return parseHelp();
335
+ if (syncify_js.$.mode.keychain) return parseKeychain();
336
+ return true;
337
+ }
338
+ function command(commands) {
339
+ syncify_js.runtime();
340
+ const [cmd, flags2] = parse(commands);
341
+ if (cmd.mode === "suggest") {
342
+ Help(syncify_js.$.mode);
343
+ return syncify_js.NooP;
344
+ }
345
+ const [node, bin] = node_process.argv;
346
+ const position = flags2.positionals ? positional(cmd, flags2.positionals.slice(3)) : false;
347
+ syncify_js.event.mode(cmd.mode);
348
+ syncify_js.$.node = node;
349
+ syncify_js.$.bin = bin;
350
+ syncify_js.$.argv = node_process.argv.slice(2);
351
+ syncify_js.$.dirs.module = bin.slice(0, bin.indexOf("dist/"));
352
+ syncify_js.$.using = syncify_js.$.dirs.module.startsWith(node_path.join(syncify_js.$.cwd, "node_modules")) ? "local" : "global";
353
+ syncify_js.$.terminal.wrap = Math.round(syncify_js.$.terminal.cols - syncify_js.$.terminal.cols / 3);
354
+ syncify_js.$.mode[cmd.mode] = true;
355
+ if (syncify_js.$.mode.build) {
356
+ syncify_js.$.log.mode = 4 /* Build */;
357
+ syncify_js.$.mode.script = true;
358
+ syncify_js.$.mode.style = true;
359
+ syncify_js.$.mode.svg = true;
360
+ syncify_js.$.mode.liquid = true;
361
+ syncify_js.$.mode.json = true;
362
+ } else {
363
+ if (syncify_js.$.mode.watch) syncify_js.$.log.mode = 1 /* Watch */;
364
+ if (syncify_js.isNull(syncify_js.$.log.mode) && syncify_js.$.mode.push) syncify_js.$.log.mode = 6 /* Push */;
365
+ if (syncify_js.isNull(syncify_js.$.log.mode) && syncify_js.$.mode.pull) syncify_js.$.log.mode = 7 /* Pull */;
366
+ if (syncify_js.isNull(syncify_js.$.log.mode) && syncify_js.$.mode.build) syncify_js.$.log.mode = 4 /* Build */;
367
+ if (syncify_js.isNull(syncify_js.$.log.mode) && syncify_js.$.mode.pack) syncify_js.$.log.mode = 8 /* Pack */;
368
+ }
369
+ if (cmd.accepts !== null && syncify_js.$.argv.length > 1 && position === false) return syncify_js.NooP;
370
+ if (syncify_js.$.mode.build) {
371
+ syncify_js.$.mode.script = true;
372
+ syncify_js.$.mode.style = true;
373
+ syncify_js.$.mode.svg = true;
374
+ syncify_js.$.mode.liquid = true;
375
+ syncify_js.$.mode.json = true;
376
+ }
377
+ if (syncify_js.$.mode.help || syncify_js.$.mode.inspect) {
378
+ Help(syncify_js.$.mode);
379
+ return syncify_js.NooP;
380
+ }
381
+ syncify_js.assign(syncify_js.$.cmd, flags2.values);
382
+ syncify_js.forKeys((mode) => mode in syncify_js.$.mode ? syncify_js.$.mode[mode] = true : null, flags2.values);
383
+ if (syncify_js.$.mode.help) {
384
+ syncify_js.$.mode._ = cmd.mode;
385
+ Help(syncify_js.$.mode);
386
+ return syncify_js.NooP;
387
+ }
388
+ syncify_js.$.env.prod = syncify_js.$.mode.prod;
389
+ syncify_js.$.env.dev = syncify_js.$.mode.dev && !syncify_js.$.mode.prod;
390
+ syncify_js.$.env.cli = true;
391
+ node_process.env.SYNCIFY_ENV = syncify_js.$.env.dev ? "dev" : "prod";
392
+ node_process.env.SYNCIFY_WATCH = String(syncify_js.$.mode.watch);
393
+ node_process.env.SYNCIFY_VERSION = "1.0.0-alpha.1";
394
+ return (fn) => fn();
395
+ }
396
+
397
+ // syncify/cli.ts
398
+ command(
399
+ [
400
+ {
401
+ mode: "build",
402
+ accepts: [
403
+ "script",
404
+ "style",
405
+ "svg",
406
+ "liquid",
407
+ "json"
408
+ ],
409
+ flags: [
410
+ "help",
411
+ "input",
412
+ "output",
413
+ "config",
414
+ "filter",
415
+ "dev",
416
+ "prod",
417
+ "terse",
418
+ "clean",
419
+ "silent"
420
+ ]
421
+ },
422
+ {
423
+ mode: "watch",
424
+ accepts: null,
425
+ flags: [
426
+ "help",
427
+ "hot",
428
+ "bind",
429
+ "align",
430
+ "input",
431
+ "output",
432
+ "config",
433
+ "target",
434
+ "filter",
435
+ "dev",
436
+ "prod",
437
+ "terse",
438
+ "clean",
439
+ "silent"
440
+ ]
441
+ },
442
+ {
443
+ mode: "pack",
444
+ accepts: null,
445
+ flags: [
446
+ "help",
447
+ "output",
448
+ "config",
449
+ "clean",
450
+ "dev",
451
+ "prod",
452
+ "terse",
453
+ "patch",
454
+ "minor",
455
+ "major"
456
+ ]
457
+ },
458
+ {
459
+ mode: "delete",
460
+ accepts: null,
461
+ flags: [
462
+ "config",
463
+ "target",
464
+ "filter",
465
+ "force"
466
+ ]
467
+ },
468
+ {
469
+ mode: "push",
470
+ accepts: null,
471
+ flags: [
472
+ "help",
473
+ "input",
474
+ "config",
475
+ "target",
476
+ "align",
477
+ "filter",
478
+ "force",
479
+ "batch"
480
+ ]
481
+ },
482
+ {
483
+ mode: "pull",
484
+ accepts: null,
485
+ flags: [
486
+ "help",
487
+ "output",
488
+ "config",
489
+ "target",
490
+ "filter",
491
+ "align",
492
+ "merge",
493
+ "force",
494
+ "batch"
495
+ ]
496
+ },
497
+ {
498
+ mode: "publish",
499
+ accepts: null,
500
+ flags: [
501
+ "output",
502
+ "config",
503
+ "patch",
504
+ "minor",
505
+ "major",
506
+ "clean",
507
+ "dev",
508
+ "prod",
509
+ "terse",
510
+ "target",
511
+ "main",
512
+ "unpublished"
513
+ ]
514
+ },
515
+ {
516
+ mode: "version",
517
+ accepts: null,
518
+ alias: ["version"],
519
+ flags: [
520
+ "help",
521
+ "patch",
522
+ "minor",
523
+ "major"
524
+ ]
525
+ },
526
+ {
527
+ mode: "create",
528
+ flags: [
529
+ "help"
530
+ ],
531
+ accepts: [
532
+ "dawn",
533
+ "dusk",
534
+ "silk",
535
+ "using-paths",
536
+ "using-rename",
537
+ "using-sass",
538
+ "using-schema",
539
+ "using-tailwind",
540
+ "using-typescript"
541
+ ]
542
+ },
543
+ {
544
+ mode: "keychain",
545
+ flags: [
546
+ "help"
547
+ ],
548
+ accepts: [
549
+ "create",
550
+ "update",
551
+ "associate",
552
+ "migrate",
553
+ "inspect"
554
+ ]
555
+ },
556
+ {
557
+ mode: "help",
558
+ alias: ["help"],
559
+ accepts: [
560
+ "examples",
561
+ // SUPPORTED
562
+ "watch",
563
+ "build",
564
+ "push",
565
+ "pull",
566
+ "create",
567
+ "inspect",
568
+ "projects",
569
+ // TODO
570
+ "export",
571
+ "import",
572
+ "stash",
573
+ "publish",
574
+ "version",
575
+ "keychain",
576
+ "theme",
577
+ "git",
578
+ "setup",
579
+ "prune",
580
+ "doctor"
581
+ ]
582
+ },
583
+ {
584
+ mode: "init",
585
+ accepts: null
586
+ },
587
+ {
588
+ mode: "projects",
589
+ accepts: null,
590
+ flags: [
591
+ "help"
592
+ ]
593
+ },
594
+ {
595
+ mode: "link",
596
+ accepts: null
597
+ },
598
+ {
599
+ mode: "git",
600
+ accepts: null
601
+ },
602
+ {
603
+ mode: "prune",
604
+ accepts: null
605
+ },
606
+ {
607
+ mode: "doctor",
608
+ accepts: null
609
+ },
610
+ {
611
+ mode: "inspect",
612
+ accepts: null
613
+ }
614
+ ]
615
+ )(syncify_js.syncify);