as-soon 0.0.10 → 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/dist/cli.d.ts CHANGED
@@ -1 +1,3 @@
1
1
  #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js CHANGED
@@ -1,135 +1,143 @@
1
1
  #!/usr/bin/env node
2
- import {
3
- __async
4
- } from "./chunk-AVQVENQ2.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 fs from "fs";
11
- import { debounce } from "lodash";
12
- import { loadEnv } from "ldenv";
13
- var args = process.argv.slice(2);
2
+ import { execFileSync } from 'child_process';
3
+ import watcher from '@parcel/watcher';
4
+ import path from 'node:path';
5
+ import fs from 'node:fs';
6
+ import { debounce } from 'lodash';
7
+ import { loadEnv } from 'ldenv';
8
+ const args = process.argv.slice(2);
14
9
  function error(msg) {
15
- console.error(msg);
16
- process.exit(1);
10
+ console.error(msg);
11
+ process.exit(1);
17
12
  }
18
- var deploymentContext = "localhost";
19
- var argToConsume;
20
- var command;
21
- var commandArgs;
22
- var options = {};
13
+ let deploymentContext = 'localhost';
14
+ let argToConsume;
15
+ let command;
16
+ let commandArgs;
17
+ const options = {};
23
18
  for (let i = 0; i < args.length; i++) {
24
- const arg = args[i];
25
- if (arg.startsWith("--")) {
26
- argToConsume = arg.substring(2);
27
- } else if (arg.startsWith("-")) {
28
- argToConsume = arg.substring(1);
29
- } else {
30
- if (argToConsume) {
31
- if (options[argToConsume]) {
32
- options[argToConsume].push(arg);
33
- } else {
34
- options[argToConsume] = [arg];
35
- }
36
- argToConsume = void 0;
37
- } else {
38
- command = arg;
39
- commandArgs = args.slice(i + 1);
40
- break;
19
+ const arg = args[i];
20
+ if (arg.startsWith('--')) {
21
+ argToConsume = arg.substring(2);
22
+ }
23
+ else if (arg.startsWith('-')) {
24
+ argToConsume = arg.substring(1);
25
+ }
26
+ else {
27
+ if (argToConsume) {
28
+ if (options[argToConsume]) {
29
+ options[argToConsume].push(arg);
30
+ }
31
+ else {
32
+ options[argToConsume] = [arg];
33
+ }
34
+ argToConsume = undefined;
35
+ }
36
+ else {
37
+ command = arg;
38
+ commandArgs = args.slice(i + 1);
39
+ break;
40
+ }
41
41
  }
42
- }
43
42
  }
44
43
  if (!command) {
45
- error(`please specify a command`);
44
+ error(`please specify a command`);
46
45
  }
47
- var commandToUse = command;
48
- console.log(`"${commandToUse} ${(commandArgs == null ? void 0 : commandArgs.join(" ")) || ""}"`);
46
+ const commandToUse = command;
47
+ console.log(`"${commandToUse} ${commandArgs?.join(' ') || ''}"`);
49
48
  loadEnv({ mode: deploymentContext });
50
49
  function _execute() {
51
- try {
52
- execFileSync(commandToUse, commandArgs, { stdio: ["inherit", "inherit", "inherit"] });
53
- } catch (err) {
54
- console.error("failed to execue", err);
55
- }
56
- console.log(`-------------------------------------`);
50
+ try {
51
+ execFileSync(commandToUse, commandArgs, { stdio: ['inherit', 'inherit', 'inherit'] });
52
+ }
53
+ catch (err) {
54
+ console.error('failed to execue', err);
55
+ }
56
+ console.log(`-------------------------------------`);
57
57
  }
58
- function subscribe_folder(absolute_path, execute, filename) {
59
- return __async(this, null, function* () {
60
- const p = path.relative(process.cwd(), absolute_path) || ".";
61
- const subscription = yield watcher.subscribe(absolute_path, (err, events) => {
62
- if (filename) {
63
- for (const event of events) {
64
- if (path.normalize(event.path) === filename) {
65
- console.log(`"${path.basename(filename)}" changed under ${p}`);
66
- execute();
67
- } else if (event.type === "delete" && event.path === absolute_path) {
68
- subscription.unsubscribe();
69
- listen(filename, execute);
70
- return;
71
- }
58
+ // let counter = 0;
59
+ async function subscribe_folder(absolute_path, execute, filename) {
60
+ // const c = ++counter;
61
+ const p = path.relative(process.cwd(), absolute_path) || '.';
62
+ const subscription = await watcher.subscribe(absolute_path, (err, events) => {
63
+ // console.log(`Files changed under ${p} (${c})`);
64
+ if (filename) {
65
+ for (const event of events) {
66
+ if (path.normalize(event.path) === filename) {
67
+ console.log(`"${path.basename(filename)}" changed under ${p}`);
68
+ execute();
69
+ }
70
+ else if (event.type === 'delete' && event.path === absolute_path) {
71
+ subscription.unsubscribe();
72
+ listen(filename, execute);
73
+ return;
74
+ }
75
+ }
72
76
  }
73
- } else {
74
- console.log(`Files changed under ${p}`);
75
- for (const event of events) {
76
- if (event.type === "delete" && event.path === absolute_path) {
77
- subscription.unsubscribe();
78
- listen(absolute_path, execute);
79
- return;
80
- }
77
+ else {
78
+ console.log(`Files changed under ${p}`);
79
+ for (const event of events) {
80
+ if (event.type === 'delete' && event.path === absolute_path) {
81
+ subscription.unsubscribe();
82
+ listen(absolute_path, execute);
83
+ return;
84
+ }
85
+ }
86
+ execute();
81
87
  }
82
- execute();
83
- }
84
88
  });
85
- });
86
89
  }
87
- function listen(absolute_path, execute) {
88
- return __async(this, null, function* () {
90
+ async function listen(absolute_path, execute) {
89
91
  const exists = fs.existsSync(absolute_path);
90
92
  if (exists) {
91
- const isDirectory = exists && fs.statSync(absolute_path).isDirectory();
92
- if (isDirectory) {
93
- subscribe_folder(absolute_path, execute);
94
- } else {
95
- subscribe_folder(path.dirname(absolute_path), execute, absolute_path);
96
- }
97
- } else {
98
- console.log(`${absolute_path} do not exist yet, listening on parent`);
99
- let tmp_subscription = yield watcher.subscribe(
100
- path.dirname(absolute_path),
101
- (err, events) => {
102
- for (const event of events) {
103
- if (event.type === "create" && path.normalize(event.path) === absolute_path) {
104
- tmp_subscription == null ? void 0 : tmp_subscription.unsubscribe();
105
- tmp_subscription = void 0;
106
- setTimeout((v) => {
107
- listen(absolute_path, execute);
108
- }, 500);
109
- }
110
- }
93
+ const isDirectory = fs.statSync(absolute_path).isDirectory();
94
+ if (isDirectory) {
95
+ // console.log(`listen for folder changes...`);
96
+ subscribe_folder(absolute_path, execute);
97
+ }
98
+ else {
99
+ // console.log(`listen for file changes...`);
100
+ subscribe_folder(path.dirname(absolute_path), execute, absolute_path);
111
101
  }
112
- );
113
102
  }
114
- });
103
+ else {
104
+ const parent = path.dirname(absolute_path);
105
+ if (!fs.existsSync(parent)) {
106
+ console.error(`cannot listen on folder who have no parent yet: ${absolute_path}`);
107
+ process.exit(1);
108
+ }
109
+ // console.log(`${absolute_path} do not exist yet, listening on parent : ${parent}`);
110
+ let tmp_subscription = await watcher.subscribe(parent, (err, events) => {
111
+ for (const event of events) {
112
+ if (event.type === 'create' && path.normalize(event.path) === absolute_path) {
113
+ // console.log(`${absolute_path} just got created, listening for it...`);
114
+ tmp_subscription?.unsubscribe();
115
+ tmp_subscription = undefined;
116
+ // wrap in a timeout to ensure @parcel/watcher hook on the correct inode?
117
+ setTimeout(() => {
118
+ listen(absolute_path, execute);
119
+ }, 500);
120
+ }
121
+ }
122
+ });
123
+ }
115
124
  }
116
- function main() {
117
- return __async(this, null, function* () {
125
+ async function main() {
118
126
  const execute = debounce(_execute, 200);
119
127
  execute();
120
- if (options["w"]) {
121
- const folders = options["w"].map((p) => path.normalize(path.join(process.cwd(), p)));
122
- for (const folder of folders) {
128
+ if (options['w']) {
129
+ const folders = options['w'].map((p) => path.normalize(path.join(process.cwd(), p)));
130
+ for (const folder of folders) {
131
+ listen(folder, execute);
132
+ console.log(`Now listening on ${folder}`);
133
+ console.log(`-------------------------------------`);
134
+ }
135
+ }
136
+ else {
137
+ const folder = path.normalize(process.cwd());
138
+ console.log(`listening on current folder: ${folder}`);
123
139
  listen(folder, execute);
124
- console.log(`Now listening on ${folder}`);
125
- console.log(`-------------------------------------`);
126
- }
127
- } else {
128
- const folder = path.normalize(process.cwd());
129
- console.log(`listening on current folder: ${folder}`);
130
- listen(folder, execute);
131
140
  }
132
- });
133
141
  }
134
142
  main();
135
143
  //# sourceMappingURL=cli.js.map
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport {execFileSync} from 'child_process';\nimport watcher, {AsyncSubscription} from '@parcel/watcher';\nimport path from 'node:path';\nimport fs from 'node:fs';\nimport {debounce} from 'lodash';\nimport {loadEnv} from 'ldenv';\n\nconst args = process.argv.slice(2);\n\nfunction error(msg: string) {\n\tconsole.error(msg);\n\tprocess.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\tconst arg = args[i];\n\tif (arg.startsWith('--')) {\n\t\targToConsume = arg.substring(2);\n\t} else if (arg.startsWith('-')) {\n\t\targToConsume = arg.substring(1);\n\t} else {\n\t\tif (argToConsume) {\n\t\t\tif (options[argToConsume]) {\n\t\t\t\toptions[argToConsume].push(arg);\n\t\t\t} else {\n\t\t\t\toptions[argToConsume] = [arg];\n\t\t\t}\n\t\t\targToConsume = undefined;\n\t\t} else {\n\t\t\tcommand = arg;\n\t\t\tcommandArgs = args.slice(i + 1);\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nif (!command) {\n\terror(`please specify a command`);\n}\nconst commandToUse = command!;\n\nconsole.log(`\"${commandToUse} ${commandArgs?.join(' ') || ''}\"`);\n\nloadEnv({mode: deploymentContext});\n\nfunction _execute() {\n\ttry {\n\t\texecFileSync(commandToUse, commandArgs, {stdio: ['inherit', 'inherit', 'inherit']});\n\t} catch (err) {\n\t\tconsole.error('failed to execue', err);\n\t}\n\tconsole.log(`-------------------------------------`);\n}\n\n// let counter = 0;\nasync function subscribe_folder(absolute_path: string, execute: () => void, filename?: string) {\n\t// const c = ++counter;\n\tconst p = path.relative(process.cwd(), absolute_path) || '.';\n\tconst subscription = await watcher.subscribe(absolute_path, (err, events) => {\n\t\t// console.log(`Files changed under ${p} (${c})`);\n\t\tif (filename) {\n\t\t\tfor (const event of events) {\n\t\t\t\tif (path.normalize(event.path) === filename) {\n\t\t\t\t\tconsole.log(`\"${path.basename(filename)}\" changed under ${p}`);\n\t\t\t\t\texecute();\n\t\t\t\t} else if (event.type === 'delete' && event.path === absolute_path) {\n\t\t\t\t\tsubscription.unsubscribe();\n\t\t\t\t\tlisten(filename, execute);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconsole.log(`Files changed under ${p}`);\n\t\t\tfor (const event of events) {\n\t\t\t\tif (event.type === 'delete' && event.path === absolute_path) {\n\t\t\t\t\tsubscription.unsubscribe();\n\t\t\t\t\tlisten(absolute_path, execute);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\texecute();\n\t\t}\n\t});\n}\n\nasync function listen(absolute_path: string, execute: () => void) {\n\tconst exists = fs.existsSync(absolute_path);\n\n\tif (exists) {\n\t\tconst isDirectory = exists && fs.statSync(absolute_path).isDirectory();\n\t\tif (isDirectory) {\n\t\t\tsubscribe_folder(absolute_path, execute);\n\t\t} else {\n\t\t\tsubscribe_folder(path.dirname(absolute_path), execute, absolute_path);\n\t\t}\n\t} else {\n\t\tconsole.log(`${absolute_path} do not exist yet, listening on parent`);\n\t\tlet tmp_subscription: AsyncSubscription | undefined = await watcher.subscribe(\n\t\t\tpath.dirname(absolute_path),\n\t\t\t(err, events) => {\n\t\t\t\tfor (const event of events) {\n\t\t\t\t\tif (event.type === 'create' && path.normalize(event.path) === absolute_path) {\n\t\t\t\t\t\t// console.log(`${absolute_path} just got created, listening for it...`);\n\t\t\t\t\t\ttmp_subscription?.unsubscribe();\n\t\t\t\t\t\ttmp_subscription = undefined;\n\t\t\t\t\t\t// wrap in a timeout to ensure @parcel/watcher hook on the correct inode?\n\t\t\t\t\t\tsetTimeout((v) => {\n\t\t\t\t\t\t\tlisten(absolute_path, execute);\n\t\t\t\t\t\t}, 500);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n}\n\nasync function main() {\n\tconst execute = debounce(_execute, 200);\n\texecute();\n\tif (options['w']) {\n\t\tconst folders = options['w'].map((p) => path.normalize(path.join(process.cwd(), p)));\n\t\tfor (const folder of folders) {\n\t\t\tlisten(folder, execute);\n\n\t\t\tconsole.log(`Now listening on ${folder}`);\n\t\t\tconsole.log(`-------------------------------------`);\n\t\t}\n\t} else {\n\t\tconst folder = path.normalize(process.cwd());\n\t\tconsole.log(`listening on current folder: ${folder}`);\n\t\tlisten(folder, execute);\n\t}\n}\nmain();\n"],"mappings":";;;;;;AACA,SAAQ,oBAAmB;AAC3B,OAAO,aAAkC;AACzC,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,SAAQ,gBAAe;AACvB,SAAQ,eAAc;AAEtB,IAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AAEjC,SAAS,MAAM,KAAa;AAC3B,UAAQ,MAAM,GAAG;AACjB,UAAQ,KAAK,CAAC;AACf;AAEA,IAAI,oBAAoB;AACxB,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAM,UAAqC,CAAC;AAC5C,SAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACrC,QAAM,MAAM,KAAK,CAAC;AAClB,MAAI,IAAI,WAAW,IAAI,GAAG;AACzB,mBAAe,IAAI,UAAU,CAAC;AAAA,EAC/B,WAAW,IAAI,WAAW,GAAG,GAAG;AAC/B,mBAAe,IAAI,UAAU,CAAC;AAAA,EAC/B,OAAO;AACN,QAAI,cAAc;AACjB,UAAI,QAAQ,YAAY,GAAG;AAC1B,gBAAQ,YAAY,EAAE,KAAK,GAAG;AAAA,MAC/B,OAAO;AACN,gBAAQ,YAAY,IAAI,CAAC,GAAG;AAAA,MAC7B;AACA,qBAAe;AAAA,IAChB,OAAO;AACN,gBAAU;AACV,oBAAc,KAAK,MAAM,IAAI,CAAC;AAC9B;AAAA,IACD;AAAA,EACD;AACD;AAEA,IAAI,CAAC,SAAS;AACb,QAAM,0BAA0B;AACjC;AACA,IAAM,eAAe;AAErB,QA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I,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QACrF,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC9B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAExB,OAAO,CAAC,GAAG,CAAC,oBAAoB,MAAM,EAAE,CAAC,CAAC;YAC1C,OAAO,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAC;QACtD,CAAC;IACF,CAAC;SAAM,CAAC;QACP,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAC7C,OAAO,CAAC,GAAG,CAAC,gCAAgC,MAAM,EAAE,CAAC,CAAC;QACtD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzB,CAAC;AACF,CAAC;AACD,IAAI,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,34 +1,28 @@
1
1
  {
2
2
  "name": "as-soon",
3
- "version": "0.0.10",
3
+ "version": "0.1.0",
4
4
  "description": "watch and execute",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
8
  "type": "module",
9
- "main": "dist/index.cjs",
10
- "module": "dist/index.js",
11
- "types": "dist/index.d.ts",
9
+
12
10
  "bin": {
13
- "as-soon": "dist/cli.cjs"
11
+ "as-soon": "dist/cli.js"
14
12
  },
15
13
  "dependencies": {
16
- "@parcel/watcher": "^2.4.0",
17
- "ldenv": "^0.3.9",
18
- "lodash": "^4.17.21",
19
- "lodash-es": "^4.17.21"
14
+ "@parcel/watcher": "^2.5.4",
15
+ "ldenv": "^0.3.16",
16
+ "lodash": "^4.17.23"
20
17
  },
21
18
  "devDependencies": {
22
- "@types/lodash": "^4.14.202",
23
- "@types/lodash-es": "^4.17.12",
24
- "@types/node": "^20.11.16",
25
- "set-defaults": "^0.0.2",
26
- "tsup": "^8.0.1",
27
- "typescript": "^5.3.3"
19
+ "@types/lodash": "^4.17.23",
20
+ "@types/node": "^25.0.10",
21
+ "as-soon": "^0.0.11",
22
+ "typescript": "^5.9.3"
28
23
  },
29
24
  "scripts": {
30
- "prepare": "set-defaults .vscode",
31
- "build": "tsup --entry src/index.ts --entry src/cli.ts --dts --format esm,cjs",
32
- "dev": "tsup --entry src/index.ts --entry src/cli.ts --dts --watch --format esm,cjs"
25
+ "build": "tsc --project tsconfig.json",
26
+ "dev": "as-soon -w src pnpm build"
33
27
  }
34
28
  }
package/src/cli.ts CHANGED
@@ -93,30 +93,34 @@ async function listen(absolute_path: string, execute: () => void) {
93
93
  const exists = fs.existsSync(absolute_path);
94
94
 
95
95
  if (exists) {
96
- const isDirectory = exists && fs.statSync(absolute_path).isDirectory();
96
+ const isDirectory = fs.statSync(absolute_path).isDirectory();
97
97
  if (isDirectory) {
98
+ // console.log(`listen for folder changes...`);
98
99
  subscribe_folder(absolute_path, execute);
99
100
  } else {
101
+ // console.log(`listen for file changes...`);
100
102
  subscribe_folder(path.dirname(absolute_path), execute, absolute_path);
101
103
  }
102
104
  } else {
103
- console.log(`${absolute_path} do not exist yet, listening on parent`);
104
- let tmp_subscription: AsyncSubscription | undefined = await watcher.subscribe(
105
- path.dirname(absolute_path),
106
- (err, events) => {
107
- for (const event of events) {
108
- if (event.type === 'create' && path.normalize(event.path) === absolute_path) {
109
- // console.log(`${absolute_path} just got created, listening for it...`);
110
- tmp_subscription?.unsubscribe();
111
- tmp_subscription = undefined;
112
- // wrap in a timeout to ensure @parcel/watcher hook on the correct inode?
113
- setTimeout((v) => {
114
- listen(absolute_path, execute);
115
- }, 500);
116
- }
105
+ const parent = path.dirname(absolute_path);
106
+ if (!fs.existsSync(parent)) {
107
+ console.error(`cannot listen on folder who have no parent yet: ${absolute_path}`);
108
+ process.exit(1);
109
+ }
110
+ // console.log(`${absolute_path} do not exist yet, listening on parent : ${parent}`);
111
+ let tmp_subscription: AsyncSubscription | undefined = await watcher.subscribe(parent, (err, events) => {
112
+ for (const event of events) {
113
+ if (event.type === 'create' && path.normalize(event.path) === absolute_path) {
114
+ // console.log(`${absolute_path} just got created, listening for it...`);
115
+ tmp_subscription?.unsubscribe();
116
+ tmp_subscription = undefined;
117
+ // wrap in a timeout to ensure @parcel/watcher hook on the correct inode?
118
+ setTimeout(() => {
119
+ listen(absolute_path, execute);
120
+ }, 500);
117
121
  }
118
122
  }
119
- );
123
+ });
120
124
  }
121
125
  }
122
126
 
package/tsconfig.json CHANGED
@@ -1,13 +1,18 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "moduleResolution": "node",
4
- "lib": ["ES2020"],
5
- "target": "ES6",
3
+ "strict": true,
4
+ "strictNullChecks": true,
5
+ "target": "ESNext",
6
+ "module": "NodeNext",
7
+ "lib": ["ESNext", "dom"],
8
+ "moduleResolution": "NodeNext",
9
+ "resolveJsonModule": true,
10
+ "skipLibCheck": true,
11
+ "sourceMap": true,
6
12
  "declaration": true,
7
13
  "declarationMap": true,
8
- "sourceMap": true,
9
- "strict": true,
10
- "esModuleInterop": true,
11
- "skipLibCheck": true
12
- }
13
- }
14
+ "rootDir": "./src",
15
+ "outDir": "./dist"
16
+ },
17
+ "include": ["src/**/*.ts"]
18
+ }
@@ -1,25 +0,0 @@
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-AVQVENQ2.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/dist/cli.cjs DELETED
@@ -1,175 +0,0 @@
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_node_fs = __toESM(require("fs"), 1);
51
- var import_lodash = require("lodash");
52
- var import_ldenv = require("ldenv");
53
- var args = process.argv.slice(2);
54
- function error(msg) {
55
- console.error(msg);
56
- process.exit(1);
57
- }
58
- var deploymentContext = "localhost";
59
- var argToConsume;
60
- var command;
61
- var commandArgs;
62
- var options = {};
63
- for (let i = 0; i < args.length; i++) {
64
- const arg = args[i];
65
- if (arg.startsWith("--")) {
66
- argToConsume = arg.substring(2);
67
- } else if (arg.startsWith("-")) {
68
- argToConsume = arg.substring(1);
69
- } else {
70
- if (argToConsume) {
71
- if (options[argToConsume]) {
72
- options[argToConsume].push(arg);
73
- } else {
74
- options[argToConsume] = [arg];
75
- }
76
- argToConsume = void 0;
77
- } else {
78
- command = arg;
79
- commandArgs = args.slice(i + 1);
80
- break;
81
- }
82
- }
83
- }
84
- if (!command) {
85
- error(`please specify a command`);
86
- }
87
- var commandToUse = command;
88
- console.log(`"${commandToUse} ${(commandArgs == null ? void 0 : commandArgs.join(" ")) || ""}"`);
89
- (0, import_ldenv.loadEnv)({ mode: deploymentContext });
90
- function _execute() {
91
- try {
92
- (0, import_child_process.execFileSync)(commandToUse, commandArgs, { stdio: ["inherit", "inherit", "inherit"] });
93
- } catch (err) {
94
- console.error("failed to execue", err);
95
- }
96
- console.log(`-------------------------------------`);
97
- }
98
- function subscribe_folder(absolute_path, execute, filename) {
99
- return __async(this, null, function* () {
100
- const p = import_node_path.default.relative(process.cwd(), absolute_path) || ".";
101
- const subscription = yield import_watcher.default.subscribe(absolute_path, (err, events) => {
102
- if (filename) {
103
- for (const event of events) {
104
- if (import_node_path.default.normalize(event.path) === filename) {
105
- console.log(`"${import_node_path.default.basename(filename)}" changed under ${p}`);
106
- execute();
107
- } else if (event.type === "delete" && event.path === absolute_path) {
108
- subscription.unsubscribe();
109
- listen(filename, execute);
110
- return;
111
- }
112
- }
113
- } else {
114
- console.log(`Files changed under ${p}`);
115
- for (const event of events) {
116
- if (event.type === "delete" && event.path === absolute_path) {
117
- subscription.unsubscribe();
118
- listen(absolute_path, execute);
119
- return;
120
- }
121
- }
122
- execute();
123
- }
124
- });
125
- });
126
- }
127
- function listen(absolute_path, execute) {
128
- return __async(this, null, function* () {
129
- const exists = import_node_fs.default.existsSync(absolute_path);
130
- if (exists) {
131
- const isDirectory = exists && import_node_fs.default.statSync(absolute_path).isDirectory();
132
- if (isDirectory) {
133
- subscribe_folder(absolute_path, execute);
134
- } else {
135
- subscribe_folder(import_node_path.default.dirname(absolute_path), execute, absolute_path);
136
- }
137
- } else {
138
- console.log(`${absolute_path} do not exist yet, listening on parent`);
139
- let tmp_subscription = yield import_watcher.default.subscribe(
140
- import_node_path.default.dirname(absolute_path),
141
- (err, events) => {
142
- for (const event of events) {
143
- if (event.type === "create" && import_node_path.default.normalize(event.path) === absolute_path) {
144
- tmp_subscription == null ? void 0 : tmp_subscription.unsubscribe();
145
- tmp_subscription = void 0;
146
- setTimeout((v) => {
147
- listen(absolute_path, execute);
148
- }, 500);
149
- }
150
- }
151
- }
152
- );
153
- }
154
- });
155
- }
156
- function main() {
157
- return __async(this, null, function* () {
158
- const execute = (0, import_lodash.debounce)(_execute, 200);
159
- execute();
160
- if (options["w"]) {
161
- const folders = options["w"].map((p) => import_node_path.default.normalize(import_node_path.default.join(process.cwd(), p)));
162
- for (const folder of folders) {
163
- listen(folder, execute);
164
- console.log(`Now listening on ${folder}`);
165
- console.log(`-------------------------------------`);
166
- }
167
- } else {
168
- const folder = import_node_path.default.normalize(process.cwd());
169
- console.log(`listening on current folder: ${folder}`);
170
- listen(folder, execute);
171
- }
172
- });
173
- }
174
- main();
175
- //# sourceMappingURL=cli.cjs.map
package/dist/cli.cjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport {execFileSync} from 'child_process';\nimport watcher, {AsyncSubscription} from '@parcel/watcher';\nimport path from 'node:path';\nimport fs from 'node:fs';\nimport {debounce} from 'lodash';\nimport {loadEnv} from 'ldenv';\n\nconst args = process.argv.slice(2);\n\nfunction error(msg: string) {\n\tconsole.error(msg);\n\tprocess.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\tconst arg = args[i];\n\tif (arg.startsWith('--')) {\n\t\targToConsume = arg.substring(2);\n\t} else if (arg.startsWith('-')) {\n\t\targToConsume = arg.substring(1);\n\t} else {\n\t\tif (argToConsume) {\n\t\t\tif (options[argToConsume]) {\n\t\t\t\toptions[argToConsume].push(arg);\n\t\t\t} else {\n\t\t\t\toptions[argToConsume] = [arg];\n\t\t\t}\n\t\t\targToConsume = undefined;\n\t\t} else {\n\t\t\tcommand = arg;\n\t\t\tcommandArgs = args.slice(i + 1);\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nif (!command) {\n\terror(`please specify a command`);\n}\nconst commandToUse = command!;\n\nconsole.log(`\"${commandToUse} ${commandArgs?.join(' ') || ''}\"`);\n\nloadEnv({mode: deploymentContext});\n\nfunction _execute() {\n\ttry {\n\t\texecFileSync(commandToUse, commandArgs, {stdio: ['inherit', 'inherit', 'inherit']});\n\t} catch (err) {\n\t\tconsole.error('failed to execue', err);\n\t}\n\tconsole.log(`-------------------------------------`);\n}\n\n// let counter = 0;\nasync function subscribe_folder(absolute_path: string, execute: () => void, filename?: string) {\n\t// const c = ++counter;\n\tconst p = path.relative(process.cwd(), absolute_path) || '.';\n\tconst subscription = await watcher.subscribe(absolute_path, (err, events) => {\n\t\t// console.log(`Files changed under ${p} (${c})`);\n\t\tif (filename) {\n\t\t\tfor (const event of events) {\n\t\t\t\tif (path.normalize(event.path) === filename) {\n\t\t\t\t\tconsole.log(`\"${path.basename(filename)}\" changed under ${p}`);\n\t\t\t\t\texecute();\n\t\t\t\t} else if (event.type === 'delete' && event.path === absolute_path) {\n\t\t\t\t\tsubscription.unsubscribe();\n\t\t\t\t\tlisten(filename, execute);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconsole.log(`Files changed under ${p}`);\n\t\t\tfor (const event of events) {\n\t\t\t\tif (event.type === 'delete' && event.path === absolute_path) {\n\t\t\t\t\tsubscription.unsubscribe();\n\t\t\t\t\tlisten(absolute_path, execute);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\texecute();\n\t\t}\n\t});\n}\n\nasync function listen(absolute_path: string, execute: () => void) {\n\tconst exists = fs.existsSync(absolute_path);\n\n\tif (exists) {\n\t\tconst isDirectory = exists && fs.statSync(absolute_path).isDirectory();\n\t\tif (isDirectory) {\n\t\t\tsubscribe_folder(absolute_path, execute);\n\t\t} else {\n\t\t\tsubscribe_folder(path.dirname(absolute_path), execute, absolute_path);\n\t\t}\n\t} else {\n\t\tconsole.log(`${absolute_path} do not exist yet, listening on parent`);\n\t\tlet tmp_subscription: AsyncSubscription | undefined = await watcher.subscribe(\n\t\t\tpath.dirname(absolute_path),\n\t\t\t(err, events) => {\n\t\t\t\tfor (const event of events) {\n\t\t\t\t\tif (event.type === 'create' && path.normalize(event.path) === absolute_path) {\n\t\t\t\t\t\t// console.log(`${absolute_path} just got created, listening for it...`);\n\t\t\t\t\t\ttmp_subscription?.unsubscribe();\n\t\t\t\t\t\ttmp_subscription = undefined;\n\t\t\t\t\t\t// wrap in a timeout to ensure @parcel/watcher hook on the correct inode?\n\t\t\t\t\t\tsetTimeout((v) => {\n\t\t\t\t\t\t\tlisten(absolute_path, execute);\n\t\t\t\t\t\t}, 500);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n}\n\nasync function main() {\n\tconst execute = debounce(_execute, 200);\n\texecute();\n\tif (options['w']) {\n\t\tconst folders = options['w'].map((p) => path.normalize(path.join(process.cwd(), p)));\n\t\tfor (const folder of folders) {\n\t\t\tlisten(folder, execute);\n\n\t\t\tconsole.log(`Now listening on ${folder}`);\n\t\t\tconsole.log(`-------------------------------------`);\n\t\t}\n\t} else {\n\t\tconst folder = path.normalize(process.cwd());\n\t\tconsole.log(`listening on current folder: ${folder}`);\n\t\tlisten(folder, execute);\n\t}\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QAAQ,aAAa;AAAA,QAC1B,CAAC,KAAK,WAAW;AAChB,qBAAW,SAAS,QAAQ;AAC3B,gBAAI,MAAM,SAAS,YAAY,iBAAAA,QAAK,UAAU,MAAM,IAAI,MAAM,eAAe;AAE5E,mEAAkB;AAClB,iCAAmB;AAEnB,yBAAW,CAAC,MAAM;AACjB,uBAAO,eAAe,OAAO;AAAA,cAC9B,GAAG,GAAG;AAAA,YACP;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAAA;AAEA,SAAe,OAAO;AAAA;AACrB,UAAM,cAAU,wBAAS,UAAU,GAAG;AACtC,YAAQ;AACR,QAAI,QAAQ,GAAG,GAAG;AACjB,YAAM,UAAU,QAAQ,GAAG,EAAE,IAAI,CAAC,MAAM,iBAAAA,QAAK,UAAU,iBAAAA,QAAK,KAAK,QAAQ,IAAI,GAAG,CAAC,CAAC,CAAC;AACnF,iBAAW,UAAU,SAAS;AAC7B,eAAO,QAAQ,OAAO;AAEtB,gBAAQ,IAAI,oBAAoB,MAAM,EAAE;AACxC,gBAAQ,IAAI,uCAAuC;AAAA,MACpD;AAAA,IACD,OAAO;AACN,YAAM,SAAS,iBAAAA,QAAK,UAAU,QAAQ,IAAI,CAAC;AAC3C,cAAQ,IAAI,gCAAgC,MAAM,EAAE;AACpD,aAAO,QAAQ,OAAO;AAAA,IACvB;AAAA,EACD;AAAA;AACA,KAAK;","names":["path","watcher","fs"]}
package/dist/cli.d.cts DELETED
@@ -1 +0,0 @@
1
- #!/usr/bin/env node
package/dist/index.cjs DELETED
@@ -1,31 +0,0 @@
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
@@ -1 +0,0 @@
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.cts DELETED
@@ -1,3 +0,0 @@
1
- declare const nothing = 0;
2
-
3
- export { nothing };
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- declare const nothing = 0;
2
-
3
- export { nothing };
package/dist/index.js DELETED
@@ -1,8 +0,0 @@
1
- import "./chunk-AVQVENQ2.js";
2
-
3
- // src/index.ts
4
- var nothing = 0;
5
- export {
6
- nothing
7
- };
8
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export const nothing = 0;\n"],"mappings":";;;AAAO,IAAM,UAAU;","names":[]}
package/src/index.ts DELETED
@@ -1 +0,0 @@
1
- export const nothing = 0;
package/tsup.config.ts DELETED
@@ -1,5 +0,0 @@
1
- import {defineConfig} from 'tsup';
2
- export default defineConfig({
3
- outDir: 'dist',
4
- sourcemap: true,
5
- });