@driftdev/cli 0.35.0 → 0.36.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/drift.js +7 -5
- package/package.json +7 -11
- package/dist/config/index.d.ts +0 -9
- package/dist/config/index.js +0 -108
package/dist/drift.js
CHANGED
|
@@ -178097,7 +178097,7 @@ function generateConfig(packages) {
|
|
|
178097
178097
|
};
|
|
178098
178098
|
}
|
|
178099
178099
|
function registerInitCommand(program) {
|
|
178100
|
-
program.command("init").description("Scan project, generate global drift config").action(async () => {
|
|
178100
|
+
program.command("init").description("Scan project, generate global drift config").option("--project", "Write to drift.config.json in cwd instead of global config").action(async (opts) => {
|
|
178101
178101
|
const startTime = Date.now();
|
|
178102
178102
|
const version = getVersion14();
|
|
178103
178103
|
const cwd = process.cwd();
|
|
@@ -178116,10 +178116,12 @@ function registerInitCommand(program) {
|
|
|
178116
178116
|
return;
|
|
178117
178117
|
}
|
|
178118
178118
|
const config = generateConfig(packages);
|
|
178119
|
-
const
|
|
178120
|
-
if (!
|
|
178121
|
-
|
|
178122
|
-
|
|
178119
|
+
const configPath = opts.project ? path33.resolve(cwd, "drift.config.json") : getGlobalConfigPath();
|
|
178120
|
+
if (!opts.project) {
|
|
178121
|
+
const globalDir = getGlobalDir();
|
|
178122
|
+
if (!existsSync19(globalDir))
|
|
178123
|
+
mkdirSync7(globalDir, { recursive: true });
|
|
178124
|
+
}
|
|
178123
178125
|
writeFileSync7(configPath, JSON.stringify(config, null, 2) + `
|
|
178124
178126
|
`);
|
|
178125
178127
|
ensureProjectDir(cwd);
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@driftdev/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.36.0",
|
|
4
|
+
"description": "Drift CLI - Documentation coverage and drift detection for TypeScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
7
7
|
"cli",
|
|
8
8
|
"documentation",
|
|
9
|
-
"
|
|
9
|
+
"drift",
|
|
10
10
|
"docs-coverage",
|
|
11
11
|
"drift-detection"
|
|
12
12
|
],
|
|
13
|
-
"homepage": "https://github.com/
|
|
13
|
+
"homepage": "https://github.com/driftdev/drift#readme",
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
|
-
"url": "git+https://github.com/
|
|
16
|
+
"url": "git+https://github.com/driftdev/drift.git",
|
|
17
17
|
"directory": "packages/cli"
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
@@ -28,10 +28,6 @@
|
|
|
28
28
|
".": {
|
|
29
29
|
"import": "./dist/index.js",
|
|
30
30
|
"types": "./dist/index.d.ts"
|
|
31
|
-
},
|
|
32
|
-
"./config": {
|
|
33
|
-
"import": "./dist/config/index.js",
|
|
34
|
-
"types": "./dist/config/index.d.ts"
|
|
35
31
|
}
|
|
36
32
|
},
|
|
37
33
|
"scripts": {
|
|
@@ -47,8 +43,8 @@
|
|
|
47
43
|
"dist"
|
|
48
44
|
],
|
|
49
45
|
"dependencies": {
|
|
50
|
-
"@driftdev/sdk": "^0.
|
|
51
|
-
"@driftdev/spec": "^0.
|
|
46
|
+
"@driftdev/sdk": "^0.36.0",
|
|
47
|
+
"@driftdev/spec": "^0.36.0",
|
|
52
48
|
"@openpkg-ts/spec": "^0.37.0",
|
|
53
49
|
"chalk": "^5.4.1",
|
|
54
50
|
"commander": "^14.0.0"
|
package/dist/config/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { DocCovConfig as DocCovConfig2, DocCovConfigInput, DocsConfig } from "@driftdev/sdk";
|
|
2
|
-
import { DocCovConfig } from "@driftdev/sdk";
|
|
3
|
-
declare const DRIFT_CONFIG_FILENAMES: readonly ["drift.config.ts", "drift.config.mts", "drift.config.js", "drift.config.mjs"];
|
|
4
|
-
interface LoadedDriftTsConfig extends DocCovConfig {
|
|
5
|
-
filePath: string;
|
|
6
|
-
}
|
|
7
|
-
declare const loadDriftTsConfig: (cwd: string) => Promise<LoadedDriftTsConfig | null>;
|
|
8
|
-
declare const defineConfig: (config: DocCovConfigInput) => DocCovConfigInput;
|
|
9
|
-
export { loadDriftTsConfig, defineConfig, LoadedDriftTsConfig, DocsConfig, DocCovConfigInput, DocCovConfig2 as DocCovConfig, DRIFT_CONFIG_FILENAMES };
|
package/dist/config/index.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
-
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
-
for (let key of __getOwnPropNames(mod))
|
|
11
|
-
if (!__hasOwnProp.call(to, key))
|
|
12
|
-
__defProp(to, key, {
|
|
13
|
-
get: () => mod[key],
|
|
14
|
-
enumerable: true
|
|
15
|
-
});
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
19
|
-
var __export = (target, all) => {
|
|
20
|
-
for (var name in all)
|
|
21
|
-
__defProp(target, name, {
|
|
22
|
-
get: all[name],
|
|
23
|
-
enumerable: true,
|
|
24
|
-
configurable: true,
|
|
25
|
-
set: (newValue) => all[name] = () => newValue
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
29
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
30
|
-
|
|
31
|
-
// src/config/drift-ts-config.ts
|
|
32
|
-
import { access } from "node:fs/promises";
|
|
33
|
-
import path from "node:path";
|
|
34
|
-
import { pathToFileURL } from "node:url";
|
|
35
|
-
import { docCovConfigSchema, normalizeConfig } from "@driftdev/sdk";
|
|
36
|
-
var DRIFT_CONFIG_FILENAMES = [
|
|
37
|
-
"drift.config.ts",
|
|
38
|
-
"drift.config.mts",
|
|
39
|
-
"drift.config.js",
|
|
40
|
-
"drift.config.mjs"
|
|
41
|
-
];
|
|
42
|
-
var fileExists = async (filePath) => {
|
|
43
|
-
try {
|
|
44
|
-
await access(filePath);
|
|
45
|
-
return true;
|
|
46
|
-
} catch {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
var findConfigFile = async (cwd) => {
|
|
51
|
-
let current = path.resolve(cwd);
|
|
52
|
-
const { root } = path.parse(current);
|
|
53
|
-
while (true) {
|
|
54
|
-
for (const candidate of DRIFT_CONFIG_FILENAMES) {
|
|
55
|
-
const candidatePath = path.join(current, candidate);
|
|
56
|
-
if (await fileExists(candidatePath)) {
|
|
57
|
-
return candidatePath;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
if (current === root) {
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
current = path.dirname(current);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
var importConfigModule = async (absolutePath) => {
|
|
67
|
-
const fileUrl = pathToFileURL(absolutePath);
|
|
68
|
-
fileUrl.searchParams.set("t", Date.now().toString());
|
|
69
|
-
const module = await import(fileUrl.href);
|
|
70
|
-
return module?.default ?? module?.config ?? module;
|
|
71
|
-
};
|
|
72
|
-
var formatIssues = (issues) => issues.map((issue) => `- ${issue}`).join(`
|
|
73
|
-
`);
|
|
74
|
-
var loadDriftTsConfig = async (cwd) => {
|
|
75
|
-
const configPath = await findConfigFile(cwd);
|
|
76
|
-
if (!configPath) {
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
let rawConfig;
|
|
80
|
-
try {
|
|
81
|
-
rawConfig = await importConfigModule(configPath);
|
|
82
|
-
} catch (error) {
|
|
83
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
84
|
-
throw new Error(`Failed to load drift config at ${configPath}: ${message}`);
|
|
85
|
-
}
|
|
86
|
-
const parsed = docCovConfigSchema.safeParse(rawConfig);
|
|
87
|
-
if (!parsed.success) {
|
|
88
|
-
const issues = parsed.error.issues.map((issue) => {
|
|
89
|
-
const pathLabel = issue.path.length > 0 ? issue.path.join(".") : "(root)";
|
|
90
|
-
return `${pathLabel}: ${issue.message}`;
|
|
91
|
-
});
|
|
92
|
-
throw new Error(`Invalid drift configuration at ${configPath}.
|
|
93
|
-
${formatIssues(issues)}`);
|
|
94
|
-
}
|
|
95
|
-
const normalized = normalizeConfig(parsed.data);
|
|
96
|
-
return {
|
|
97
|
-
filePath: configPath,
|
|
98
|
-
...normalized
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
// src/config/index.ts
|
|
103
|
-
var defineConfig = (config) => config;
|
|
104
|
-
export {
|
|
105
|
-
loadDriftTsConfig,
|
|
106
|
-
defineConfig,
|
|
107
|
-
DRIFT_CONFIG_FILENAMES
|
|
108
|
-
};
|