@bemedev/codebase 0.3.0 → 1.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/README.md +26 -13
- package/lib/analyse.cjs +10 -8
- package/lib/analyse.cjs.map +1 -1
- package/lib/analyse.d.ts +4 -3
- package/lib/analyse.d.ts.map +1 -0
- package/lib/analyse.js +9 -7
- package/lib/analyse.js.map +1 -1
- package/lib/analyse.utils.cjs +6 -6
- package/lib/analyse.utils.cjs.map +1 -1
- package/lib/analyse.utils.d.ts +8 -7
- package/lib/analyse.utils.d.ts.map +1 -0
- package/lib/analyse.utils.js +6 -6
- package/lib/analyse.utils.js.map +1 -1
- package/lib/cli/cli.cjs +2 -2
- package/lib/cli/cli.cjs.map +1 -1
- package/lib/cli/cli.d.ts +1 -0
- package/lib/cli/cli.d.ts.map +1 -0
- package/lib/cli/cli.js +2 -1
- package/lib/cli/cli.js.map +1 -1
- package/lib/cli/constants.d.ts +1 -0
- package/lib/cli/constants.d.ts.map +1 -0
- package/lib/cli/index.cjs +0 -1
- package/lib/cli/index.cjs.map +1 -1
- package/lib/cli/index.d.ts +1 -0
- package/lib/cli/index.d.ts.map +1 -0
- package/lib/cli/index.js +0 -0
- package/lib/cli/index.js.map +1 -1
- package/lib/config.cjs +12 -0
- package/lib/config.cjs.map +1 -0
- package/lib/config.d.ts +7 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +11 -0
- package/lib/config.js.map +1 -0
- package/lib/constants.cjs +6 -5
- package/lib/constants.cjs.map +1 -1
- package/lib/constants.d.ts +4 -2
- package/lib/constants.d.ts.map +1 -0
- package/lib/constants.js +4 -3
- package/lib/constants.js.map +1 -1
- package/lib/exports.cjs +0 -1
- package/lib/exports.cjs.map +1 -1
- package/lib/exports.d.ts +1 -0
- package/lib/exports.d.ts.map +1 -0
- package/lib/exports.js.map +1 -1
- package/lib/functions/add.cjs +6 -5
- package/lib/functions/add.cjs.map +1 -1
- package/lib/functions/add.d.ts +2 -1
- package/lib/functions/add.d.ts.map +1 -0
- package/lib/functions/add.js +6 -5
- package/lib/functions/add.js.map +1 -1
- package/lib/functions/generate.cjs +5 -6
- package/lib/functions/generate.cjs.map +1 -1
- package/lib/functions/generate.d.ts +3 -2
- package/lib/functions/generate.d.ts.map +1 -0
- package/lib/functions/generate.js +5 -5
- package/lib/functions/generate.js.map +1 -1
- package/lib/functions/index.d.ts +1 -0
- package/lib/functions/index.d.ts.map +1 -0
- package/lib/functions/init.cjs +29 -16
- package/lib/functions/init.cjs.map +1 -1
- package/lib/functions/init.d.ts +6 -3
- package/lib/functions/init.d.ts.map +1 -0
- package/lib/functions/init.js +30 -16
- package/lib/functions/init.js.map +1 -1
- package/lib/functions/remove.cjs +11 -10
- package/lib/functions/remove.cjs.map +1 -1
- package/lib/functions/remove.d.ts +2 -1
- package/lib/functions/remove.d.ts.map +1 -0
- package/lib/functions/remove.js +11 -10
- package/lib/functions/remove.js.map +1 -1
- package/lib/helpers.cjs +1 -2
- package/lib/helpers.cjs.map +1 -1
- package/lib/helpers.d.ts +4 -3
- package/lib/helpers.d.ts.map +1 -0
- package/lib/helpers.js +1 -1
- package/lib/helpers.js.map +1 -1
- package/lib/imports.cjs +2 -3
- package/lib/imports.cjs.map +1 -1
- package/lib/imports.d.ts +4 -3
- package/lib/imports.d.ts.map +1 -0
- package/lib/imports.js +2 -2
- package/lib/imports.js.map +1 -1
- package/lib/index.cjs +2 -0
- package/lib/index.d.ts +6 -4
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +2 -1
- package/lib/schemas.cjs +1 -1
- package/lib/schemas.cjs.map +1 -1
- package/lib/schemas.d.ts +2 -1
- package/lib/schemas.d.ts.map +1 -0
- package/lib/schemas.js.map +1 -1
- package/lib/types.d.ts +1 -6
- package/lib/types.d.ts.map +1 -0
- package/lib/utils.cjs +2 -2
- package/lib/utils.cjs.map +1 -1
- package/lib/utils.d.ts +2 -1
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +2 -2
- package/lib/utils.js.map +1 -1
- package/package.json +43 -62
package/lib/helpers.js
CHANGED
|
@@ -19,7 +19,7 @@ const writeFileAnalysis = (fileAnalysis, folderPath) => {
|
|
|
19
19
|
console.log(` ✅ ${relativePath}`);
|
|
20
20
|
return relativePath.slice(0, -3).replaceAll("/", ".");
|
|
21
21
|
} catch (error) {
|
|
22
|
-
return console.error(` ❌
|
|
22
|
+
return console.error(` ❌ Error for ${relativePath}:`, error);
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
const consoleStars = () => {
|
package/lib/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from
|
|
1
|
+
{"version":3,"file":"helpers.js","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport { dirname, join, relative, resolve } from 'node:path';\nimport { REPLACERS } from './constants';\nimport { FileAnalysis } from './schemas';\n\nexport type TransformModuleArgs = {\n cwd?: string;\n relativePath: string;\n moduleSpecifier: string;\n};\n\nexport const transformModule = ({\n cwd = process.cwd(),\n relativePath,\n moduleSpecifier,\n}: TransformModuleArgs) => {\n const out = relative(\n cwd,\n resolve(dirname(relativePath), moduleSpecifier),\n ).replaceAll('/', '.');\n\n return out;\n};\n\nexport const writeFileAnalysis = (\n fileAnalysis: FileAnalysis,\n folderPath: string,\n) => {\n const relativePath = fileAnalysis.relativePath;\n\n // Create the destination path in .bemedev maintaining the structure\n const destPath = join(folderPath, relativePath);\n const destDir = dirname(destPath);\n\n try {\n // Create the destination folder if necessary\n mkdirSync(destDir, { recursive: true });\n\n let fileContent = fileAnalysis.text;\n REPLACERS.init.forEach(([search, replace]) => {\n fileContent = fileContent.replaceAll(search, replace);\n });\n\n // Write the types file content\n writeFileSync(destPath, fileContent, 'utf8');\n\n console.log(` ✅ ${relativePath}`);\n return relativePath.slice(0, -3).replaceAll('/', '.');\n } catch (error) {\n return console.error(` ❌ Error for ${relativePath}:`, error);\n }\n};\n\nexport const consoleStars = () => {\n console.log();\n console.log('*'.repeat(30));\n console.log();\n};\n\nexport const toArray = <T>(value?: T | T[]): T[] => {\n return Array.isArray(value) ? value : !value ? [] : [value];\n};\n\nexport const getFolderPath = (root: string) => {\n const cwd = process.cwd();\n const srcExists = existsSync(join(cwd, 'src'));\n const folderPath = srcExists\n ? join(cwd, 'src', root)\n : join(cwd, root);\n\n return folderPath;\n};\n"],"mappings":";;;;AAWA,MAAa,mBAAmB,EAC9B,MAAM,QAAQ,IAAI,GAClB,cACA,sBACyB;CAMzB,OALY,SACV,KACA,QAAQ,QAAQ,YAAY,GAAG,eAAe,CAChD,CAAC,CAAC,WAAW,KAAK,GAET;AACX;AAEA,MAAa,qBACX,cACA,eACG;CACH,MAAM,eAAe,aAAa;CAGlC,MAAM,WAAW,KAAK,YAAY,YAAY;CAC9C,MAAM,UAAU,QAAQ,QAAQ;CAEhC,IAAI;EAEF,UAAU,SAAS,EAAE,WAAW,KAAK,CAAC;EAEtC,IAAI,cAAc,aAAa;EAC/B,UAAU,KAAK,SAAS,CAAC,QAAQ,aAAa;GAC5C,cAAc,YAAY,WAAW,QAAQ,OAAO;EACtD,CAAC;EAGD,cAAc,UAAU,aAAa,MAAM;EAE3C,QAAQ,IAAI,OAAO,cAAc;EACjC,OAAO,aAAa,MAAM,GAAG,EAAE,CAAC,CAAC,WAAW,KAAK,GAAG;CACtD,SAAS,OAAO;EACd,OAAO,QAAQ,MAAM,iBAAiB,aAAa,IAAI,KAAK;CAC9D;AACF;AAEA,MAAa,qBAAqB;CAChC,QAAQ,IAAI;CACZ,QAAQ,IAAI,IAAI,OAAO,EAAE,CAAC;CAC1B,QAAQ,IAAI;AACd;AAEA,MAAa,WAAc,UAAyB;CAClD,OAAO,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK;AAC5D;AAEA,MAAa,iBAAiB,SAAiB;CAC7C,MAAM,MAAM,QAAQ,IAAI;CAMxB,OALkB,WAAW,KAAK,KAAK,KAAK,CACjB,IACvB,KAAK,KAAK,OAAO,IAAI,IACrB,KAAK,KAAK,IAAI;AAGpB"}
|
package/lib/imports.cjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
require("./_virtual/_rolldown/runtime.cjs");
|
|
3
2
|
let path = require("path");
|
|
4
3
|
let ts_morph = require("ts-morph");
|
|
5
4
|
//#region src/imports.ts
|
|
6
5
|
/**
|
|
7
|
-
*
|
|
6
|
+
* Resolves the moduleSpecifier using the tsconfig paths if it starts with "#"
|
|
8
7
|
*/
|
|
9
8
|
const resolveModuleSpecifier = (sourceFile, moduleSpecifier) => {
|
|
10
9
|
const paths = sourceFile.getProject().getCompilerOptions().paths;
|
|
@@ -26,7 +25,7 @@ const resolveModuleSpecifier = (sourceFile, moduleSpecifier) => {
|
|
|
26
25
|
return moduleSpecifier;
|
|
27
26
|
};
|
|
28
27
|
/**
|
|
29
|
-
*
|
|
28
|
+
* Analyzes a file's imports
|
|
30
29
|
*/
|
|
31
30
|
const analyzeImports = (sourceFile) => {
|
|
32
31
|
const imports = [];
|
package/lib/imports.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imports.cjs","names":["SyntaxKind"],"sources":["../src/imports.ts"],"sourcesContent":["import { join, relative } from
|
|
1
|
+
{"version":3,"file":"imports.cjs","names":["SyntaxKind"],"sources":["../src/imports.ts"],"sourcesContent":["import { join, relative } from 'node:path';\nimport { SourceFile, SyntaxKind } from 'ts-morph';\nimport type { ImportInfo } from './schemas';\n\n/**\n * Resolves the moduleSpecifier using the tsconfig paths if it starts with \"#\"\n */\nconst resolveModuleSpecifier = (\n sourceFile: SourceFile,\n moduleSpecifier: string,\n): string => {\n const paths = sourceFile.getProject().getCompilerOptions().paths;\n\n if (!paths) return moduleSpecifier;\n\n const baseUrl = sourceFile.getProject().getCompilerOptions().baseUrl;\n const paths2 = Object.entries(paths);\n\n // Find the match in paths\n for (const [pattern, mappings] of paths2) {\n // Replace * with a regex to match\n const regexPattern = pattern.replace(/\\*/g, '(.*)');\n const regex = new RegExp(`^${regexPattern}$`);\n const match = moduleSpecifier.match(regex);\n\n if (match) {\n // Take the first available mapping\n const first = mappings[0];\n\n // Resolve the absolute path\n let relativedPath = baseUrl ? join(baseUrl, first) : first;\n\n if (match[1]) {\n relativedPath = relativedPath.replace('*', match[1]);\n }\n\n // Calculate the relative path from the current source file\n const sourceFileDir = relative(\n process.cwd(),\n sourceFile.getDirectoryPath(),\n );\n const relativePath = relative(sourceFileDir, relativedPath);\n\n // Make sure the relative path starts with ./ or ../\n return relativePath.startsWith('.')\n ? relativePath\n : `./${relativePath}`;\n }\n }\n\n return moduleSpecifier;\n};\n\n/**\n * Analyzes a file's imports\n */\nexport const analyzeImports = (\n sourceFile: SourceFile,\n): ImportInfo[] => {\n const imports: ImportInfo[] = [];\n\n // Import declarations (import ... from '...')\n sourceFile.getImportDeclarations().forEach(importDecl => {\n // Determine if this is a type-only import\n const isTypeOnly = importDecl.isTypeOnly();\n\n const rawModuleSpecifier = importDecl.getModuleSpecifierValue();\n const moduleSpecifier = resolveModuleSpecifier(\n sourceFile,\n rawModuleSpecifier,\n );\n\n // Import default\n const defaultImport = importDecl.getDefaultImport();\n if (defaultImport) {\n imports.push({\n moduleSpecifier,\n kind: 'default',\n default: defaultImport.getText(),\n isTypeOnly,\n });\n }\n\n // Import namespace (* as name)\n const namespaceImport = importDecl.getNamespaceImport();\n if (namespaceImport) {\n imports.push({\n moduleSpecifier,\n kind: 'namespace',\n default: namespaceImport.getText(),\n isTypeOnly,\n });\n }\n\n // Named imports ({ name1, name2 })\n const namedImports = importDecl.getNamedImports();\n if (namedImports.length > 0) {\n imports.push({\n moduleSpecifier,\n kind: 'named',\n namedImports: namedImports.map(ni => ni.getName()),\n isTypeOnly,\n });\n }\n\n // Side-effect import (import '...')\n if (\n !defaultImport &&\n !namespaceImport &&\n namedImports.length === 0\n ) {\n imports.push({\n moduleSpecifier,\n kind: 'side-effect',\n isTypeOnly,\n });\n }\n });\n\n // Dynamic imports (import('...'))\n sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .forEach(callExpr => {\n if (\n callExpr.getExpression().getKind() === SyntaxKind.ImportKeyword\n ) {\n const arg = callExpr.getArguments()[0];\n if (arg && arg.getKind() === SyntaxKind.StringLiteral) {\n const rawModuleSpecifier = arg.getText().replace(/['\"]/g, '');\n const moduleSpecifier = resolveModuleSpecifier(\n sourceFile,\n rawModuleSpecifier,\n );\n imports.push({\n moduleSpecifier,\n kind: 'side-effect',\n isDynamic: true,\n });\n }\n }\n });\n\n return imports;\n};\n\nexport const buildImportStrings = (imports: ImportInfo[]) => {\n return imports.map(imp => {\n switch (imp.kind) {\n case 'named': {\n const namedImports = imp.namedImports?.join(', ') || '';\n return `import ${imp.isTypeOnly ? 'type ' : ''}{ ${namedImports} } from '${imp.moduleSpecifier}';`;\n }\n case 'namespace':\n return `import ${imp.isTypeOnly ? 'type ' : ''}* as ${imp.default} from '${imp.moduleSpecifier}';`;\n case 'side-effect': {\n if (imp.isDynamic) {\n return `// Dynamic import: import('${imp.moduleSpecifier}')`;\n }\n return `import '${imp.moduleSpecifier}';`;\n }\n\n case 'default':\n return `import ${imp.isTypeOnly ? 'type ' : ''}${imp.default} from '${imp.moduleSpecifier}';`;\n default:\n return '';\n }\n });\n};\n"],"mappings":"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"}
|
package/lib/imports.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { SourceFile } from
|
|
2
|
-
import type { ImportInfo } from
|
|
1
|
+
import { SourceFile } from 'ts-morph';
|
|
2
|
+
import type { ImportInfo } from './schemas';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Analyzes a file's imports
|
|
5
5
|
*/
|
|
6
6
|
export declare const analyzeImports: (sourceFile: SourceFile) => ImportInfo[];
|
|
7
7
|
export declare const buildImportStrings: (imports: ImportInfo[]) => string[];
|
|
8
|
+
//# sourceMappingURL=imports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imports.d.ts","sourceRoot":"","sources":["../src/imports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAc,MAAM,UAAU,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAmD5C;;GAEG;AACH,eAAO,MAAM,cAAc,GACzB,YAAY,UAAU,KACrB,UAAU,EAqFZ,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,SAAS,UAAU,EAAE,aAsBvD,CAAC"}
|
package/lib/imports.js
CHANGED
|
@@ -2,7 +2,7 @@ import { join, relative } from "path";
|
|
|
2
2
|
import { SyntaxKind } from "ts-morph";
|
|
3
3
|
//#region src/imports.ts
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Resolves the moduleSpecifier using the tsconfig paths if it starts with "#"
|
|
6
6
|
*/
|
|
7
7
|
const resolveModuleSpecifier = (sourceFile, moduleSpecifier) => {
|
|
8
8
|
const paths = sourceFile.getProject().getCompilerOptions().paths;
|
|
@@ -24,7 +24,7 @@ const resolveModuleSpecifier = (sourceFile, moduleSpecifier) => {
|
|
|
24
24
|
return moduleSpecifier;
|
|
25
25
|
};
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* Analyzes a file's imports
|
|
28
28
|
*/
|
|
29
29
|
const analyzeImports = (sourceFile) => {
|
|
30
30
|
const imports = [];
|
package/lib/imports.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imports.js","names":[],"sources":["../src/imports.ts"],"sourcesContent":["import { join, relative } from
|
|
1
|
+
{"version":3,"file":"imports.js","names":[],"sources":["../src/imports.ts"],"sourcesContent":["import { join, relative } from 'node:path';\nimport { SourceFile, SyntaxKind } from 'ts-morph';\nimport type { ImportInfo } from './schemas';\n\n/**\n * Resolves the moduleSpecifier using the tsconfig paths if it starts with \"#\"\n */\nconst resolveModuleSpecifier = (\n sourceFile: SourceFile,\n moduleSpecifier: string,\n): string => {\n const paths = sourceFile.getProject().getCompilerOptions().paths;\n\n if (!paths) return moduleSpecifier;\n\n const baseUrl = sourceFile.getProject().getCompilerOptions().baseUrl;\n const paths2 = Object.entries(paths);\n\n // Find the match in paths\n for (const [pattern, mappings] of paths2) {\n // Replace * with a regex to match\n const regexPattern = pattern.replace(/\\*/g, '(.*)');\n const regex = new RegExp(`^${regexPattern}$`);\n const match = moduleSpecifier.match(regex);\n\n if (match) {\n // Take the first available mapping\n const first = mappings[0];\n\n // Resolve the absolute path\n let relativedPath = baseUrl ? join(baseUrl, first) : first;\n\n if (match[1]) {\n relativedPath = relativedPath.replace('*', match[1]);\n }\n\n // Calculate the relative path from the current source file\n const sourceFileDir = relative(\n process.cwd(),\n sourceFile.getDirectoryPath(),\n );\n const relativePath = relative(sourceFileDir, relativedPath);\n\n // Make sure the relative path starts with ./ or ../\n return relativePath.startsWith('.')\n ? relativePath\n : `./${relativePath}`;\n }\n }\n\n return moduleSpecifier;\n};\n\n/**\n * Analyzes a file's imports\n */\nexport const analyzeImports = (\n sourceFile: SourceFile,\n): ImportInfo[] => {\n const imports: ImportInfo[] = [];\n\n // Import declarations (import ... from '...')\n sourceFile.getImportDeclarations().forEach(importDecl => {\n // Determine if this is a type-only import\n const isTypeOnly = importDecl.isTypeOnly();\n\n const rawModuleSpecifier = importDecl.getModuleSpecifierValue();\n const moduleSpecifier = resolveModuleSpecifier(\n sourceFile,\n rawModuleSpecifier,\n );\n\n // Import default\n const defaultImport = importDecl.getDefaultImport();\n if (defaultImport) {\n imports.push({\n moduleSpecifier,\n kind: 'default',\n default: defaultImport.getText(),\n isTypeOnly,\n });\n }\n\n // Import namespace (* as name)\n const namespaceImport = importDecl.getNamespaceImport();\n if (namespaceImport) {\n imports.push({\n moduleSpecifier,\n kind: 'namespace',\n default: namespaceImport.getText(),\n isTypeOnly,\n });\n }\n\n // Named imports ({ name1, name2 })\n const namedImports = importDecl.getNamedImports();\n if (namedImports.length > 0) {\n imports.push({\n moduleSpecifier,\n kind: 'named',\n namedImports: namedImports.map(ni => ni.getName()),\n isTypeOnly,\n });\n }\n\n // Side-effect import (import '...')\n if (\n !defaultImport &&\n !namespaceImport &&\n namedImports.length === 0\n ) {\n imports.push({\n moduleSpecifier,\n kind: 'side-effect',\n isTypeOnly,\n });\n }\n });\n\n // Dynamic imports (import('...'))\n sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .forEach(callExpr => {\n if (\n callExpr.getExpression().getKind() === SyntaxKind.ImportKeyword\n ) {\n const arg = callExpr.getArguments()[0];\n if (arg && arg.getKind() === SyntaxKind.StringLiteral) {\n const rawModuleSpecifier = arg.getText().replace(/['\"]/g, '');\n const moduleSpecifier = resolveModuleSpecifier(\n sourceFile,\n rawModuleSpecifier,\n );\n imports.push({\n moduleSpecifier,\n kind: 'side-effect',\n isDynamic: true,\n });\n }\n }\n });\n\n return imports;\n};\n\nexport const buildImportStrings = (imports: ImportInfo[]) => {\n return imports.map(imp => {\n switch (imp.kind) {\n case 'named': {\n const namedImports = imp.namedImports?.join(', ') || '';\n return `import ${imp.isTypeOnly ? 'type ' : ''}{ ${namedImports} } from '${imp.moduleSpecifier}';`;\n }\n case 'namespace':\n return `import ${imp.isTypeOnly ? 'type ' : ''}* as ${imp.default} from '${imp.moduleSpecifier}';`;\n case 'side-effect': {\n if (imp.isDynamic) {\n return `// Dynamic import: import('${imp.moduleSpecifier}')`;\n }\n return `import '${imp.moduleSpecifier}';`;\n }\n\n case 'default':\n return `import ${imp.isTypeOnly ? 'type ' : ''}${imp.default} from '${imp.moduleSpecifier}';`;\n default:\n return '';\n }\n });\n};\n"],"mappings":"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"}
|
package/lib/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_schemas = require("./schemas.cjs");
|
|
3
3
|
const require_analyse = require("./analyse.cjs");
|
|
4
|
+
const require_config = require("./config.cjs");
|
|
4
5
|
const require_functions_add = require("./functions/add.cjs");
|
|
5
6
|
const require_functions_generate = require("./functions/generate.cjs");
|
|
6
7
|
const require_functions_init = require("./functions/init.cjs");
|
|
@@ -15,6 +16,7 @@ exports.FileAnalysisSchema = require_schemas.FileAnalysisSchema;
|
|
|
15
16
|
exports.ImportInfoSchema = require_schemas.ImportInfoSchema;
|
|
16
17
|
exports.add = require_functions_add.add;
|
|
17
18
|
exports.analyze = require_analyse.analyze;
|
|
19
|
+
exports.config = require_config.config;
|
|
18
20
|
exports.createTypesStructure = require_functions_init.createTypesStructure;
|
|
19
21
|
exports.generate = require_functions_generate.generate;
|
|
20
22
|
exports.init = require_functions_init.init;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
1
|
+
export * from './analyse';
|
|
2
|
+
export * from './functions';
|
|
3
|
+
export * from './schemas';
|
|
4
|
+
export * from './types';
|
|
5
|
+
export * from './config';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { AnalysisStatsSchema, CodeAnalysisFileSchema, CodebaseAnalysisSchema, DeclarationKindSchema, ExportInfoSchema, FileAnalysisSchema, ImportInfoSchema } from "./schemas.js";
|
|
2
2
|
import { analyze } from "./analyse.js";
|
|
3
|
+
import { config } from "./config.js";
|
|
3
4
|
import { add } from "./functions/add.js";
|
|
4
5
|
import { generate, transformJSON } from "./functions/generate.js";
|
|
5
6
|
import { createTypesStructure, init } from "./functions/init.js";
|
|
6
7
|
import { remove } from "./functions/remove.js";
|
|
7
8
|
import "./functions/index.js";
|
|
8
|
-
export { AnalysisStatsSchema, CodeAnalysisFileSchema, CodebaseAnalysisSchema, DeclarationKindSchema, ExportInfoSchema, FileAnalysisSchema, ImportInfoSchema, add, analyze, createTypesStructure, generate, init, remove, transformJSON };
|
|
9
|
+
export { AnalysisStatsSchema, CodeAnalysisFileSchema, CodebaseAnalysisSchema, DeclarationKindSchema, ExportInfoSchema, FileAnalysisSchema, ImportInfoSchema, add, analyze, config, createTypesStructure, generate, init, remove, transformJSON };
|
package/lib/schemas.cjs
CHANGED
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
3
3
|
const require_constants = require("./constants.cjs");
|
|
4
4
|
let valibot = require("valibot");
|
|
5
|
-
valibot = require_runtime.__toESM(valibot);
|
|
5
|
+
valibot = require_runtime.__toESM(valibot, 1);
|
|
6
6
|
//#region src/schemas.ts
|
|
7
7
|
const DeclarationKindSchema = valibot.picklist([
|
|
8
8
|
"function",
|
package/lib/schemas.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.cjs","names":["v","PROPERTIES"],"sources":["../src/schemas.ts"],"sourcesContent":["import * as v from
|
|
1
|
+
{"version":3,"file":"schemas.cjs","names":["v","PROPERTIES"],"sources":["../src/schemas.ts"],"sourcesContent":["import * as v from 'valibot';\nimport { PROPERTIES } from './constants';\n\nexport const DeclarationKindSchema = v.picklist([\n 'function',\n 'class',\n 'interface',\n 'type',\n 'variable',\n 'const',\n 'let',\n 'enum',\n]);\n\nexport const ImportInfoSchema = v.object({\n moduleSpecifier: v.string(),\n kind: v.picklist(['default', 'named', 'namespace', 'side-effect']),\n namedImports: v.optional(v.array(v.string())),\n default: v.optional(v.string()),\n isDynamic: v.optional(v.boolean()),\n isTypeOnly: v.optional(v.boolean()),\n});\n\nexport const ExportInfoSchema = v.object({\n name: v.string(),\n kind: v.picklist(['default', 'named', 'namespace']),\n text: v.optional(v.string()),\n moduleSpecifier: v.optional(v.string()),\n declarationKind: v.optional(DeclarationKindSchema),\n});\n\nexport const FileAnalysisSchema = v.object({\n relativePath: v.string(),\n imports: v.array(ImportInfoSchema),\n exports: v.optional(v.array(ExportInfoSchema)),\n text: v.string(),\n});\n\n// Schema for CodebaseAnalysis\nexport const CodebaseAnalysisSchema = v.record(\n v.string(),\n FileAnalysisSchema,\n);\n\n// Schema for analysis statistics\nexport const AnalysisStatsSchema = v.object({\n files: v.number(),\n imports: v.number(),\n exports: v.number(),\n});\n\n// Complete schema for a codebase analysis file containing the full analysis\nexport const CodeAnalysisFileSchema = v.object({\n [PROPERTIES.CODEBASE_ANALYSIS]: CodebaseAnalysisSchema,\n [PROPERTIES.STATS]: v.optional(AnalysisStatsSchema),\n});\n\n// Types inferred from schemas\nexport type DeclarationKind = v.InferOutput<\n typeof DeclarationKindSchema\n>;\nexport type ImportInfo = v.InferOutput<typeof ImportInfoSchema>;\nexport type ExportInfo = v.InferOutput<typeof ExportInfoSchema>;\nexport type FileAnalysis = v.InferOutput<typeof FileAnalysisSchema>;\nexport type CodebaseAnalysis = v.InferOutput<\n typeof CodebaseAnalysisSchema\n>;\nexport type AnalysisStats = v.InferOutput<typeof AnalysisStatsSchema>;\nexport type CodeAnalysisFile = v.InferOutput<\n typeof CodeAnalysisFileSchema\n>;\n"],"mappings":";;;;;;AAGA,MAAa,wBAAwBA,QAAE,SAAS;CAC9C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAa,mBAAmBA,QAAE,OAAO;CACvC,iBAAiBA,QAAE,OAAO;CAC1B,MAAMA,QAAE,SAAS;EAAC;EAAW;EAAS;EAAa;CAAa,CAAC;CACjE,cAAcA,QAAE,SAASA,QAAE,MAAMA,QAAE,OAAO,CAAC,CAAC;CAC5C,SAASA,QAAE,SAASA,QAAE,OAAO,CAAC;CAC9B,WAAWA,QAAE,SAASA,QAAE,QAAQ,CAAC;CACjC,YAAYA,QAAE,SAASA,QAAE,QAAQ,CAAC;AACpC,CAAC;AAED,MAAa,mBAAmBA,QAAE,OAAO;CACvC,MAAMA,QAAE,OAAO;CACf,MAAMA,QAAE,SAAS;EAAC;EAAW;EAAS;CAAW,CAAC;CAClD,MAAMA,QAAE,SAASA,QAAE,OAAO,CAAC;CAC3B,iBAAiBA,QAAE,SAASA,QAAE,OAAO,CAAC;CACtC,iBAAiBA,QAAE,SAAS,qBAAqB;AACnD,CAAC;AAED,MAAa,qBAAqBA,QAAE,OAAO;CACzC,cAAcA,QAAE,OAAO;CACvB,SAASA,QAAE,MAAM,gBAAgB;CACjC,SAASA,QAAE,SAASA,QAAE,MAAM,gBAAgB,CAAC;CAC7C,MAAMA,QAAE,OAAO;AACjB,CAAC;AAGD,MAAa,yBAAyBA,QAAE,OACtCA,QAAE,OAAO,GACT,kBACF;AAGA,MAAa,sBAAsBA,QAAE,OAAO;CAC1C,OAAOA,QAAE,OAAO;CAChB,SAASA,QAAE,OAAO;CAClB,SAASA,QAAE,OAAO;AACpB,CAAC;AAGD,MAAa,yBAAyBA,QAAE,OAAO;EAC5CC,kBAAAA,WAAW,oBAAoB;EAC/BA,kBAAAA,WAAW,QAAQD,QAAE,SAAS,mBAAmB;AACpD,CAAC"}
|
package/lib/schemas.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as v from
|
|
1
|
+
import * as v from 'valibot';
|
|
2
2
|
export declare const DeclarationKindSchema: v.PicklistSchema<["function", "class", "interface", "type", "variable", "const", "let", "enum"], undefined>;
|
|
3
3
|
export declare const ImportInfoSchema: v.ObjectSchema<{
|
|
4
4
|
readonly moduleSpecifier: v.StringSchema<undefined>;
|
|
@@ -91,3 +91,4 @@ export type FileAnalysis = v.InferOutput<typeof FileAnalysisSchema>;
|
|
|
91
91
|
export type CodebaseAnalysis = v.InferOutput<typeof CodebaseAnalysisSchema>;
|
|
92
92
|
export type AnalysisStats = v.InferOutput<typeof AnalysisStatsSchema>;
|
|
93
93
|
export type CodeAnalysisFile = v.InferOutput<typeof CodeAnalysisFileSchema>;
|
|
94
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAG7B,eAAO,MAAM,qBAAqB,6GAShC,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;aAO3B,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;aAM3B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;aAK7B,CAAC;AAGH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;yBAGlC,CAAC;AAGF,eAAO,MAAM,mBAAmB;;;;aAI9B,CAAC;AAGH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;aAGjC,CAAC;AAGH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,WAAW,CACzC,OAAO,qBAAqB,CAC7B,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAChE,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAChE,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,kBAAkB,CAAC,CAAC;AACpE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,WAAW,CAC1C,OAAO,sBAAsB,CAC9B,CAAC;AACF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACtE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,WAAW,CAC1C,OAAO,sBAAsB,CAC9B,CAAC"}
|
package/lib/schemas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.js","names":[],"sources":["../src/schemas.ts"],"sourcesContent":["import * as v from
|
|
1
|
+
{"version":3,"file":"schemas.js","names":[],"sources":["../src/schemas.ts"],"sourcesContent":["import * as v from 'valibot';\nimport { PROPERTIES } from './constants';\n\nexport const DeclarationKindSchema = v.picklist([\n 'function',\n 'class',\n 'interface',\n 'type',\n 'variable',\n 'const',\n 'let',\n 'enum',\n]);\n\nexport const ImportInfoSchema = v.object({\n moduleSpecifier: v.string(),\n kind: v.picklist(['default', 'named', 'namespace', 'side-effect']),\n namedImports: v.optional(v.array(v.string())),\n default: v.optional(v.string()),\n isDynamic: v.optional(v.boolean()),\n isTypeOnly: v.optional(v.boolean()),\n});\n\nexport const ExportInfoSchema = v.object({\n name: v.string(),\n kind: v.picklist(['default', 'named', 'namespace']),\n text: v.optional(v.string()),\n moduleSpecifier: v.optional(v.string()),\n declarationKind: v.optional(DeclarationKindSchema),\n});\n\nexport const FileAnalysisSchema = v.object({\n relativePath: v.string(),\n imports: v.array(ImportInfoSchema),\n exports: v.optional(v.array(ExportInfoSchema)),\n text: v.string(),\n});\n\n// Schema for CodebaseAnalysis\nexport const CodebaseAnalysisSchema = v.record(\n v.string(),\n FileAnalysisSchema,\n);\n\n// Schema for analysis statistics\nexport const AnalysisStatsSchema = v.object({\n files: v.number(),\n imports: v.number(),\n exports: v.number(),\n});\n\n// Complete schema for a codebase analysis file containing the full analysis\nexport const CodeAnalysisFileSchema = v.object({\n [PROPERTIES.CODEBASE_ANALYSIS]: CodebaseAnalysisSchema,\n [PROPERTIES.STATS]: v.optional(AnalysisStatsSchema),\n});\n\n// Types inferred from schemas\nexport type DeclarationKind = v.InferOutput<\n typeof DeclarationKindSchema\n>;\nexport type ImportInfo = v.InferOutput<typeof ImportInfoSchema>;\nexport type ExportInfo = v.InferOutput<typeof ExportInfoSchema>;\nexport type FileAnalysis = v.InferOutput<typeof FileAnalysisSchema>;\nexport type CodebaseAnalysis = v.InferOutput<\n typeof CodebaseAnalysisSchema\n>;\nexport type AnalysisStats = v.InferOutput<typeof AnalysisStatsSchema>;\nexport type CodeAnalysisFile = v.InferOutput<\n typeof CodeAnalysisFileSchema\n>;\n"],"mappings":";;;AAGA,MAAa,wBAAwB,EAAE,SAAS;CAC9C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAa,mBAAmB,EAAE,OAAO;CACvC,iBAAiB,EAAE,OAAO;CAC1B,MAAM,EAAE,SAAS;EAAC;EAAW;EAAS;EAAa;CAAa,CAAC;CACjE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;CAC5C,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC;CAC9B,WAAW,EAAE,SAAS,EAAE,QAAQ,CAAC;CACjC,YAAY,EAAE,SAAS,EAAE,QAAQ,CAAC;AACpC,CAAC;AAED,MAAa,mBAAmB,EAAE,OAAO;CACvC,MAAM,EAAE,OAAO;CACf,MAAM,EAAE,SAAS;EAAC;EAAW;EAAS;CAAW,CAAC;CAClD,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC;CAC3B,iBAAiB,EAAE,SAAS,EAAE,OAAO,CAAC;CACtC,iBAAiB,EAAE,SAAS,qBAAqB;AACnD,CAAC;AAED,MAAa,qBAAqB,EAAE,OAAO;CACzC,cAAc,EAAE,OAAO;CACvB,SAAS,EAAE,MAAM,gBAAgB;CACjC,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;CAC7C,MAAM,EAAE,OAAO;AACjB,CAAC;AAGD,MAAa,yBAAyB,EAAE,OACtC,EAAE,OAAO,GACT,kBACF;AAGA,MAAa,sBAAsB,EAAE,OAAO;CAC1C,OAAO,EAAE,OAAO;CAChB,SAAS,EAAE,OAAO;CAClB,SAAS,EAAE,OAAO;AACpB,CAAC;AAGD,MAAa,yBAAyB,EAAE,OAAO;EAC5C,WAAW,oBAAoB;EAC/B,WAAW,QAAQ,EAAE,SAAS,mBAAmB;AACpD,CAAC"}
|
package/lib/types.d.ts
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* NOmit type - Auto-generated expression
|
|
3
|
-
*
|
|
4
|
-
* ⚠️ WARNING: This expression is auto-generated and should not be modified.
|
|
5
|
-
* @author chlbri (bri_lvi@icloud.com)
|
|
6
|
-
*/
|
|
7
1
|
export type NOmit<T, K extends keyof T> = Omit<T, K>;
|
|
2
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
|
package/lib/utils.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region src/utils.ts
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Converts a file path to a dot notation key as in .manifest.ts
|
|
5
5
|
* Ex: 'features/arrays/castings/all.ts' -> 'features.arrays.castings.all'
|
|
6
6
|
*/
|
|
7
7
|
function pathToDotNotation(filePath) {
|
|
8
|
-
return filePath.replace(/\.ts$/, "").replace(/\//g, ".");
|
|
8
|
+
return filePath.replace(/\.ts$/, "").replace(/\.tsx$/, "").replace(/\//g, ".");
|
|
9
9
|
}
|
|
10
10
|
//#endregion
|
|
11
11
|
exports.pathToDotNotation = pathToDotNotation;
|
package/lib/utils.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["/**\n *
|
|
1
|
+
{"version":3,"file":"utils.cjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["/**\n * Converts a file path to a dot notation key as in .manifest.ts\n * Ex: 'features/arrays/castings/all.ts' -> 'features.arrays.castings.all'\n */\nexport function pathToDotNotation(filePath: string): string {\n return filePath\n .replace(/\\.ts$/, '') // Remove the .ts extension\n .replace(/\\.tsx$/, '') // Remove the .tsx extension\n .replace(/\\//g, '.'); // Replace / with .\n}\n"],"mappings":";;;;;;AAIA,SAAgB,kBAAkB,UAA0B;CAC1D,OAAO,SACJ,QAAQ,SAAS,EAAE,CAAC,CACpB,QAAQ,UAAU,EAAE,CAAC,CACrB,QAAQ,OAAO,GAAG;AACvB"}
|
package/lib/utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Converts a file path to a dot notation key as in .manifest.ts
|
|
3
3
|
* Ex: 'features/arrays/castings/all.ts' -> 'features.arrays.castings.all'
|
|
4
4
|
*/
|
|
5
5
|
export declare function pathToDotNotation(filePath: string): string;
|
|
6
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAK1D"}
|
package/lib/utils.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
//#region src/utils.ts
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Converts a file path to a dot notation key as in .manifest.ts
|
|
4
4
|
* Ex: 'features/arrays/castings/all.ts' -> 'features.arrays.castings.all'
|
|
5
5
|
*/
|
|
6
6
|
function pathToDotNotation(filePath) {
|
|
7
|
-
return filePath.replace(/\.ts$/, "").replace(/\//g, ".");
|
|
7
|
+
return filePath.replace(/\.ts$/, "").replace(/\.tsx$/, "").replace(/\//g, ".");
|
|
8
8
|
}
|
|
9
9
|
//#endregion
|
|
10
10
|
export { pathToDotNotation };
|
package/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["/**\n *
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["/**\n * Converts a file path to a dot notation key as in .manifest.ts\n * Ex: 'features/arrays/castings/all.ts' -> 'features.arrays.castings.all'\n */\nexport function pathToDotNotation(filePath: string): string {\n return filePath\n .replace(/\\.ts$/, '') // Remove the .ts extension\n .replace(/\\.tsx$/, '') // Remove the .tsx extension\n .replace(/\\//g, '.'); // Replace / with .\n}\n"],"mappings":";;;;;AAIA,SAAgB,kBAAkB,UAA0B;CAC1D,OAAO,SACJ,QAAQ,SAAS,EAAE,CAAC,CACpB,QAAQ,UAAU,EAAE,CAAC,CACrB,QAAQ,OAAO,GAAG;AACvB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bemedev/codebase",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "The CLI for to generate codebase, and import partially a library. From @bemedev.",
|
|
5
5
|
"author": {
|
|
6
6
|
"email": "bri_lvi@icloud.com",
|
|
@@ -16,6 +16,13 @@
|
|
|
16
16
|
"main": "lib/index.js",
|
|
17
17
|
"types": "lib/index.d.ts",
|
|
18
18
|
"module": "lib/index.js",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./lib/index.d.ts",
|
|
22
|
+
"import": "./lib/index.js",
|
|
23
|
+
"require": "./lib/index.cjs"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
19
26
|
"maintainers": [
|
|
20
27
|
{
|
|
21
28
|
"email": "bri_lvi@icloud.com",
|
|
@@ -48,26 +55,45 @@
|
|
|
48
55
|
"partial installation"
|
|
49
56
|
],
|
|
50
57
|
"files": [
|
|
51
|
-
"CHANGE_LOG.md",
|
|
52
|
-
"CONTRIBUTING.md",
|
|
53
|
-
"LICENSE",
|
|
54
|
-
"README.md",
|
|
55
58
|
"lib",
|
|
56
|
-
"package.json"
|
|
57
|
-
"public"
|
|
59
|
+
"package.json"
|
|
58
60
|
],
|
|
59
61
|
"engines": {
|
|
60
62
|
"node": ">=24"
|
|
61
63
|
},
|
|
62
|
-
"
|
|
64
|
+
"size-limit": [
|
|
65
|
+
{
|
|
66
|
+
"path": "lib/*.js",
|
|
67
|
+
"limit": "10 KB"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"path": "lib/*.cjs",
|
|
71
|
+
"limit": "10 KB"
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
"devDependencies": {
|
|
75
|
+
"@bemedev/dev-utils": "^0.8.0",
|
|
76
|
+
"@size-limit/file": "^12.1.0",
|
|
77
|
+
"@types/node": "^25.9.3",
|
|
78
|
+
"rolldown": "1.1.1",
|
|
79
|
+
"size-limit": "^12.1.0",
|
|
80
|
+
"tsx": "^4.22.4",
|
|
81
|
+
"typescript": "^6.0.3"
|
|
82
|
+
},
|
|
83
|
+
"dependencies": {
|
|
84
|
+
"cmd-ts": "^0.15.0",
|
|
85
|
+
"edit-json-file": "^1.8.1",
|
|
86
|
+
"ts-morph": "^28.0.0",
|
|
87
|
+
"valibot": "^1.4.1"
|
|
88
|
+
},
|
|
63
89
|
"scripts": {
|
|
64
|
-
"build": "pnpm rm:lib && pnpm run rolldown && pnpm run codegen",
|
|
65
|
-
"
|
|
66
|
-
"ci
|
|
67
|
-
"
|
|
90
|
+
"build": "pnpm rm:lib && pnpm run rolldown && pnpm run codegen && chmod +x lib/cli/index.js",
|
|
91
|
+
"_ci": "pnpm run config:off && pnpm run lint && pnpm run test",
|
|
92
|
+
"ci": "CI_START=$(date +%s) && pnpm run _ci && pnpm run p-q && echo \"\n✅ CI takes $(($(date +%s) - CI_START))s\n\"",
|
|
93
|
+
"ci:admin": "CI_START=$(date +%s) && pnpm run rm && pnpm run upgrade && pnpm run _ci && echo \"\n✅ CI_ADMIN takes $(($(date +%s) - CI_START))s\n\"",
|
|
94
|
+
"codegen": "tsx ./src/cli/index.ts",
|
|
68
95
|
"config": "pnpm install",
|
|
69
96
|
"config:off": "pnpm run config --offline",
|
|
70
|
-
"config:vitest": "pnpm add -D @vitest/coverage-v8@3.2.4 vitest@3.2.4 @vitest/ui@3.2.4",
|
|
71
97
|
"fmt": "oxfmt",
|
|
72
98
|
"fmt:check": "oxfmt --check",
|
|
73
99
|
"lint": "pnpm run fmt && pnpm run lint:fix",
|
|
@@ -75,8 +101,6 @@
|
|
|
75
101
|
"lint:watch": "onchange --await-write-finish 1500 -d 10000 -v \"**/*.ts\" -- pnpm run lint",
|
|
76
102
|
"p-q": "pretty-quick",
|
|
77
103
|
"posttest": "pnpm run fmt",
|
|
78
|
-
"prepare": "husky",
|
|
79
|
-
"prepublishOnly": "",
|
|
80
104
|
"pretest": "pnpm run build && pnpm run size",
|
|
81
105
|
"prettier": "prettier --write \"src/**/*.{ts,tsx}\"",
|
|
82
106
|
"rinit": "pnpm run rm && pnpm run config",
|
|
@@ -91,52 +115,9 @@
|
|
|
91
115
|
"test:only": "pnpm run test:coverage --no-coverage",
|
|
92
116
|
"test:ui": "vitest --ui",
|
|
93
117
|
"test:watch": "vitest",
|
|
94
|
-
"upgrade": "pnpm upgrade --latest
|
|
118
|
+
"upgrade": "pnpm upgrade --latest"
|
|
95
119
|
},
|
|
96
|
-
"
|
|
97
|
-
|
|
98
|
-
"path": "lib/*.js",
|
|
99
|
-
"limit": "10 KB"
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
"path": "lib/*.cjs",
|
|
103
|
-
"limit": "10 KB"
|
|
104
|
-
}
|
|
105
|
-
],
|
|
106
|
-
"devDependencies": {
|
|
107
|
-
"@bemedev/decompose": "^2.2.0",
|
|
108
|
-
"@bemedev/dev-utils": "^0.5.2",
|
|
109
|
-
"@bemedev/fsf": "^1.0.1",
|
|
110
|
-
"@size-limit/file": "^12.0.1",
|
|
111
|
-
"@types/edit-json-file": "^1.7.4",
|
|
112
|
-
"@types/node": "^25.5.2",
|
|
113
|
-
"@vitest/coverage-v8": "3.2.4",
|
|
114
|
-
"@vitest/ui": "3.2.4",
|
|
115
|
-
"glob": "^13.0.6",
|
|
116
|
-
"globals": "^17.4.0",
|
|
117
|
-
"husky": "^9.1.7",
|
|
118
|
-
"onchange": "^7.1.0",
|
|
119
|
-
"oxfmt": "^0.43.0",
|
|
120
|
-
"oxlint": "^1.58.0",
|
|
121
|
-
"prettier": "^3.8.1",
|
|
122
|
-
"pretty-quick": "^4.2.2",
|
|
123
|
-
"rolldown": "1.0.0-rc.13",
|
|
124
|
-
"size-limit": "^12.0.1",
|
|
125
|
-
"this": "file:",
|
|
126
|
-
"tslib": "^2.8.1",
|
|
127
|
-
"tsx": "^4.21.0",
|
|
128
|
-
"typescript": "^6.0.2",
|
|
129
|
-
"vitest": "3.2.4"
|
|
130
|
-
},
|
|
131
|
-
"pnpm": {
|
|
132
|
-
"onlyBuiltDependencies": [
|
|
133
|
-
"esbuild"
|
|
134
|
-
]
|
|
135
|
-
},
|
|
136
|
-
"dependencies": {
|
|
137
|
-
"cmd-ts": "^0.15.0",
|
|
138
|
-
"edit-json-file": "^1.8.1",
|
|
139
|
-
"ts-morph": "^27.0.2",
|
|
140
|
-
"valibot": "^1.3.1"
|
|
120
|
+
"bin": {
|
|
121
|
+
"codebase": "lib/cli/index.js"
|
|
141
122
|
}
|
|
142
|
-
}
|
|
123
|
+
}
|