as-soon 0.0.1
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/.editorconfig +9 -0
- package/.env +5 -0
- package/.env.production +1 -0
- package/.prettierignore +3 -0
- package/.prettierrc +7 -0
- package/README.md +0 -0
- package/dist/chunk-I7R4HAJ6.js +25 -0
- package/dist/chunk-I7R4HAJ6.js.map +1 -0
- package/dist/cli.cjs +106 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +66 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.cjs +31 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/package.json +32 -0
- package/script.sh +4 -0
- package/src/cli.ts +64 -0
- package/src/index.ts +1 -0
- package/src/utils.ts +25 -0
- package/tsconfig.json +13 -0
- package/tsup.config.ts +5 -0
package/.editorconfig
ADDED
package/.env
ADDED
package/.env.production
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
HELLO="prod"
|
package/.prettierignore
ADDED
package/.prettierrc
ADDED
package/README.md
ADDED
|
File without changes
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
__async
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=chunk-I7R4HAJ6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/cli.cjs
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
25
|
+
var __async = (__this, __arguments, generator) => {
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
var fulfilled = (value) => {
|
|
28
|
+
try {
|
|
29
|
+
step(generator.next(value));
|
|
30
|
+
} catch (e) {
|
|
31
|
+
reject(e);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
var rejected = (value) => {
|
|
35
|
+
try {
|
|
36
|
+
step(generator.throw(value));
|
|
37
|
+
} catch (e) {
|
|
38
|
+
reject(e);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
42
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// src/cli.ts
|
|
47
|
+
var import_child_process = require("child_process");
|
|
48
|
+
var import_watcher = __toESM(require("@parcel/watcher"), 1);
|
|
49
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
50
|
+
var import_lodash_es = require("lodash-es");
|
|
51
|
+
var import_ldenv = require("ldenv");
|
|
52
|
+
var args = process.argv.slice(2);
|
|
53
|
+
function error(msg) {
|
|
54
|
+
console.error(msg);
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
var deploymentContext = "localhost";
|
|
58
|
+
var argToConsume;
|
|
59
|
+
var command;
|
|
60
|
+
var commandArgs;
|
|
61
|
+
var options = {};
|
|
62
|
+
for (let i = 0; i < args.length; i++) {
|
|
63
|
+
const arg = args[i];
|
|
64
|
+
if (arg.startsWith("--")) {
|
|
65
|
+
argToConsume = arg.substring(2);
|
|
66
|
+
} else if (arg.startsWith("-")) {
|
|
67
|
+
argToConsume = arg.substring(1);
|
|
68
|
+
} else {
|
|
69
|
+
if (argToConsume) {
|
|
70
|
+
if (options[argToConsume]) {
|
|
71
|
+
options[argToConsume].push(arg);
|
|
72
|
+
} else {
|
|
73
|
+
options[argToConsume] = [arg];
|
|
74
|
+
}
|
|
75
|
+
argToConsume = void 0;
|
|
76
|
+
} else {
|
|
77
|
+
command = arg;
|
|
78
|
+
commandArgs = args.slice(i + 1);
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (!command) {
|
|
84
|
+
error(`please specify a command`);
|
|
85
|
+
}
|
|
86
|
+
var commandToUse = command;
|
|
87
|
+
(0, import_ldenv.loadEnv)({ mode: deploymentContext });
|
|
88
|
+
function _execute() {
|
|
89
|
+
return __async(this, null, function* () {
|
|
90
|
+
(0, import_child_process.execFileSync)(commandToUse, commandArgs, { stdio: ["inherit", "inherit", "inherit"] });
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function main() {
|
|
94
|
+
return __async(this, null, function* () {
|
|
95
|
+
const execute = (0, import_lodash_es.debounce)(_execute, 50);
|
|
96
|
+
for (const p of options["w"]) {
|
|
97
|
+
import_watcher.default.subscribe(import_node_path.default.join(process.cwd(), p), (err, events) => {
|
|
98
|
+
console.log(`Files changed under ${p}`);
|
|
99
|
+
execute();
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
execute();
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
main();
|
|
106
|
+
//# sourceMappingURL=cli.cjs.map
|
package/dist/cli.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { execFileSync } from 'child_process';\nimport watcher from \"@parcel/watcher\";\nimport path from \"node:path\";\nimport { debounce } from \"lodash-es\";\nimport { loadEnv } from \"ldenv\";\n\nconst args = process.argv.slice(2);\n\nfunction error(msg: string) {\n console.error(msg);\n process.exit(1);\n}\n\nlet deploymentContext = \"localhost\";\nlet argToConsume;\nlet command: string | undefined;\nlet commandArgs: string[] | undefined;\nconst options: { [key: string]: string[] } = {};\nfor (let i = 0; i < args.length; i++) {\n const arg = args[i];\n if (arg.startsWith(\"--\")) {\n argToConsume = arg.substring(2);\n } else if (arg.startsWith(\"-\")) {\n argToConsume = arg.substring(1);\n } else {\n if (argToConsume) {\n if (options[argToConsume]) {\n options[argToConsume].push(arg);\n } else {\n options[argToConsume] = [arg];\n }\n argToConsume = undefined;\n } else {\n command = arg;\n commandArgs = args.slice(i + 1);\n break;\n }\n }\n}\n\nif (!command) {\n error(`please specify a command`);\n}\nconst commandToUse = command!;\n\nloadEnv({ mode: deploymentContext });\n\nasync function _execute() {\n execFileSync(commandToUse, commandArgs, { stdio: [\"inherit\", \"inherit\", \"inherit\"] });\n}\n\n\nasync function main() {\n const execute = debounce(_execute, 50);\n for (const p of options[\"w\"]) {\n watcher.subscribe(path.join(process.cwd(), p), (err, events) => {\n console.log(`Files changed under ${p}`)\n execute();\n });\n }\n execute();\n}\nmain();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2BAA6B;AAC7B,qBAAoB;AACpB,uBAAiB;AACjB,uBAAyB;AACzB,mBAAwB;AAExB,IAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AAEjC,SAAS,MAAM,KAAa;AAC1B,UAAQ,MAAM,GAAG;AACjB,UAAQ,KAAK,CAAC;AAChB;AAEA,IAAI,oBAAoB;AACxB,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAM,UAAuC,CAAC;AAC9C,SAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,QAAM,MAAM,KAAK,CAAC;AAClB,MAAI,IAAI,WAAW,IAAI,GAAG;AACxB,mBAAe,IAAI,UAAU,CAAC;AAAA,EAChC,WAAW,IAAI,WAAW,GAAG,GAAG;AAC9B,mBAAe,IAAI,UAAU,CAAC;AAAA,EAChC,OAAO;AACL,QAAI,cAAc;AAChB,UAAI,QAAQ,YAAY,GAAG;AACzB,gBAAQ,YAAY,EAAE,KAAK,GAAG;AAAA,MAChC,OAAO;AACL,gBAAQ,YAAY,IAAI,CAAC,GAAG;AAAA,MAC9B;AACA,qBAAe;AAAA,IACjB,OAAO;AACL,gBAAU;AACV,oBAAc,KAAK,MAAM,IAAI,CAAC;AAC9B;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAI,CAAC,SAAS;AACZ,QAAM,0BAA0B;AAClC;AACA,IAAM,eAAe;AAAA,IAErB,sBAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEnC,SAAe,WAAW;AAAA;AACxB,2CAAa,cAAc,aAAa,EAAE,OAAO,CAAC,WAAW,WAAW,SAAS,EAAE,CAAC;AAAA,EACtF;AAAA;AAGA,SAAe,OAAO;AAAA;AACpB,UAAM,cAAU,2BAAS,UAAU,EAAE;AACrC,eAAW,KAAK,QAAQ,GAAG,GAAG;AAC5B,qBAAAA,QAAQ,UAAU,iBAAAC,QAAK,KAAK,QAAQ,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,WAAW;AAC9D,gBAAQ,IAAI,uBAAuB,GAAG;AACtC,gBAAQ;AAAA,MACV,CAAC;AAAA,IACH;AACA,YAAQ;AAAA,EACV;AAAA;AACA,KAAK;","names":["watcher","path"]}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "./chunk-I7R4HAJ6.js";
|
|
5
|
+
|
|
6
|
+
// src/cli.ts
|
|
7
|
+
import { execFileSync } from "child_process";
|
|
8
|
+
import watcher from "@parcel/watcher";
|
|
9
|
+
import path from "path";
|
|
10
|
+
import { debounce } from "lodash-es";
|
|
11
|
+
import { loadEnv } from "ldenv";
|
|
12
|
+
var args = process.argv.slice(2);
|
|
13
|
+
function error(msg) {
|
|
14
|
+
console.error(msg);
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
var deploymentContext = "localhost";
|
|
18
|
+
var argToConsume;
|
|
19
|
+
var command;
|
|
20
|
+
var commandArgs;
|
|
21
|
+
var options = {};
|
|
22
|
+
for (let i = 0; i < args.length; i++) {
|
|
23
|
+
const arg = args[i];
|
|
24
|
+
if (arg.startsWith("--")) {
|
|
25
|
+
argToConsume = arg.substring(2);
|
|
26
|
+
} else if (arg.startsWith("-")) {
|
|
27
|
+
argToConsume = arg.substring(1);
|
|
28
|
+
} else {
|
|
29
|
+
if (argToConsume) {
|
|
30
|
+
if (options[argToConsume]) {
|
|
31
|
+
options[argToConsume].push(arg);
|
|
32
|
+
} else {
|
|
33
|
+
options[argToConsume] = [arg];
|
|
34
|
+
}
|
|
35
|
+
argToConsume = void 0;
|
|
36
|
+
} else {
|
|
37
|
+
command = arg;
|
|
38
|
+
commandArgs = args.slice(i + 1);
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (!command) {
|
|
44
|
+
error(`please specify a command`);
|
|
45
|
+
}
|
|
46
|
+
var commandToUse = command;
|
|
47
|
+
loadEnv({ mode: deploymentContext });
|
|
48
|
+
function _execute() {
|
|
49
|
+
return __async(this, null, function* () {
|
|
50
|
+
execFileSync(commandToUse, commandArgs, { stdio: ["inherit", "inherit", "inherit"] });
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function main() {
|
|
54
|
+
return __async(this, null, function* () {
|
|
55
|
+
const execute = debounce(_execute, 50);
|
|
56
|
+
for (const p of options["w"]) {
|
|
57
|
+
watcher.subscribe(path.join(process.cwd(), p), (err, events) => {
|
|
58
|
+
console.log(`Files changed under ${p}`);
|
|
59
|
+
execute();
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
execute();
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
main();
|
|
66
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { execFileSync } from 'child_process';\nimport watcher from \"@parcel/watcher\";\nimport path from \"node:path\";\nimport { debounce } from \"lodash-es\";\nimport { loadEnv } from \"ldenv\";\n\nconst args = process.argv.slice(2);\n\nfunction error(msg: string) {\n console.error(msg);\n process.exit(1);\n}\n\nlet deploymentContext = \"localhost\";\nlet argToConsume;\nlet command: string | undefined;\nlet commandArgs: string[] | undefined;\nconst options: { [key: string]: string[] } = {};\nfor (let i = 0; i < args.length; i++) {\n const arg = args[i];\n if (arg.startsWith(\"--\")) {\n argToConsume = arg.substring(2);\n } else if (arg.startsWith(\"-\")) {\n argToConsume = arg.substring(1);\n } else {\n if (argToConsume) {\n if (options[argToConsume]) {\n options[argToConsume].push(arg);\n } else {\n options[argToConsume] = [arg];\n }\n argToConsume = undefined;\n } else {\n command = arg;\n commandArgs = args.slice(i + 1);\n break;\n }\n }\n}\n\nif (!command) {\n error(`please specify a command`);\n}\nconst commandToUse = command!;\n\nloadEnv({ mode: deploymentContext });\n\nasync function _execute() {\n execFileSync(commandToUse, commandArgs, { stdio: [\"inherit\", \"inherit\", \"inherit\"] });\n}\n\n\nasync function main() {\n const execute = debounce(_execute, 50);\n for (const p of options[\"w\"]) {\n watcher.subscribe(path.join(process.cwd(), p), (err, events) => {\n console.log(`Files changed under ${p}`)\n execute();\n });\n }\n execute();\n}\nmain();\n"],"mappings":";;;;;;AACA,SAAS,oBAAoB;AAC7B,OAAO,aAAa;AACpB,OAAO,UAAU;AACjB,SAAS,gBAAgB;AACzB,SAAS,eAAe;AAExB,IAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AAEjC,SAAS,MAAM,KAAa;AAC1B,UAAQ,MAAM,GAAG;AACjB,UAAQ,KAAK,CAAC;AAChB;AAEA,IAAI,oBAAoB;AACxB,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAM,UAAuC,CAAC;AAC9C,SAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,QAAM,MAAM,KAAK,CAAC;AAClB,MAAI,IAAI,WAAW,IAAI,GAAG;AACxB,mBAAe,IAAI,UAAU,CAAC;AAAA,EAChC,WAAW,IAAI,WAAW,GAAG,GAAG;AAC9B,mBAAe,IAAI,UAAU,CAAC;AAAA,EAChC,OAAO;AACL,QAAI,cAAc;AAChB,UAAI,QAAQ,YAAY,GAAG;AACzB,gBAAQ,YAAY,EAAE,KAAK,GAAG;AAAA,MAChC,OAAO;AACL,gBAAQ,YAAY,IAAI,CAAC,GAAG;AAAA,MAC9B;AACA,qBAAe;AAAA,IACjB,OAAO;AACL,gBAAU;AACV,oBAAc,KAAK,MAAM,IAAI,CAAC;AAC9B;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAI,CAAC,SAAS;AACZ,QAAM,0BAA0B;AAClC;AACA,IAAM,eAAe;AAErB,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEnC,SAAe,WAAW;AAAA;AACxB,iBAAa,cAAc,aAAa,EAAE,OAAO,CAAC,WAAW,WAAW,SAAS,EAAE,CAAC;AAAA,EACtF;AAAA;AAGA,SAAe,OAAO;AAAA;AACpB,UAAM,UAAU,SAAS,UAAU,EAAE;AACrC,eAAW,KAAK,QAAQ,GAAG,GAAG;AAC5B,cAAQ,UAAU,KAAK,KAAK,QAAQ,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,WAAW;AAC9D,gBAAQ,IAAI,uBAAuB,GAAG;AACtC,gBAAQ;AAAA,MACV,CAAC;AAAA,IACH;AACA,YAAQ;AAAA,EACV;AAAA;AACA,KAAK;","names":[]}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
nothing: () => nothing
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(src_exports);
|
|
26
|
+
var nothing = 0;
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
nothing
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export const nothing = 0;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAM,UAAU;","names":[]}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export const nothing = 0;\n"],"mappings":";;;AAAO,IAAM,UAAU;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "as-soon",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "watch and execute",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "dist/index.cjs",
|
|
10
|
+
"module": "dist/index.js",
|
|
11
|
+
"types": "dist/index.d.ts",
|
|
12
|
+
"bin": {
|
|
13
|
+
"as-soon": "dist/cli.cjs"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@parcel/watcher": "^2.1.0",
|
|
17
|
+
"ldenv": "^0.2.1",
|
|
18
|
+
"lodash-es": "^4.17.21"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/lodash-es": "^4.17.7",
|
|
22
|
+
"@types/node": "^18.15.5",
|
|
23
|
+
"set-defaults": "^0.0.1",
|
|
24
|
+
"tsup": "^6.7.0",
|
|
25
|
+
"typescript": "^4.9.5"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"prepare": "set-defaults .vscode",
|
|
29
|
+
"build": "tsup --entry src/index.ts --entry src/cli.ts --dts --format esm,cjs",
|
|
30
|
+
"dev": "tsup --entry src/index.ts --entry src/cli.ts --dts --watch --format esm,cjs"
|
|
31
|
+
}
|
|
32
|
+
}
|
package/script.sh
ADDED
package/src/cli.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { execFileSync } from 'child_process';
|
|
3
|
+
import watcher from "@parcel/watcher";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { debounce } from "lodash-es";
|
|
6
|
+
import { loadEnv } from "ldenv";
|
|
7
|
+
|
|
8
|
+
const args = process.argv.slice(2);
|
|
9
|
+
|
|
10
|
+
function error(msg: string) {
|
|
11
|
+
console.error(msg);
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let deploymentContext = "localhost";
|
|
16
|
+
let argToConsume;
|
|
17
|
+
let command: string | undefined;
|
|
18
|
+
let commandArgs: string[] | undefined;
|
|
19
|
+
const options: { [key: string]: string[] } = {};
|
|
20
|
+
for (let i = 0; i < args.length; i++) {
|
|
21
|
+
const arg = args[i];
|
|
22
|
+
if (arg.startsWith("--")) {
|
|
23
|
+
argToConsume = arg.substring(2);
|
|
24
|
+
} else if (arg.startsWith("-")) {
|
|
25
|
+
argToConsume = arg.substring(1);
|
|
26
|
+
} else {
|
|
27
|
+
if (argToConsume) {
|
|
28
|
+
if (options[argToConsume]) {
|
|
29
|
+
options[argToConsume].push(arg);
|
|
30
|
+
} else {
|
|
31
|
+
options[argToConsume] = [arg];
|
|
32
|
+
}
|
|
33
|
+
argToConsume = undefined;
|
|
34
|
+
} else {
|
|
35
|
+
command = arg;
|
|
36
|
+
commandArgs = args.slice(i + 1);
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (!command) {
|
|
43
|
+
error(`please specify a command`);
|
|
44
|
+
}
|
|
45
|
+
const commandToUse = command!;
|
|
46
|
+
|
|
47
|
+
loadEnv({ mode: deploymentContext });
|
|
48
|
+
|
|
49
|
+
async function _execute() {
|
|
50
|
+
execFileSync(commandToUse, commandArgs, { stdio: ["inherit", "inherit", "inherit"] });
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
async function main() {
|
|
55
|
+
const execute = debounce(_execute, 50);
|
|
56
|
+
for (const p of options["w"]) {
|
|
57
|
+
watcher.subscribe(path.join(process.cwd(), p), (err, events) => {
|
|
58
|
+
console.log(`Files changed under ${p}`)
|
|
59
|
+
execute();
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
execute();
|
|
63
|
+
}
|
|
64
|
+
main();
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const nothing = 0;
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// taken from https://github.com/vitejs/vite/blob/63524bac878e8d3771d34ad7ad2e10cd16870ff4/packages/vite/src/node/utils.ts#L371-L400
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
|
|
5
|
+
interface LookupFileOptions {
|
|
6
|
+
pathOnly?: boolean;
|
|
7
|
+
rootDir?: string;
|
|
8
|
+
predicate?: (file: string) => boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function lookupFile(dir: string, formats: string[], options?: LookupFileOptions): string | undefined {
|
|
12
|
+
for (const format of formats) {
|
|
13
|
+
const fullPath = path.join(dir, format);
|
|
14
|
+
if (fs.existsSync(fullPath) && fs.statSync(fullPath).isFile()) {
|
|
15
|
+
const result = options?.pathOnly ? fullPath : fs.readFileSync(fullPath, 'utf-8');
|
|
16
|
+
if (!options?.predicate || options.predicate(result)) {
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const parentDir = path.dirname(dir);
|
|
22
|
+
if (parentDir !== dir && (!options?.rootDir || parentDir.startsWith(options?.rootDir))) {
|
|
23
|
+
return lookupFile(parentDir, formats, options);
|
|
24
|
+
}
|
|
25
|
+
}
|
package/tsconfig.json
ADDED