@xylabs/ts-scripts-yarn3 6.5.18 → 7.0.0-rc.10

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.
Files changed (38) hide show
  1. package/dist/actions/index.mjs +110 -130
  2. package/dist/actions/index.mjs.map +1 -1
  3. package/dist/actions/package/compile/buildEntries.mjs +8 -1
  4. package/dist/actions/package/compile/buildEntries.mjs.map +1 -1
  5. package/dist/actions/package/compile/compile.mjs +87 -107
  6. package/dist/actions/package/compile/compile.mjs.map +1 -1
  7. package/dist/actions/package/compile/index.mjs +88 -108
  8. package/dist/actions/package/compile/index.mjs.map +1 -1
  9. package/dist/actions/package/compile/packageCompileTsc.mjs +9 -35
  10. package/dist/actions/package/compile/packageCompileTsc.mjs.map +1 -1
  11. package/dist/actions/package/compile/packageCompileTscTypes.mjs +29 -102
  12. package/dist/actions/package/compile/packageCompileTscTypes.mjs.map +1 -1
  13. package/dist/actions/package/compile/packageCompileTsup.mjs +96 -135
  14. package/dist/actions/package/compile/packageCompileTsup.mjs.map +1 -1
  15. package/dist/actions/package/index.mjs +100 -120
  16. package/dist/actions/package/index.mjs.map +1 -1
  17. package/dist/actions/package/recompile.mjs +87 -107
  18. package/dist/actions/package/recompile.mjs.map +1 -1
  19. package/dist/bin/package/build-only.mjs +89 -109
  20. package/dist/bin/package/build-only.mjs.map +1 -1
  21. package/dist/bin/package/build.mjs +89 -109
  22. package/dist/bin/package/build.mjs.map +1 -1
  23. package/dist/bin/package/compile-only.mjs +89 -109
  24. package/dist/bin/package/compile-only.mjs.map +1 -1
  25. package/dist/bin/package/compile-tsup.mjs +101 -140
  26. package/dist/bin/package/compile-tsup.mjs.map +1 -1
  27. package/dist/bin/package/compile.mjs +89 -109
  28. package/dist/bin/package/compile.mjs.map +1 -1
  29. package/dist/bin/package/recompile.mjs +89 -109
  30. package/dist/bin/package/recompile.mjs.map +1 -1
  31. package/dist/index.d.ts +24 -7
  32. package/dist/index.mjs +122 -142
  33. package/dist/index.mjs.map +1 -1
  34. package/package.json +8 -5
  35. package/dist/actions/package/compile/compileTypes.mjs +0 -138
  36. package/dist/actions/package/compile/compileTypes.mjs.map +0 -1
  37. package/dist/bin/package/compile-types.mjs +0 -150
  38. package/dist/bin/package/compile-types.mjs.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xylabs/ts-scripts-yarn3",
3
- "version": "6.5.18",
3
+ "version": "7.0.0-rc.10",
4
4
  "description": "TypeScript project scripts",
5
5
  "keywords": [
6
6
  "xylabs",
@@ -39,7 +39,6 @@
39
39
  "package-clean": "dist/bin/package/clean.mjs",
40
40
  "package-compile": "dist/bin/package/compile.mjs",
41
41
  "package-compile-only": "dist/bin/package/compile-only.mjs",
42
- "package-compile-types": "dist/bin/package/compile-types.mjs",
43
42
  "package-copy-assets-cjs": "dist/bin/package/copy-assets-cjs.mjs",
44
43
  "package-copy-assets-esm": "dist/bin/package/copy-assets-esm.mjs",
45
44
  "package-cycle": "dist/bin/package/cycle.mjs",
@@ -76,6 +75,9 @@
76
75
  "parse-git-config": "^3.0.0",
77
76
  "picomatch": "^4.0.2",
78
77
  "publint": "^0.3.12",
78
+ "rollup": "^4.44.2",
79
+ "rollup-plugin-dts": "^6.2.1",
80
+ "rollup-plugin-node-externals": "^8.0.1",
79
81
  "sort-package-json": "^3.4.0",
80
82
  "tsc-prog": "^2.3.0",
81
83
  "tsup": "8.5.0",
@@ -85,11 +87,11 @@
85
87
  "devDependencies": {
86
88
  "@types/eslint": "^9.6.1",
87
89
  "@types/license-checker": "^25.0.6",
88
- "@types/node": "^24.0.11",
90
+ "@types/node": "^24.0.12",
89
91
  "@types/parse-git-config": "^3.0.4",
90
92
  "@types/picomatch": "^4.0.0",
91
93
  "@types/yargs": "^17.0.33",
92
- "@xylabs/tsconfig": "^6.5.18",
94
+ "@xylabs/tsconfig": "^7.0.0-rc.10",
93
95
  "esbuild": "0.25.6",
94
96
  "knip": "^5.61.3",
95
97
  "rimraf": "^6.0.1",
@@ -105,5 +107,6 @@
105
107
  "engineStrict": true,
106
108
  "publishConfig": {
107
109
  "access": "public"
108
- }
110
+ },
111
+ "stableVersion": "6.5.14"
109
112
  }
