@codefast/cli 0.8.1 → 0.10.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/CHANGELOG.md +596 -0
- package/LICENSE +1 -1
- package/README.md +335 -129
- package/dist/arrange/analyze.d.ts +10 -0
- package/dist/arrange/cli-schema.d.ts +50 -0
- package/dist/arrange/command.d.ts +7 -0
- package/dist/arrange/domain/analyze-service.d.ts +18 -0
- package/dist/arrange/domain/ast/ast-node.d.ts +394 -0
- package/dist/arrange/domain/ast/collectors-cn.d.ts +26 -0
- package/dist/arrange/domain/ast/collectors-jsx.d.ts +8 -0
- package/dist/arrange/domain/ast/collectors-tv.d.ts +34 -0
- package/dist/arrange/domain/ast/helpers.d.ts +36 -0
- package/dist/arrange/domain/ast/helpers.js +1 -0
- package/dist/arrange/domain/ast/simplify-targets.d.ts +22 -0
- package/dist/arrange/domain/ast/targets.d.ts +20 -0
- package/dist/arrange/domain/constants.d.ts +111 -0
- package/dist/arrange/domain/grouping-service.d.ts +100 -0
- package/dist/arrange/domain/grouping.d.ts +21 -0
- package/dist/arrange/domain/imports.d.ts +14 -0
- package/dist/arrange/domain/source-text-formatters.d.ts +33 -0
- package/dist/arrange/domain/tailwind-token.d.ts +24 -0
- package/dist/arrange/domain/token-classifier.d.ts +47 -0
- package/dist/arrange/domain/types.d.ts +208 -0
- package/dist/arrange/output.d.ts +26 -0
- package/dist/arrange/process-file.d.ts +11 -0
- package/dist/arrange/resolve-target.d.ts +10 -0
- package/dist/arrange/resolve-target.js +3 -16
- package/dist/arrange/scan-target.d.ts +7 -0
- package/dist/arrange/simplify-process-file.d.ts +11 -0
- package/dist/arrange/simplify-sync.d.ts +13 -0
- package/dist/arrange/source-parse.d.ts +7 -0
- package/dist/arrange/suggest.d.ts +8 -0
- package/dist/arrange/sync.d.ts +11 -0
- package/dist/arrange/typescript-ast-translator.d.ts +31 -0
- package/dist/arrange/workspace.d.ts +13 -0
- package/dist/arrange/workspace.js +2 -2
- package/dist/audit/cli-schema.d.ts +93 -0
- package/dist/audit/cli-schema.js +14 -3
- package/dist/audit/command.d.ts +8 -0
- package/dist/audit/command.js +52 -12
- package/dist/audit/domain/audit-file.d.ts +7 -0
- package/dist/audit/domain/comment-content.d.ts +26 -0
- package/dist/audit/domain/comment-dividers.d.ts +62 -0
- package/dist/audit/domain/comment-dividers.js +48 -20
- package/dist/audit/domain/display-names.d.ts +11 -0
- package/dist/audit/domain/display-names.js +71 -0
- package/dist/audit/domain/import-policy.d.ts +34 -0
- package/dist/audit/domain/import-policy.js +147 -0
- package/dist/audit/domain/link-references.d.ts +40 -0
- package/dist/audit/domain/mappings.d.ts +45 -0
- package/dist/audit/domain/markdown-links.d.ts +44 -0
- package/dist/audit/domain/since-versions.d.ts +26 -0
- package/dist/audit/domain/tokenize.d.ts +14 -0
- package/dist/audit/domain/tsdoc-syntax.d.ts +20 -0
- package/dist/audit/domain/types.d.ts +171 -0
- package/dist/audit/output.d.ts +91 -0
- package/dist/audit/output.js +52 -11
- package/dist/audit/prepare.d.ts +70 -0
- package/dist/audit/prepare.js +41 -10
- package/dist/audit/run-comments.d.ts +17 -0
- package/dist/audit/run-comments.js +22 -18
- package/dist/audit/run-display-names.d.ts +14 -0
- package/dist/audit/run-display-names.js +60 -0
- package/dist/audit/run-imports.d.ts +14 -0
- package/dist/audit/{run-react.js → run-imports.js} +15 -5
- package/dist/audit/run-links.d.ts +14 -0
- package/dist/audit/run.d.ts +14 -0
- package/dist/bin.d.ts +2 -0
- package/dist/cli.d.ts +6 -0
- package/dist/core/cli/format-error.d.ts +7 -0
- package/dist/core/cli/global-options.d.ts +15 -0
- package/dist/core/cli/positional.d.ts +6 -0
- package/dist/core/cli/result-handle.d.ts +19 -0
- package/dist/core/config/define-config.d.ts +7 -0
- package/dist/core/config/define-config.js +8 -0
- package/dist/core/config/loader.d.ts +18 -0
- package/dist/core/config/loader.js +2 -7
- package/dist/core/config/schema.d.ts +99 -0
- package/dist/core/config/schema.js +7 -75
- package/dist/core/config/warnings.d.ts +6 -0
- package/dist/core/config.d.ts +12 -0
- package/dist/core/errors.d.ts +25 -0
- package/dist/core/exit-codes.d.ts +18 -0
- package/dist/core/filesystem/node.d.ts +7 -0
- package/dist/core/filesystem/node.js +1 -0
- package/dist/core/filesystem/port.d.ts +44 -0
- package/dist/core/glob.d.ts +19 -0
- package/dist/core/logger.d.ts +9 -0
- package/dist/core/result.d.ts +30 -0
- package/dist/core/schema-parse.d.ts +9 -0
- package/dist/core/source-text-edit.d.ts +33 -0
- package/dist/core/verbose-diagnostics.d.ts +6 -0
- package/dist/core/workspace/ancestor-directories.d.ts +12 -0
- package/dist/core/workspace/ancestor-directories.js +30 -0
- package/dist/core/workspace/markdown-walk.d.ts +7 -0
- package/dist/core/workspace/markdown-walk.js +2 -20
- package/dist/core/workspace/package-version.d.ts +9 -0
- package/dist/core/workspace/package-version.js +8 -12
- package/dist/core/workspace/resolver.d.ts +39 -0
- package/dist/core/workspace/resolver.js +58 -75
- package/dist/core/workspace/skip-directories.d.ts +6 -0
- package/dist/core/workspace/source-walk.d.ts +16 -0
- package/dist/core/workspace/source-walk.js +14 -20
- package/dist/core/workspace/typescript-walk.d.ts +7 -0
- package/dist/core/workspace/typescript-walk.js +2 -23
- package/dist/core/workspace/walk-files.d.ts +7 -0
- package/dist/core/workspace/walk-files.js +27 -0
- package/dist/core/workspace/well-known-files.d.ts +18 -0
- package/dist/core/workspace/well-known-files.js +18 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +5 -0
- package/dist/mirror/cli-result.d.ts +13 -0
- package/dist/mirror/cli-schema.d.ts +8 -0
- package/dist/mirror/command.d.ts +7 -0
- package/dist/mirror/dist-filesystem-impl.d.ts +8 -0
- package/dist/mirror/domain/constants.d.ts +18 -0
- package/dist/mirror/domain/constants.js +0 -12
- package/dist/mirror/domain/dirent-guard.d.ts +10 -0
- package/dist/mirror/domain/dist-filesystem.d.ts +9 -0
- package/dist/mirror/domain/errors.d.ts +24 -0
- package/dist/mirror/domain/exports.d.ts +36 -0
- package/dist/mirror/domain/package-display-name.d.ts +8 -0
- package/dist/mirror/domain/path-normalizer.d.ts +6 -0
- package/dist/mirror/domain/types.d.ts +131 -0
- package/dist/mirror/output.d.ts +23 -0
- package/dist/mirror/package-path.d.ts +19 -0
- package/dist/mirror/prepare.d.ts +15 -0
- package/dist/mirror/prepare.js +2 -2
- package/dist/mirror/supplement-exports.d.ts +27 -0
- package/dist/mirror/supplement-exports.js +2 -2
- package/dist/mirror/sync-reporter.d.ts +60 -0
- package/dist/mirror/sync-reporter.js +4 -0
- package/dist/mirror/sync-types.d.ts +43 -0
- package/dist/mirror/sync-workspace-package.d.ts +9 -0
- package/dist/mirror/sync-workspace-package.js +3 -3
- package/dist/mirror/sync.d.ts +12 -0
- package/dist/mirror/sync.js +5 -3
- package/dist/mirror/write-exports.d.ts +15 -0
- package/dist/pack-slim/cli-result.d.ts +13 -0
- package/dist/pack-slim/cli-schema.d.ts +17 -0
- package/dist/pack-slim/command.d.ts +7 -0
- package/dist/pack-slim/command.js +5 -4
- package/dist/pack-slim/domain/transform.d.ts +69 -0
- package/dist/pack-slim/domain/transform.js +141 -15
- package/dist/pack-slim/domain/types.d.ts +46 -0
- package/dist/pack-slim/output.d.ts +15 -0
- package/dist/pack-slim/output.js +10 -1
- package/dist/pack-slim/sync.d.ts +23 -0
- package/dist/pack-slim/sync.js +14 -8
- package/dist/pack-slim/working-tree.d.ts +20 -0
- package/dist/tag/cli-result.d.ts +7 -0
- package/dist/tag/cli-schema.d.ts +8 -0
- package/dist/tag/command.d.ts +7 -0
- package/dist/tag/domain/types.d.ts +111 -0
- package/dist/tag/output.d.ts +17 -0
- package/dist/tag/prepare.d.ts +13 -0
- package/dist/tag/prepare.js +2 -2
- package/dist/tag/resolve-target-path.d.ts +10 -0
- package/dist/tag/since-writer.d.ts +32 -0
- package/dist/tag/sync.d.ts +42 -0
- package/dist/tag/target-candidates.d.ts +8 -0
- package/dist/tag/target-candidates.js +1 -1
- package/dist/tag/target-runner.d.ts +8 -0
- package/dist/tag/version-resolver.d.ts +7 -0
- package/package.json +16 -33
- package/dist/audit/domain/react-imports.js +0 -91
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FilesystemPort } from "#/core/filesystem/port";
|
|
2
|
+
import type { TagTargetCandidate } from "#/tag/domain/types";
|
|
3
|
+
/**
|
|
4
|
+
* Resolves the candidate targets for a tag run: the explicit target, or the discovered workspace packages.
|
|
5
|
+
*
|
|
6
|
+
* @since 0.3.16-canary.0
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolveTagTargetCandidates(fs: FilesystemPort, rootDir: string, explicitTarget: string | undefined): Promise<Array<TagTargetCandidate>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { listWorkspacePackageDirectories } from "#/core/workspace/resolver";
|
|
4
|
-
|
|
4
|
+
import { packageJsonFileName } from "#/core/workspace/well-known-files";
|
|
5
5
|
const packageJsonNameSchema = z.looseObject({
|
|
6
6
|
name: z.string().min(1).optional(),
|
|
7
7
|
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FilesystemPort } from "#/core/filesystem/port";
|
|
2
|
+
import type { TagRunOptions, TagRunResult } from "#/tag/domain/types";
|
|
3
|
+
/**
|
|
4
|
+
* Stamps `@since` tags across one target's TypeScript files and returns the run result.
|
|
5
|
+
*
|
|
6
|
+
* @since 0.3.16-canary.0
|
|
7
|
+
*/
|
|
8
|
+
export declare function runTagOnTarget(fs: FilesystemPort, targetPath: string, opts: TagRunOptions): TagRunResult;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FilesystemPort } from "#/core/filesystem/port";
|
|
2
|
+
/**
|
|
3
|
+
* Returns the `version` of the nearest enclosing `package.json` above a target path.
|
|
4
|
+
*
|
|
5
|
+
* @since 0.3.16-canary.0
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveNearestPackageVersion(fs: FilesystemPort, targetPath: string): string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codefast/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Developer CLI for the Codefast monorepo (arrange, audit, mirror, tag)",
|
|
3
|
+
"version": "0.10.0",
|
|
4
|
+
"description": "Developer CLI for the Codefast monorepo (arrange, audit, mirror, pack-slim, tag)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
7
7
|
"codefast",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"url": "https://github.com/codefastlabs/codefast/issues"
|
|
16
16
|
},
|
|
17
17
|
"license": "MIT",
|
|
18
|
-
"author": "Vuong Phan <mr.thevuong@gmail.com>",
|
|
18
|
+
"author": "Vuong Phan <mr.thevuong@gmail.com> (https://github.com/thevuong)",
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
21
21
|
"url": "git+https://github.com/codefastlabs/codefast.git",
|
|
@@ -26,23 +26,27 @@
|
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
28
|
"dist",
|
|
29
|
-
"
|
|
29
|
+
"CHANGELOG.md",
|
|
30
30
|
"README.md",
|
|
31
|
-
"
|
|
31
|
+
"LICENSE"
|
|
32
32
|
],
|
|
33
33
|
"type": "module",
|
|
34
|
+
"main": "./dist/index.js",
|
|
35
|
+
"module": "./dist/index.js",
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
34
37
|
"imports": {
|
|
35
|
-
"#/tests/*": [
|
|
36
|
-
"./tests/*",
|
|
37
|
-
"./tests/*.ts",
|
|
38
|
-
"./tests/*.tsx",
|
|
39
|
-
"./tests/*/index.ts",
|
|
40
|
-
"./tests/*/index.tsx"
|
|
41
|
-
],
|
|
42
38
|
"#/*": {
|
|
39
|
+
"types": "./dist/*.d.ts",
|
|
43
40
|
"default": "./dist/*.js"
|
|
44
41
|
}
|
|
45
42
|
},
|
|
43
|
+
"exports": {
|
|
44
|
+
".": {
|
|
45
|
+
"types": "./dist/index.d.ts",
|
|
46
|
+
"import": "./dist/index.js"
|
|
47
|
+
},
|
|
48
|
+
"./package.json": "./package.json"
|
|
49
|
+
},
|
|
46
50
|
"publishConfig": {
|
|
47
51
|
"access": "public"
|
|
48
52
|
},
|
|
@@ -55,28 +59,7 @@
|
|
|
55
59
|
"yaml": "^2.9.0",
|
|
56
60
|
"zod": "^4.5.4"
|
|
57
61
|
},
|
|
58
|
-
"devDependencies": {
|
|
59
|
-
"@types/node": "^26.4.1",
|
|
60
|
-
"@types/picomatch": "^4.0.3",
|
|
61
|
-
"@vitest/coverage-v8": "^5.0.0",
|
|
62
|
-
"typescript": "^7.0.2",
|
|
63
|
-
"vite": "^8.2.2",
|
|
64
|
-
"vitest": "^5.0.0",
|
|
65
|
-
"@codefast/typescript-config": "0.9.0"
|
|
66
|
-
},
|
|
67
62
|
"engines": {
|
|
68
63
|
"node": ">=24.0.0"
|
|
69
|
-
},
|
|
70
|
-
"scripts": {
|
|
71
|
-
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
72
|
-
"check-types": "tsc --noEmit",
|
|
73
|
-
"clean": "rm -rf dist",
|
|
74
|
-
"test": "vitest run",
|
|
75
|
-
"test:coverage": "vitest run --coverage",
|
|
76
|
-
"test:e2e": "vitest run tests/e2e",
|
|
77
|
-
"test:integration": "vitest run tests/integration",
|
|
78
|
-
"test:type": "vitest run tests/types",
|
|
79
|
-
"test:unit": "vitest run tests/unit",
|
|
80
|
-
"test:watch": "vitest"
|
|
81
64
|
}
|
|
82
65
|
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { parseSync } from "oxc-parser";
|
|
2
|
-
function isOxcNode(value) {
|
|
3
|
-
return typeof value === "object" && value !== null && typeof value.type === "string";
|
|
4
|
-
}
|
|
5
|
-
function isIdentifierNamed(node, name) {
|
|
6
|
-
return isOxcNode(node) && node.type === "Identifier" && node.name === name;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Scans one TypeScript source for React import-policy violations.
|
|
10
|
-
*
|
|
11
|
-
* @remarks Three violation kinds: `import * as React`, a default `React` import (type-only
|
|
12
|
-
* included), and — only when no import binds `React` — an implicit `React.*` UMD-global type
|
|
13
|
-
* reference, which tsc accepts silently through the `export as namespace React` in `@types/react`.
|
|
14
|
-
*
|
|
15
|
-
* @since 0.8.0
|
|
16
|
-
*/
|
|
17
|
-
export function auditReactImportSource(filePath, sourceText) {
|
|
18
|
-
const { program } = parseSync(filePath, sourceText);
|
|
19
|
-
const statements = program.body;
|
|
20
|
-
const violations = [];
|
|
21
|
-
let bindsReact = false;
|
|
22
|
-
for (const statement of statements) {
|
|
23
|
-
if (statement.type !== "ImportDeclaration") {
|
|
24
|
-
continue;
|
|
25
|
-
}
|
|
26
|
-
const source = statement.source;
|
|
27
|
-
if (!isOxcNode(source) || source.value !== "react") {
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
const specifiers = Array.isArray(statement.specifiers) ? statement.specifiers.filter(isOxcNode) : [];
|
|
31
|
-
bindsReact ||= specifiers.some((specifier) => isIdentifierNamed(specifier.local, "React"));
|
|
32
|
-
for (const specifier of specifiers) {
|
|
33
|
-
if (specifier.type === "ImportNamespaceSpecifier") {
|
|
34
|
-
violations.push({
|
|
35
|
-
line: lineOfOffset(sourceText, statement.start),
|
|
36
|
-
raw: firstLineOf(sourceText.slice(statement.start, statement.end)),
|
|
37
|
-
reason: 'namespace React import — import members by name from "react"',
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
else if (specifier.type === "ImportDefaultSpecifier") {
|
|
41
|
-
violations.push({
|
|
42
|
-
line: lineOfOffset(sourceText, statement.start),
|
|
43
|
-
raw: firstLineOf(sourceText.slice(statement.start, statement.end)),
|
|
44
|
-
reason: 'default React import — import members by name from "react"',
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
// A bound `React` means the import itself is flagged above; qualified names under it are
|
|
50
|
-
// symptoms, not extra findings.
|
|
51
|
-
if (!bindsReact) {
|
|
52
|
-
collectUmdGlobalReferences(program, sourceText, violations);
|
|
53
|
-
}
|
|
54
|
-
violations.sort((a, b) => a.line - b.line);
|
|
55
|
-
return violations;
|
|
56
|
-
}
|
|
57
|
-
function collectUmdGlobalReferences(node, sourceText, violations) {
|
|
58
|
-
if (node.type === "TSQualifiedName" && isIdentifierNamed(node.left, "React")) {
|
|
59
|
-
violations.push({
|
|
60
|
-
line: lineOfOffset(sourceText, node.start),
|
|
61
|
-
raw: sourceText.slice(node.start, node.end),
|
|
62
|
-
reason: 'implicit React.* UMD global — add import type { … } from "react"',
|
|
63
|
-
});
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
for (const value of Object.values(node)) {
|
|
67
|
-
if (Array.isArray(value)) {
|
|
68
|
-
for (const item of value) {
|
|
69
|
-
if (isOxcNode(item)) {
|
|
70
|
-
collectUmdGlobalReferences(item, sourceText, violations);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
else if (isOxcNode(value)) {
|
|
75
|
-
collectUmdGlobalReferences(value, sourceText, violations);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
function lineOfOffset(sourceText, offset) {
|
|
80
|
-
let line = 1;
|
|
81
|
-
for (let index = 0; index < offset; index++) {
|
|
82
|
-
if (sourceText.charCodeAt(index) === 10) {
|
|
83
|
-
line++;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return line;
|
|
87
|
-
}
|
|
88
|
-
function firstLineOf(text) {
|
|
89
|
-
const newlineIndex = text.indexOf("\n");
|
|
90
|
-
return newlineIndex === -1 ? text : text.slice(0, newlineIndex);
|
|
91
|
-
}
|