alex-c-line 1.3.7 → 1.4.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/index.cjs +64 -14
- package/dist/index.js +63 -13
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -60,17 +60,66 @@ var __async = (__this, __arguments, generator) => {
|
|
|
60
60
|
// src/index.ts
|
|
61
61
|
var import_commander = require("commander");
|
|
62
62
|
|
|
63
|
+
// src/commands/check-for-file-dependencies.ts
|
|
64
|
+
var import_promises = require("fs/promises");
|
|
65
|
+
var import_path = __toESM(require("path"), 1);
|
|
66
|
+
function findFileDependencies(dependencies) {
|
|
67
|
+
const fileDependencies = {};
|
|
68
|
+
if (!dependencies) {
|
|
69
|
+
return {};
|
|
70
|
+
}
|
|
71
|
+
for (const dependency in dependencies) {
|
|
72
|
+
if (dependencies[dependency].includes("file:")) {
|
|
73
|
+
fileDependencies[dependency] = dependencies[dependency];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return fileDependencies;
|
|
77
|
+
}
|
|
78
|
+
function checkForFileDependencies(program2) {
|
|
79
|
+
program2.command("check-for-file-dependencies").description(
|
|
80
|
+
"Check for existence of file dependencies in package.json and give exit code 1 if such dependencies are found"
|
|
81
|
+
).action(() => __async(null, null, function* () {
|
|
82
|
+
var _a, _b, _c;
|
|
83
|
+
console.log("Checking for file dependencies...");
|
|
84
|
+
const { dependencies, devDependencies, peerDependencies } = JSON.parse(
|
|
85
|
+
yield (0, import_promises.readFile)(import_path.default.resolve(process.cwd(), "package.json"), "utf-8")
|
|
86
|
+
);
|
|
87
|
+
const allFileDependencies = {
|
|
88
|
+
dependencies: findFileDependencies(dependencies),
|
|
89
|
+
devDependencies: findFileDependencies(devDependencies),
|
|
90
|
+
peerDependencies: findFileDependencies(peerDependencies)
|
|
91
|
+
};
|
|
92
|
+
if (Object.keys((_a = allFileDependencies.dependencies) != null ? _a : {}).length === 0) {
|
|
93
|
+
delete allFileDependencies.dependencies;
|
|
94
|
+
}
|
|
95
|
+
if (Object.keys((_b = allFileDependencies.devDependencies) != null ? _b : {}).length === 0) {
|
|
96
|
+
delete allFileDependencies.devDependencies;
|
|
97
|
+
}
|
|
98
|
+
if (Object.keys((_c = allFileDependencies.peerDependencies) != null ? _c : {}).length === 0) {
|
|
99
|
+
delete allFileDependencies.peerDependencies;
|
|
100
|
+
}
|
|
101
|
+
if (Object.keys(allFileDependencies).length !== 0) {
|
|
102
|
+
console.error("ERROR: File dependencies found:");
|
|
103
|
+
console.error(JSON.stringify(allFileDependencies, void 0, 2));
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
console.log("No file dependencies found!");
|
|
107
|
+
process.exit(0);
|
|
108
|
+
}));
|
|
109
|
+
}
|
|
110
|
+
var check_for_file_dependencies_default = checkForFileDependencies;
|
|
111
|
+
|
|
63
112
|
// src/commands/check-lockfile-version-discrepancy.ts
|
|
64
113
|
var import_fs = require("fs");
|
|
65
|
-
var
|
|
114
|
+
var import_path2 = __toESM(require("path"), 1);
|
|
66
115
|
function checkLockfileVersionDiscrepancy(program2) {
|
|
67
116
|
program2.command("check-lockfile-version-discrepancy").description("Check that version numbers in package.json and package-lock.json match").action(() => {
|
|
68
117
|
console.log("Checking for package.json and package-lock.json discrepancies...");
|
|
69
118
|
const { version: packageVersion } = JSON.parse(
|
|
70
|
-
(0, import_fs.readFileSync)(
|
|
119
|
+
(0, import_fs.readFileSync)(import_path2.default.resolve(process.cwd(), "package.json"), "utf-8")
|
|
71
120
|
);
|
|
72
121
|
const { version: packageLockVersion } = JSON.parse(
|
|
73
|
-
(0, import_fs.readFileSync)(
|
|
122
|
+
(0, import_fs.readFileSync)(import_path2.default.resolve(process.cwd(), "package-lock.json"), "utf-8")
|
|
74
123
|
);
|
|
75
124
|
if (packageVersion !== packageLockVersion) {
|
|
76
125
|
console.error(
|
|
@@ -85,8 +134,8 @@ function checkLockfileVersionDiscrepancy(program2) {
|
|
|
85
134
|
var check_lockfile_version_discrepancy_default = checkLockfileVersionDiscrepancy;
|
|
86
135
|
|
|
87
136
|
// src/commands/edit-env.ts
|
|
88
|
-
var
|
|
89
|
-
var
|
|
137
|
+
var import_promises2 = require("fs/promises");
|
|
138
|
+
var import_path3 = __toESM(require("path"), 1);
|
|
90
139
|
var import_dotenv = __toESM(require("dotenv"), 1);
|
|
91
140
|
var import_dotenv_stringify = __toESM(require("dotenv-stringify"), 1);
|
|
92
141
|
function editEnv(program2) {
|
|
@@ -98,7 +147,7 @@ function editEnv(program2) {
|
|
|
98
147
|
let currentEnvFileContents;
|
|
99
148
|
try {
|
|
100
149
|
currentEnvFileContents = import_dotenv.default.parse(
|
|
101
|
-
yield (0,
|
|
150
|
+
yield (0, import_promises2.readFile)(import_path3.default.join(process.cwd(), file), "utf-8")
|
|
102
151
|
);
|
|
103
152
|
} catch (e) {
|
|
104
153
|
currentEnvFileContents = {};
|
|
@@ -108,8 +157,8 @@ function editEnv(program2) {
|
|
|
108
157
|
} else {
|
|
109
158
|
delete currentEnvFileContents[key];
|
|
110
159
|
}
|
|
111
|
-
yield (0,
|
|
112
|
-
|
|
160
|
+
yield (0, import_promises2.writeFile)(
|
|
161
|
+
import_path3.default.join(process.cwd(), file),
|
|
113
162
|
(0, import_dotenv_stringify.default)(currentEnvFileContents) + "\n"
|
|
114
163
|
);
|
|
115
164
|
console.log(".env file updated");
|
|
@@ -118,9 +167,9 @@ function editEnv(program2) {
|
|
|
118
167
|
var edit_env_default = editEnv;
|
|
119
168
|
|
|
120
169
|
// src/commands/git-post-merge-cleanup.ts
|
|
121
|
-
var
|
|
170
|
+
var import_promises3 = require("fs/promises");
|
|
122
171
|
var import_os = __toESM(require("os"), 1);
|
|
123
|
-
var
|
|
172
|
+
var import_path4 = __toESM(require("path"), 1);
|
|
124
173
|
var import_execa2 = require("execa");
|
|
125
174
|
|
|
126
175
|
// src/utils/execa-helpers.ts
|
|
@@ -137,8 +186,8 @@ function gitPostMergeCleanup(program2) {
|
|
|
137
186
|
var _a, _b, _c;
|
|
138
187
|
let alexCLineConfigJSON;
|
|
139
188
|
try {
|
|
140
|
-
alexCLineConfigJSON = yield (0,
|
|
141
|
-
|
|
189
|
+
alexCLineConfigJSON = yield (0, import_promises3.readFile)(
|
|
190
|
+
import_path4.default.join((_a = process.env.HOME) != null ? _a : import_os.default.homedir(), "alex-c-line-config.json"),
|
|
142
191
|
"utf-8"
|
|
143
192
|
);
|
|
144
193
|
} catch (e) {
|
|
@@ -200,10 +249,11 @@ var say_hello_default = sayHello;
|
|
|
200
249
|
|
|
201
250
|
// src/commands/index.ts
|
|
202
251
|
function loadCommands(program2) {
|
|
203
|
-
say_hello_default(program2);
|
|
204
252
|
check_lockfile_version_discrepancy_default(program2);
|
|
205
|
-
|
|
253
|
+
check_for_file_dependencies_default(program2);
|
|
206
254
|
edit_env_default(program2);
|
|
255
|
+
git_post_merge_cleanup_default(program2);
|
|
256
|
+
say_hello_default(program2);
|
|
207
257
|
}
|
|
208
258
|
var commands_default = loadCommands;
|
|
209
259
|
|
package/dist/index.js
CHANGED
|
@@ -39,17 +39,66 @@ var __async = (__this, __arguments, generator) => {
|
|
|
39
39
|
// src/index.ts
|
|
40
40
|
import { Command } from "commander";
|
|
41
41
|
|
|
42
|
+
// src/commands/check-for-file-dependencies.ts
|
|
43
|
+
import { readFile } from "fs/promises";
|
|
44
|
+
import path from "path";
|
|
45
|
+
function findFileDependencies(dependencies) {
|
|
46
|
+
const fileDependencies = {};
|
|
47
|
+
if (!dependencies) {
|
|
48
|
+
return {};
|
|
49
|
+
}
|
|
50
|
+
for (const dependency in dependencies) {
|
|
51
|
+
if (dependencies[dependency].includes("file:")) {
|
|
52
|
+
fileDependencies[dependency] = dependencies[dependency];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return fileDependencies;
|
|
56
|
+
}
|
|
57
|
+
function checkForFileDependencies(program2) {
|
|
58
|
+
program2.command("check-for-file-dependencies").description(
|
|
59
|
+
"Check for existence of file dependencies in package.json and give exit code 1 if such dependencies are found"
|
|
60
|
+
).action(() => __async(null, null, function* () {
|
|
61
|
+
var _a, _b, _c;
|
|
62
|
+
console.log("Checking for file dependencies...");
|
|
63
|
+
const { dependencies, devDependencies, peerDependencies } = JSON.parse(
|
|
64
|
+
yield readFile(path.resolve(process.cwd(), "package.json"), "utf-8")
|
|
65
|
+
);
|
|
66
|
+
const allFileDependencies = {
|
|
67
|
+
dependencies: findFileDependencies(dependencies),
|
|
68
|
+
devDependencies: findFileDependencies(devDependencies),
|
|
69
|
+
peerDependencies: findFileDependencies(peerDependencies)
|
|
70
|
+
};
|
|
71
|
+
if (Object.keys((_a = allFileDependencies.dependencies) != null ? _a : {}).length === 0) {
|
|
72
|
+
delete allFileDependencies.dependencies;
|
|
73
|
+
}
|
|
74
|
+
if (Object.keys((_b = allFileDependencies.devDependencies) != null ? _b : {}).length === 0) {
|
|
75
|
+
delete allFileDependencies.devDependencies;
|
|
76
|
+
}
|
|
77
|
+
if (Object.keys((_c = allFileDependencies.peerDependencies) != null ? _c : {}).length === 0) {
|
|
78
|
+
delete allFileDependencies.peerDependencies;
|
|
79
|
+
}
|
|
80
|
+
if (Object.keys(allFileDependencies).length !== 0) {
|
|
81
|
+
console.error("ERROR: File dependencies found:");
|
|
82
|
+
console.error(JSON.stringify(allFileDependencies, void 0, 2));
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
console.log("No file dependencies found!");
|
|
86
|
+
process.exit(0);
|
|
87
|
+
}));
|
|
88
|
+
}
|
|
89
|
+
var check_for_file_dependencies_default = checkForFileDependencies;
|
|
90
|
+
|
|
42
91
|
// src/commands/check-lockfile-version-discrepancy.ts
|
|
43
92
|
import { readFileSync } from "fs";
|
|
44
|
-
import
|
|
93
|
+
import path2 from "path";
|
|
45
94
|
function checkLockfileVersionDiscrepancy(program2) {
|
|
46
95
|
program2.command("check-lockfile-version-discrepancy").description("Check that version numbers in package.json and package-lock.json match").action(() => {
|
|
47
96
|
console.log("Checking for package.json and package-lock.json discrepancies...");
|
|
48
97
|
const { version: packageVersion } = JSON.parse(
|
|
49
|
-
readFileSync(
|
|
98
|
+
readFileSync(path2.resolve(process.cwd(), "package.json"), "utf-8")
|
|
50
99
|
);
|
|
51
100
|
const { version: packageLockVersion } = JSON.parse(
|
|
52
|
-
readFileSync(
|
|
101
|
+
readFileSync(path2.resolve(process.cwd(), "package-lock.json"), "utf-8")
|
|
53
102
|
);
|
|
54
103
|
if (packageVersion !== packageLockVersion) {
|
|
55
104
|
console.error(
|
|
@@ -64,8 +113,8 @@ function checkLockfileVersionDiscrepancy(program2) {
|
|
|
64
113
|
var check_lockfile_version_discrepancy_default = checkLockfileVersionDiscrepancy;
|
|
65
114
|
|
|
66
115
|
// src/commands/edit-env.ts
|
|
67
|
-
import { readFile, writeFile } from "fs/promises";
|
|
68
|
-
import
|
|
116
|
+
import { readFile as readFile2, writeFile } from "fs/promises";
|
|
117
|
+
import path3 from "path";
|
|
69
118
|
import dotenv from "dotenv";
|
|
70
119
|
import dotenvStringify from "dotenv-stringify";
|
|
71
120
|
function editEnv(program2) {
|
|
@@ -77,7 +126,7 @@ function editEnv(program2) {
|
|
|
77
126
|
let currentEnvFileContents;
|
|
78
127
|
try {
|
|
79
128
|
currentEnvFileContents = dotenv.parse(
|
|
80
|
-
yield
|
|
129
|
+
yield readFile2(path3.join(process.cwd(), file), "utf-8")
|
|
81
130
|
);
|
|
82
131
|
} catch (e) {
|
|
83
132
|
currentEnvFileContents = {};
|
|
@@ -88,7 +137,7 @@ function editEnv(program2) {
|
|
|
88
137
|
delete currentEnvFileContents[key];
|
|
89
138
|
}
|
|
90
139
|
yield writeFile(
|
|
91
|
-
|
|
140
|
+
path3.join(process.cwd(), file),
|
|
92
141
|
dotenvStringify(currentEnvFileContents) + "\n"
|
|
93
142
|
);
|
|
94
143
|
console.log(".env file updated");
|
|
@@ -97,9 +146,9 @@ function editEnv(program2) {
|
|
|
97
146
|
var edit_env_default = editEnv;
|
|
98
147
|
|
|
99
148
|
// src/commands/git-post-merge-cleanup.ts
|
|
100
|
-
import { readFile as
|
|
149
|
+
import { readFile as readFile3 } from "fs/promises";
|
|
101
150
|
import os from "os";
|
|
102
|
-
import
|
|
151
|
+
import path4 from "path";
|
|
103
152
|
import { execa as execa2, ExecaError } from "execa";
|
|
104
153
|
|
|
105
154
|
// src/utils/execa-helpers.ts
|
|
@@ -116,8 +165,8 @@ function gitPostMergeCleanup(program2) {
|
|
|
116
165
|
var _a, _b, _c;
|
|
117
166
|
let alexCLineConfigJSON;
|
|
118
167
|
try {
|
|
119
|
-
alexCLineConfigJSON = yield
|
|
120
|
-
|
|
168
|
+
alexCLineConfigJSON = yield readFile3(
|
|
169
|
+
path4.join((_a = process.env.HOME) != null ? _a : os.homedir(), "alex-c-line-config.json"),
|
|
121
170
|
"utf-8"
|
|
122
171
|
);
|
|
123
172
|
} catch (e) {
|
|
@@ -179,10 +228,11 @@ var say_hello_default = sayHello;
|
|
|
179
228
|
|
|
180
229
|
// src/commands/index.ts
|
|
181
230
|
function loadCommands(program2) {
|
|
182
|
-
say_hello_default(program2);
|
|
183
231
|
check_lockfile_version_discrepancy_default(program2);
|
|
184
|
-
|
|
232
|
+
check_for_file_dependencies_default(program2);
|
|
185
233
|
edit_env_default(program2);
|
|
234
|
+
git_post_merge_cleanup_default(program2);
|
|
235
|
+
say_hello_default(program2);
|
|
186
236
|
}
|
|
187
237
|
var commands_default = loadCommands;
|
|
188
238
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alex-c-line",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
"scripts": {
|
|
14
14
|
"test": "vitest run",
|
|
15
15
|
"test-watch": "vitest",
|
|
16
|
-
"format": "prettier --write --parser typescript
|
|
17
|
-
"lint": "
|
|
16
|
+
"format": "prettier --write --parser typescript \"src/**/*.ts\" \"tests/**/*.ts\" && eslint --fix --suppress-all \"src/**/*.ts\" \"tests/**/*.ts\" && rm -f eslint-suppressions.json",
|
|
17
|
+
"lint": "tsc --noEmit && eslint \"src/**/*.ts\" \"tests/**/*.ts\" && prettier --check --parser typescript \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
18
18
|
"build": "tsup",
|
|
19
19
|
"command": "npm run build && echo && echo \"Command output:\" && npx alex-c-line",
|
|
20
20
|
"prepare": "husky",
|
|
21
|
-
"update-dependencies": "npx npm-check-updates -u && npm install",
|
|
21
|
+
"update-dependencies": "bash -c 'npx npm-check-updates -u \"$@\" && npm install' --",
|
|
22
22
|
"change-major": "npm version major -m \"Change version number to v%s\"",
|
|
23
23
|
"change-minor": "npm version minor -m \"Change version number to v%s\"",
|
|
24
24
|
"change-patch": "npm version patch -m \"Change version number to v%s\""
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"execa": "^9.6.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@alextheman/eslint-plugin": "^1.
|
|
37
|
+
"@alextheman/eslint-plugin": "^1.8.2",
|
|
38
38
|
"@types/eslint": "^9.6.1",
|
|
39
39
|
"@types/node": "^24.3.0",
|
|
40
40
|
"eslint": "^9.34.0",
|