@@ -1,138 +0,0 @@
1
- // src/lib/loadConfig.ts
2
- import chalk from "chalk";
3
- import { cosmiconfig } from "cosmiconfig";
4
- import { TypeScriptLoader } from "cosmiconfig-typescript-loader";
5
- import deepmerge from "deepmerge";
6
- var config;
7
- var loadConfig = async (params) => {
8
- if (config) {
9
- return deepmerge(config, params ?? {});
10
- }
11
- const cosmicConfigResult = await cosmiconfig("xy", { cache: true, loaders: { ".ts": TypeScriptLoader() } }).search();
12
- config = cosmicConfigResult?.config;
13
- const configFilePath = cosmicConfigResult?.filepath;
14
- if (configFilePath) {
15
- console.log(chalk.gray(`Loading config from ${configFilePath}`));
16
- }
17
- return deepmerge(config, params ?? {});
18
- };
19
-
20
- // src/actions/package/compile/packageCompileTscTypes.ts
21
- import { cwd } from "process";
22
- import chalk2 from "chalk";
23
- import { createProgramFromConfig } from "tsc-prog";
24
- import {
25
- DiagnosticCategory,
26
- formatDiagnosticsWithColorAndContext,
27
- getPreEmitDiagnostics,
28
- sys as sys2
29
- } from "typescript";
30
-
31
- // src/actions/package/compile/inputs.ts
32
- import { glob } from "glob";
33
- var getAllInputs = (folder) => {
34
- return glob.sync(`${folder}/**/*.*`, { posix: true });
35
- };
36
-
37
- // src/actions/package/compile/buildEntries.ts
38
- var buildEntries = (folder, entryMode = "single", excludeSpecAndStories = true, verbose = false) => {
39
- let entries = [];
40
- switch (entryMode) {
41
- case "platform": {
42
- entries = [`${folder}/index-node.ts`, `${folder}/index-browser.ts`];
43
- break;
44
- }
45
- case "all": {
46
- entries = excludeSpecAndStories ? getAllInputs(folder).filter((entry) => !entry.includes(".spec.") && !entry.includes(".stories.")) : getAllInputs(folder);
47
- break;
48
- }
49
- default: {
50
- entries = [`${folder}/index.ts`];
51
- break;
52
- }
53
- }
54
- if (verbose) console.log(`buildEntries [${entryMode}] ${entries.length}`);
55
- return entries;
56
- };
57
-
58
- // src/actions/package/compile/getCompilerOptions.ts
59
- import { createRequire } from "module";
60
- import deepmerge2 from "deepmerge";
61
- import {
62
- findConfigFile,
63
- readConfigFile,
64
- sys
65
- } from "typescript";
66
- var getNested = (config2) => {
67
- if (config2.extends) {
68
- const require2 = createRequire(import.meta.url);
69
- const opts = require2(config2.extends);
70
- return deepmerge2(getNested(opts), config2.compilerOptions ?? {});
71
- }
72
- return config2.compilerOptions;
73
- };
74
- var getCompilerOptionsJSONFollowExtends = (filename) => {
75
- const config2 = readConfigFile(filename, sys.readFile).config;
76
- return getNested(config2);
77
- };
78
- var getCompilerOptions = (options = {}, tsconfig = "tsconfig.json") => {
79
- const configFileName = findConfigFile("./", sys.fileExists, tsconfig);
80
- const configFileCompilerOptions = (configFileName ? getCompilerOptionsJSONFollowExtends(configFileName) : void 0) ?? {};
81
- return deepmerge2(configFileCompilerOptions, options);
82
- };
83
-
84
- // src/actions/package/compile/packageCompileTscTypes.ts
85
- var packageCompileTscTypes = (folder = "src", config2 = {}, compilerOptionsParam) => {
86
- const pkg = process.env.INIT_CWD ?? cwd();
87
- const verbose = config2?.verbose ?? false;
88
- const compilerOptions = {
89
- ...getCompilerOptions({
90
- emitDeclarationOnly: true,
91
- outDir: config2.compile?.tsup?.options?.outDir ?? "dist/types",
92
- removeComments: false,
93
- skipDefaultLibCheck: true,
94
- skipLibCheck: true,
95
- sourceMap: false
96
- }),
97
- ...compilerOptionsParam,
98
- emitDeclarationOnly: true,
99
- noEmit: false
100
- };
101
- const validTsExt = [".ts", ".tsx", ".d.ts", ".cts", ".d.cts", ".mts", ".d.mts"];
102
- const excludes = [".stories.", ".spec.", "/stories/", "/spec/"];
103
- const files = buildEntries(folder, "all", verbose).filter((file) => validTsExt.find((ext) => file.endsWith(ext)) && !excludes.some((exclude) => file.includes(exclude)));
104
- console.log(chalk2.green(`Compiling Types ${pkg}: ${files.length}`));
105
- if (files.length > 0) {
106
- const program = createProgramFromConfig({
107
- basePath: pkg ?? cwd(),
108
- compilerOptions,
109
- exclude: ["build", "dist", "docs", "**/*.spec.*", "**/*.stories.*", "src/**/spec/**/*"],
110
- files
111
- });
112
- const diagnostics = getPreEmitDiagnostics(program);
113
- if (diagnostics.length > 0) {
114
- const formattedDiagnostics = formatDiagnosticsWithColorAndContext(
115
- diagnostics,
116
- {
117
- getCanonicalFileName: (fileName) => fileName,
118
- getCurrentDirectory: () => folder,
119
- getNewLine: () => sys2.newLine
120
- }
121
- );
122
- console.error(formattedDiagnostics);
123
- }
124
- program.emit();
125
- return diagnostics.reduce((acc, diag) => acc + (diag.category === DiagnosticCategory.Error ? 1 : 0), 0);
126
- }
127
- return 0;
128
- };
129
-
130
- // src/actions/package/compile/compileTypes.ts
131
- var packageCompileTypes = async (inConfig = {}) => {
132
- const config2 = await loadConfig(inConfig);
133
- return packageCompileTscTypes(void 0, config2);
134
- };
135
- export {
136
- packageCompileTypes
137
- };
138
- //# sourceMappingURL=compileTypes.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/lib/loadConfig.ts","../../../../src/actions/package/compile/packageCompileTscTypes.ts","../../../../src/actions/package/compile/inputs.ts","../../../../src/actions/package/compile/buildEntries.ts","../../../../src/actions/package/compile/getCompilerOptions.ts","../../../../src/actions/package/compile/compileTypes.ts"],"sourcesContent":["import chalk from 'chalk'\nimport { cosmiconfig } from 'cosmiconfig'\nimport { TypeScriptLoader } from 'cosmiconfig-typescript-loader'\nimport deepmerge from 'deepmerge'\n\nlet config: Record<string, unknown>\n\nexport const loadConfig = async <T extends object>(params?: T): Promise<T> => {\n if (config) {\n return deepmerge(config, params ?? {}) as T\n }\n\n const cosmicConfigResult = await cosmiconfig('xy', { cache: true, loaders: { '.ts': TypeScriptLoader() } }).search()\n config = cosmicConfigResult?.config\n const configFilePath = cosmicConfigResult?.filepath\n if (configFilePath) {\n console.log(chalk.gray(`Loading config from ${configFilePath}`))\n }\n return deepmerge(config, params ?? {}) as T\n}\n","import { cwd } from 'node:process'\n\nimport chalk from 'chalk'\nimport type { TsConfigCompilerOptions } from 'tsc-prog'\nimport { createProgramFromConfig } from 'tsc-prog'\nimport type { CompilerOptions } from 'typescript'\nimport {\n DiagnosticCategory, formatDiagnosticsWithColorAndContext, getPreEmitDiagnostics, sys,\n} from 'typescript'\n\nimport { buildEntries } from './buildEntries.ts'\nimport { getCompilerOptions } from './getCompilerOptions.ts'\nimport type { XyConfig, XyTsupConfig } from './XyConfig.ts'\n\nexport const packageCompileTscTypes = (\n folder: string = 'src',\n config: XyConfig = {},\n compilerOptionsParam?: CompilerOptions,\n): number => {\n const pkg = process.env.INIT_CWD ?? cwd()\n const verbose = config?.verbose ?? false\n\n const compilerOptions = {\n ...(getCompilerOptions({\n emitDeclarationOnly: true,\n outDir: (config as XyTsupConfig).compile?.tsup?.options?.outDir ?? 'dist/types',\n removeComments: false,\n skipDefaultLibCheck: true,\n skipLibCheck: true,\n sourceMap: false,\n })),\n ...compilerOptionsParam,\n emitDeclarationOnly: true,\n noEmit: false,\n } as TsConfigCompilerOptions\n\n const validTsExt = ['.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts']\n const excludes = ['.stories.', '.spec.', '/stories/', '/spec/']\n\n // calling all here since the types do not get rolled up\n const files = buildEntries(folder, 'all', verbose)\n .filter(file => validTsExt.find(ext => file.endsWith(ext)) && !(excludes.some(exclude => file.includes(exclude))))\n\n console.log(chalk.green(`Compiling Types ${pkg}: ${files.length}`))\n\n if (files.length > 0) {\n const program = createProgramFromConfig({\n basePath: pkg ?? cwd(),\n compilerOptions,\n exclude: ['build', 'dist', 'docs', '**/*.spec.*', '**/*.stories.*', 'src/**/spec/**/*'],\n files,\n })\n\n const diagnostics = getPreEmitDiagnostics(program)\n\n if (diagnostics.length > 0) {\n const formattedDiagnostics = formatDiagnosticsWithColorAndContext(\n diagnostics,\n {\n getCanonicalFileName: fileName => fileName,\n getCurrentDirectory: () => folder,\n getNewLine: () => sys.newLine,\n },\n )\n console.error(formattedDiagnostics)\n }\n\n program.emit()\n return diagnostics.reduce((acc, diag) => acc + (diag.category === DiagnosticCategory.Error ? 1 : 0), 0)\n }\n return 0\n}\n","import { glob } from 'glob'\n\nexport const getAllInputs = (folder: string) => {\n /* tsup wants posix paths */\n return glob.sync(`${folder}/**/*.*`, { posix: true })\n}\n","import { getAllInputs } from './inputs.ts'\nimport type { EntryMode } from './XyConfig.ts'\n\nexport const buildEntries = (folder: string, entryMode: EntryMode = 'single', excludeSpecAndStories = true, verbose = false) => {\n let entries: string[] = []\n switch (entryMode) {\n case 'platform': {\n entries = [`${folder}/index-node.ts`, `${folder}/index-browser.ts`]\n break\n }\n case 'all': {\n entries = excludeSpecAndStories ? getAllInputs(folder).filter(entry => !entry.includes('.spec.') && !entry.includes('.stories.')) : getAllInputs(folder)\n break\n }\n default: {\n entries = [`${folder}/index.ts`]\n break\n }\n }\n if (verbose) console.log(`buildEntries [${entryMode}] ${entries.length}`)\n return entries\n}\n","import { createRequire } from 'node:module'\n\nimport deepmerge from 'deepmerge'\nimport type { TsConfig } from 'tsc-prog'\nimport type { CompilerOptions } from 'typescript'\nimport {\n findConfigFile, readConfigFile, sys,\n} from 'typescript'\n\nconst getNested = (config: TsConfig): CompilerOptions => {\n if (config.extends) {\n const require = createRequire(import.meta.url)\n const opts = require(config.extends)\n return deepmerge(getNested(opts), config.compilerOptions ?? {}) as CompilerOptions\n }\n\n return config.compilerOptions as CompilerOptions\n}\n\nconst getCompilerOptionsJSONFollowExtends = (filename: string): CompilerOptions => {\n const config = readConfigFile(filename, sys.readFile).config\n return getNested(config)\n}\n\nexport const getCompilerOptions = (options: CompilerOptions = {}, tsconfig: string = 'tsconfig.json'): CompilerOptions => {\n const configFileName = findConfigFile('./', sys.fileExists, tsconfig)\n const configFileCompilerOptions = (configFileName ? getCompilerOptionsJSONFollowExtends(configFileName) : undefined) ?? {}\n\n return deepmerge(configFileCompilerOptions, options)\n}\n","import { loadConfig } from '../../../lib/index.ts'\nimport { packageCompileTscTypes } from './packageCompileTscTypes.ts'\nimport type { XyConfig, XyTscConfig } from './XyConfig.ts'\n\nexport const packageCompileTypes = async (inConfig: XyConfig = {}): Promise<number> => {\n const config = await loadConfig(inConfig)\n\n return packageCompileTscTypes(undefined, config as XyTscConfig)\n}\n"],"mappings":";AAAA,OAAO,WAAW;AAClB,SAAS,mBAAmB;AAC5B,SAAS,wBAAwB;AACjC,OAAO,eAAe;AAEtB,IAAI;AAEG,IAAM,aAAa,OAAyB,WAA2B;AAC5E,MAAI,QAAQ;AACV,WAAO,UAAU,QAAQ,UAAU,CAAC,CAAC;AAAA,EACvC;AAEA,QAAM,qBAAqB,MAAM,YAAY,MAAM,EAAE,OAAO,MAAM,SAAS,EAAE,OAAO,iBAAiB,EAAE,EAAE,CAAC,EAAE,OAAO;AACnH,WAAS,oBAAoB;AAC7B,QAAM,iBAAiB,oBAAoB;AAC3C,MAAI,gBAAgB;AAClB,YAAQ,IAAI,MAAM,KAAK,uBAAuB,cAAc,EAAE,CAAC;AAAA,EACjE;AACA,SAAO,UAAU,QAAQ,UAAU,CAAC,CAAC;AACvC;;;ACnBA,SAAS,WAAW;AAEpB,OAAOA,YAAW;AAElB,SAAS,+BAA+B;AAExC;AAAA,EACE;AAAA,EAAoB;AAAA,EAAsC;AAAA,EAAuB,OAAAC;AAAA,OAC5E;;;ACRP,SAAS,YAAY;AAEd,IAAM,eAAe,CAAC,WAAmB;AAE9C,SAAO,KAAK,KAAK,GAAG,MAAM,WAAW,EAAE,OAAO,KAAK,CAAC;AACtD;;;ACFO,IAAM,eAAe,CAAC,QAAgB,YAAuB,UAAU,wBAAwB,MAAM,UAAU,UAAU;AAC9H,MAAI,UAAoB,CAAC;AACzB,UAAQ,WAAW;AAAA,IACjB,KAAK,YAAY;AACf,gBAAU,CAAC,GAAG,MAAM,kBAAkB,GAAG,MAAM,mBAAmB;AAClE;AAAA,IACF;AAAA,IACA,KAAK,OAA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uBAAuB,QAAWA,OAAqB;AAChE;","names":["chalk","sys","deepmerge","config","require","config","chalk","sys","config"]}
@@ -1,150 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/bin/package/compile-types.ts
4
- import chalk3 from "chalk";
5
-
6
- // src/lib/loadConfig.ts
7
- import chalk from "chalk";
8
- import { cosmiconfig } from "cosmiconfig";
9
- import { TypeScriptLoader } from "cosmiconfig-typescript-loader";
10
- import deepmerge from "deepmerge";
11
- var config;
12
- var loadConfig = async (params) => {
13
- if (config) {
14
- return deepmerge(config, params ?? {});
15
- }
16
- const cosmicConfigResult = await cosmiconfig("xy", { cache: true, loaders: { ".ts": TypeScriptLoader() } }).search();
17
- config = cosmicConfigResult?.config;
18
- const configFilePath = cosmicConfigResult?.filepath;
19
- if (configFilePath) {
20
- console.log(chalk.gray(`Loading config from ${configFilePath}`));
21
- }
22
- return deepmerge(config, params ?? {});
23
- };
24
-
25
- // src/actions/package/compile/inputs.ts
26
- import { glob } from "glob";
27
- var getAllInputs = (folder) => {
28
- return glob.sync(`${folder}/**/*.*`, { posix: true });
29
- };
30
-
31
- // src/actions/package/compile/buildEntries.ts
32
- var buildEntries = (folder, entryMode = "single", excludeSpecAndStories = true, verbose = false) => {
33
- let entries = [];
34
- switch (entryMode) {
35
- case "platform": {
36
- entries = [`${folder}/index-node.ts`, `${folder}/index-browser.ts`];
37
- break;
38
- }
39
- case "all": {
40
- entries = excludeSpecAndStories ? getAllInputs(folder).filter((entry) => !entry.includes(".spec.") && !entry.includes(".stories.")) : getAllInputs(folder);
41
- break;
42
- }
43
- default: {
44
- entries = [`${folder}/index.ts`];
45
- break;
46
- }
47
- }
48
- if (verbose) console.log(`buildEntries [${entryMode}] ${entries.length}`);
49
- return entries;
50
- };
51
-
52
- // src/actions/package/compile/packageCompileTscTypes.ts
53
- import { cwd } from "process";
54
- import chalk2 from "chalk";
55
- import { createProgramFromConfig } from "tsc-prog";
56
- import {
57
- DiagnosticCategory,
58
- formatDiagnosticsWithColorAndContext,
59
- getPreEmitDiagnostics,
60
- sys as sys2
61
- } from "typescript";
62
-
63
- // src/actions/package/compile/getCompilerOptions.ts
64
- import { createRequire } from "module";
65
- import deepmerge2 from "deepmerge";
66
- import {
67
- findConfigFile,
68
- readConfigFile,
69
- sys
70
- } from "typescript";
71
- var getNested = (config2) => {
72
- if (config2.extends) {
73
- const require2 = createRequire(import.meta.url);
74
- const opts = require2(config2.extends);
75
- return deepmerge2(getNested(opts), config2.compilerOptions ?? {});
76
- }
77
- return config2.compilerOptions;
78
- };
79
- var getCompilerOptionsJSONFollowExtends = (filename) => {
80
- const config2 = readConfigFile(filename, sys.readFile).config;
81
- return getNested(config2);
82
- };
83
- var getCompilerOptions = (options = {}, tsconfig = "tsconfig.json") => {
84
- const configFileName = findConfigFile("./", sys.fileExists, tsconfig);
85
- const configFileCompilerOptions = (configFileName ? getCompilerOptionsJSONFollowExtends(configFileName) : void 0) ?? {};
86
- return deepmerge2(configFileCompilerOptions, options);
87
- };
88
-
89
- // src/actions/package/compile/packageCompileTscTypes.ts
90
- var packageCompileTscTypes = (folder = "src", config2 = {}, compilerOptionsParam) => {
91
- const pkg = process.env.INIT_CWD ?? cwd();
92
- const verbose = config2?.verbose ?? false;
93
- const compilerOptions = {
94
- ...getCompilerOptions({
95
- emitDeclarationOnly: true,
96
- outDir: config2.compile?.tsup?.options?.outDir ?? "dist/types",
97
- removeComments: false,
98
- skipDefaultLibCheck: true,
99
- skipLibCheck: true,
100
- sourceMap: false
101
- }),
102
- ...compilerOptionsParam,
103
- emitDeclarationOnly: true,
104
- noEmit: false
105
- };
106
- const validTsExt = [".ts", ".tsx", ".d.ts", ".cts", ".d.cts", ".mts", ".d.mts"];
107
- const excludes = [".stories.", ".spec.", "/stories/", "/spec/"];
108
- const files = buildEntries(folder, "all", verbose).filter((file) => validTsExt.find((ext) => file.endsWith(ext)) && !excludes.some((exclude) => file.includes(exclude)));
109
- console.log(chalk2.green(`Compiling Types ${pkg}: ${files.length}`));
110
- if (files.length > 0) {
111
- const program = createProgramFromConfig({
112
- basePath: pkg ?? cwd(),
113
- compilerOptions,
114
- exclude: ["build", "dist", "docs", "**/*.spec.*", "**/*.stories.*", "src/**/spec/**/*"],
115
- files
116
- });
117
- const diagnostics = getPreEmitDiagnostics(program);
118
- if (diagnostics.length > 0) {
119
- const formattedDiagnostics = formatDiagnosticsWithColorAndContext(
120
- diagnostics,
121
- {
122
- getCanonicalFileName: (fileName) => fileName,
123
- getCurrentDirectory: () => folder,
124
- getNewLine: () => sys2.newLine
125
- }
126
- );
127
- console.error(formattedDiagnostics);
128
- }
129
- program.emit();
130
- return diagnostics.reduce((acc, diag) => acc + (diag.category === DiagnosticCategory.Error ? 1 : 0), 0);
131
- }
132
- return 0;
133
- };
134
-
135
- // src/actions/package/compile/compileTypes.ts
136
- var packageCompileTypes = async (inConfig = {}) => {
137
- const config2 = await loadConfig(inConfig);
138
- return packageCompileTscTypes(void 0, config2);
139
- };
140
-
141
- // src/bin/package/compile-types.ts
142
- packageCompileTypes({ verbose: true }).then((value) => {
143
- if (value) {
144
- process.exit(value);
145
- }
146
- }).catch((reason) => {
147
- console.error(chalk3.red(reason));
148
- process.exit(-1);
149
- });
150
- //# sourceMappingURL=compile-types.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/bin/package/compile-types.ts","../../../src/lib/loadConfig.ts","../../../src/actions/package/compile/inputs.ts","../../../src/actions/package/compile/buildEntries.ts","../../../src/actions/package/compile/packageCompileTscTypes.ts","../../../src/actions/package/compile/getCompilerOptions.ts","../../../src/actions/package/compile/compileTypes.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport chalk from 'chalk'\n\nimport { packageCompileTypes } from '../../actions/index.ts'\n\npackageCompileTypes({ verbose: true })\n .then((value) => {\n if (value) {\n process.exit(value)\n }\n })\n .catch((reason) => {\n console.error(chalk.red(reason))\n process.exit(-1)\n })\n","import chalk from 'chalk'\nimport { cosmiconfig } from 'cosmiconfig'\nimport { TypeScriptLoader } from 'cosmiconfig-typescript-loader'\nimport deepmerge from 'deepmerge'\n\nlet config: Record<string, unknown>\n\nexport const loadConfig = async <T extends object>(params?: T): Promise<T> => {\n if (config) {\n return deepmerge(config, params ?? {}) as T\n }\n\n const cosmicConfigResult = await cosmiconfig('xy', { cache: true, loaders: { '.ts': TypeScriptLoader() } }).search()\n config = cosmicConfigResult?.config\n const configFilePath = cosmicConfigResult?.filepath\n if (configFilePath) {\n console.log(chalk.gray(`Loading config from ${configFilePath}`))\n }\n return deepmerge(config, params ?? {}) as T\n}\n","import { glob } from 'glob'\n\nexport const getAllInputs = (folder: string) => {\n /* tsup wants posix paths */\n return glob.sync(`${folder}/**/*.*`, { posix: true })\n}\n","import { getAllInputs } from './inputs.ts'\nimport type { EntryMode } from './XyConfig.ts'\n\nexport const buildEntries = (folder: string, entryMode: EntryMode = 'single', excludeSpecAndStories = true, verbose = false) => {\n let entries: string[] = []\n switch (entryMode) {\n case 'platform': {\n entries = [`${folder}/index-node.ts`, `${folder}/index-browser.ts`]\n break\n }\n case 'all': {\n entries = excludeSpecAndStories ? getAllInputs(folder).filter(entry => !entry.includes('.spec.') && !entry.includes('.stories.')) : getAllInputs(folder)\n break\n }\n default: {\n entries = [`${folder}/index.ts`]\n break\n }\n }\n if (verbose) console.log(`buildEntries [${entryMode}] ${entries.length}`)\n return entries\n}\n","import { cwd } from 'node:process'\n\nimport chalk from 'chalk'\nimport type { TsConfigCompilerOptions } from 'tsc-prog'\nimport { createProgramFromConfig } from 'tsc-prog'\nimport type { CompilerOptions } from 'typescript'\nimport {\n DiagnosticCategory, formatDiagnosticsWithColorAndContext, getPreEmitDiagnostics, sys,\n} from 'typescript'\n\nimport { buildEntries } from './buildEntries.ts'\nimport { getCompilerOptions } from './getCompilerOptions.ts'\nimport type { XyConfig, XyTsupConfig } from './XyConfig.ts'\n\nexport const packageCompileTscTypes = (\n folder: string = 'src',\n config: XyConfig = {},\n compilerOptionsParam?: CompilerOptions,\n): number => {\n const pkg = process.env.INIT_CWD ?? cwd()\n const verbose = config?.verbose ?? false\n\n const compilerOptions = {\n ...(getCompilerOptions({\n emitDeclarationOnly: true,\n outDir: (config as XyTsupConfig).compile?.tsup?.options?.outDir ?? 'dist/types',\n removeComments: false,\n skipDefaultLibCheck: true,\n skipLibCheck: true,\n sourceMap: false,\n })),\n ...compilerOptionsParam,\n emitDeclarationOnly: true,\n noEmit: false,\n } as TsConfigCompilerOptions\n\n const validTsExt = ['.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts']\n const excludes = ['.stories.', '.spec.', '/stories/', '/spec/']\n\n // calling all here since the types do not get rolled up\n const files = buildEntries(folder, 'all', verbose)\n .filter(file => validTsExt.find(ext => file.endsWith(ext)) && !(excludes.some(exclude => file.includes(exclude))))\n\n console.log(chalk.green(`Compiling Types ${pkg}: ${files.length}`))\n\n if (files.length > 0) {\n const program = createProgramFromConfig({\n basePath: pkg ?? cwd(),\n compilerOptions,\n exclude: ['build', 'dist', 'docs', '**/*.spec.*', '**/*.stories.*', 'src/**/spec/**/*'],\n files,\n })\n\n const diagnostics = getPreEmitDiagnostics(program)\n\n if (diagnostics.length > 0) {\n const formattedDiagnostics = formatDiagnosticsWithColorAndContext(\n diagnostics,\n {\n getCanonicalFileName: fileName => fileName,\n getCurrentDirectory: () => folder,\n getNewLine: () => sys.newLine,\n },\n )\n console.error(formattedDiagnostics)\n }\n\n program.emit()\n return diagnostics.reduce((acc, diag) => acc + (diag.category === DiagnosticCategory.Error ? 1 : 0), 0)\n }\n return 0\n}\n","import { createRequire } from 'node:module'\n\nimport deepmerge from 'deepmerge'\nimport type { TsConfig } from 'tsc-prog'\nimport type { CompilerOptions } from 'typescript'\nimport {\n findConfigFile, readConfigFile, sys,\n} from 'typescript'\n\nconst getNested = (config: TsConfig): CompilerOptions => {\n if (config.extends) {\n const require = createRequire(import.meta.url)\n const opts = require(config.extends)\n return deepmerge(getNested(opts), config.compilerOptions ?? {}) as CompilerOptions\n }\n\n return config.compilerOptions as CompilerOptions\n}\n\nconst getCompilerOptionsJSONFollowExtends = (filename: string): CompilerOptions => {\n const config = readConfigFile(filename, sys.readFile).config\n return getNested(config)\n}\n\nexport const getCompilerOptions = (options: CompilerOptions = {}, tsconfig: string = 'tsconfig.json'): CompilerOptions => {\n const configFileName = findConfigFile('./', sys.fileExists, tsconfig)\n const configFileCompilerOptions = (configFileName ? getCompilerOptionsJSONFollowExtends(configFileName) : undefined) ?? {}\n\n return deepmerge(configFileCompilerOptions, options)\n}\n","import { loadConfig } from '../../../lib/index.ts'\nimport { packageCompileTscTypes } from './packageCompileTscTypes.ts'\nimport type { XyConfig, XyTscConfig } from './XyConfig.ts'\n\nexport const packageCompileTypes = async (inConfig: XyConfig = {}): Promise<number> => {\n const config = await loadConfig(inConfig)\n\n return packageCompileTscTypes(undefined, config as XyTscConfig)\n}\n"],"mappings":";;;AAEA,OAAOA,YAAW;;;ACFlB,OAAO,WAAW;AAClB,SAAS,mBAAmB;AAC5B,SAAS,wBAAwB;AACjC,OAAO,eAAe;AAEtB,IAAI;AAEG,IAAM,aAAa,OAAyB,WAA2B;AAC5E,MAAI,QAAQ;AACV,WAAO,UAAU,QAAQ,UAAU,CAAC,CAAC;AAAA,EACvC;AAEA,QAAM,qBAAqB,MAAM,YAAY,MAAM,EAAE,OAAO,MAAM,SAAS,EAAE,OAAO,iBAAiB,EAAE,EAAE,CAAC,EAAE,OAAO;AACnH,WAAS,oBAAoB;AAC7B,QAAM,iBAAiB,oBAAoB;AAC3C,MAAI,gBAAgB;AAClB,YAAQ,IAAI,MAAM,KAAK,uBAAuB,cAAc,EAAE,CAAC;AAAA,EACjE;AACA,SAAO,UAAU,QAAQ,UAAU,CAAC,CAAC;AACvC;;;ACnBA,SAAS,YAAY;AAEd,IAAM,eAAe,CAAC,WAAmB;AAE9C,SAAO,KAAK,KAAK,GAAG,MAAM,WAAW,EAAE,OAAO,KAAK,CAAC;AACtD;;;ACFO,IAAM,eAAe,CAAC,QAAgB,YA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