@xylabs/ts-scripts-yarn3 4.0.0-rc.4 → 4.0.0-rc.6
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/actions/index.mjs +26 -97
- package/dist/actions/index.mjs.map +1 -1
- package/dist/actions/package/compile/compile.mjs +5 -76
- package/dist/actions/package/compile/compile.mjs.map +1 -1
- package/dist/actions/package/compile/index.mjs +5 -76
- package/dist/actions/package/compile/index.mjs.map +1 -1
- package/dist/actions/package/compile/packageCompileTsup.mjs +3 -157
- package/dist/actions/package/compile/packageCompileTsup.mjs.map +1 -1
- package/dist/actions/package/index.mjs +19 -90
- package/dist/actions/package/index.mjs.map +1 -1
- package/dist/actions/package/recompile.mjs +5 -76
- package/dist/actions/package/recompile.mjs.map +1 -1
- package/dist/bin/package/compile-only.mjs +7 -78
- package/dist/bin/package/compile-only.mjs.map +1 -1
- package/dist/bin/package/compile-tsup.mjs +5 -159
- package/dist/bin/package/compile-tsup.mjs.map +1 -1
- package/dist/bin/package/compile.mjs +7 -78
- package/dist/bin/package/compile.mjs.map +1 -1
- package/dist/bin/package/recompile.mjs +7 -78
- package/dist/bin/package/recompile.mjs.map +1 -1
- package/dist/index.mjs +36 -107
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/actions/package/compile/packageCompileTsup.ts +4 -10
|
@@ -81,169 +81,23 @@ var buildEntries = /* @__PURE__ */ __name((folder, entryMode, verbose = false) =
|
|
|
81
81
|
}
|
|
82
82
|
}, "buildEntries");
|
|
83
83
|
|
|
84
|
-
// src/actions/package/compile/packageCompileTsc.ts
|
|
85
|
-
import { cwd } from "node:process";
|
|
86
|
-
import chalk2 from "chalk";
|
|
87
|
-
import { createProgramFromConfig } from "tsc-prog";
|
|
88
|
-
import { DiagnosticCategory, formatDiagnosticsWithColorAndContext, getLineAndCharacterOfPosition, getPreEmitDiagnostics } from "typescript";
|
|
89
|
-
|
|
90
|
-
// src/actions/package/compile/getCompilerOptions.ts
|
|
91
|
-
import { createRequire } from "node:module";
|
|
92
|
-
import merge from "lodash/merge.js";
|
|
93
|
-
import { findConfigFile, readConfigFile, sys } from "typescript";
|
|
94
|
-
var getNested = /* @__PURE__ */ __name((config) => {
|
|
95
|
-
if (config.extends) {
|
|
96
|
-
const require2 = createRequire(import.meta.url);
|
|
97
|
-
const opts = require2(config.extends);
|
|
98
|
-
return {
|
|
99
|
-
...getNested(opts),
|
|
100
|
-
...config.compilerOptions
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
return config.compilerOptions;
|
|
104
|
-
}, "getNested");
|
|
105
|
-
var getCompilerOptionsJSONFollowExtends = /* @__PURE__ */ __name((filename) => {
|
|
106
|
-
const config = readConfigFile(filename, sys.readFile).config;
|
|
107
|
-
return getNested(config);
|
|
108
|
-
}, "getCompilerOptionsJSONFollowExtends");
|
|
109
|
-
var getCompilerOptions = /* @__PURE__ */ __name((options, tsconfig = "tsconfig.json") => {
|
|
110
|
-
const configFileName = findConfigFile("./", sys.fileExists, tsconfig);
|
|
111
|
-
const configFileCompilerOptions = configFileName ? getCompilerOptionsJSONFollowExtends(configFileName) : void 0;
|
|
112
|
-
return merge({}, configFileCompilerOptions, options);
|
|
113
|
-
}, "getCompilerOptions");
|
|
114
|
-
|
|
115
|
-
// src/actions/package/compile/packageCompileTsc.ts
|
|
116
|
-
var packageCompileTsc = /* @__PURE__ */ __name(async (noEmit, config, compilerOptionsParam) => {
|
|
117
|
-
const pkg = process.env.INIT_CWD ?? cwd();
|
|
118
|
-
const publint = config?.publint ?? true;
|
|
119
|
-
const verbose = config?.verbose ?? false;
|
|
120
|
-
const formatHost = {
|
|
121
|
-
getCanonicalFileName: /* @__PURE__ */ __name((fileName) => fileName, "getCanonicalFileName"),
|
|
122
|
-
getCurrentDirectory: /* @__PURE__ */ __name(() => pkg, "getCurrentDirectory"),
|
|
123
|
-
getNewLine: /* @__PURE__ */ __name(() => "\n", "getNewLine")
|
|
124
|
-
};
|
|
125
|
-
if (verbose) {
|
|
126
|
-
console.log(`Compiling with NoEmit TSC [${pkg}]`);
|
|
127
|
-
}
|
|
128
|
-
const compilerOptions = {
|
|
129
|
-
...getCompilerOptions({
|
|
130
|
-
outDir: "dist",
|
|
131
|
-
removeComments: true,
|
|
132
|
-
rootDir: "src"
|
|
133
|
-
}),
|
|
134
|
-
...compilerOptionsParam,
|
|
135
|
-
...noEmit === void 0 ? {} : {
|
|
136
|
-
noEmit
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
const program = createProgramFromConfig({
|
|
140
|
-
basePath: pkg ?? cwd(),
|
|
141
|
-
compilerOptions,
|
|
142
|
-
exclude: [
|
|
143
|
-
"dist",
|
|
144
|
-
"docs",
|
|
145
|
-
"**/*.spec.*",
|
|
146
|
-
"**/*.stories.*",
|
|
147
|
-
"src/**/spec/**/*"
|
|
148
|
-
],
|
|
149
|
-
include: [
|
|
150
|
-
"src"
|
|
151
|
-
]
|
|
152
|
-
});
|
|
153
|
-
const results = getPreEmitDiagnostics(program);
|
|
154
|
-
for (const diag of results) {
|
|
155
|
-
const lineAndChar = diag.file ? getLineAndCharacterOfPosition(diag.file, diag.start ?? 0) : {
|
|
156
|
-
character: 0,
|
|
157
|
-
line: 0
|
|
158
|
-
};
|
|
159
|
-
console.log(chalk2.cyan(`${diag.file?.fileName}:${lineAndChar.line + 1}:${lineAndChar.character + 1}`));
|
|
160
|
-
console.log(formatDiagnosticsWithColorAndContext([
|
|
161
|
-
diag
|
|
162
|
-
], formatHost));
|
|
163
|
-
}
|
|
164
|
-
return results.reduce((prev, diag) => prev + diag.category === DiagnosticCategory.Error ? 1 : 0, 0) || (publint ? await packagePublint() : 0);
|
|
165
|
-
}, "packageCompileTsc");
|
|
166
|
-
|
|
167
|
-
// src/actions/package/compile/packageCompileTscTypes.ts
|
|
168
|
-
import { cwd as cwd2 } from "node:process";
|
|
169
|
-
import chalk3 from "chalk";
|
|
170
|
-
import { createProgramFromConfig as createProgramFromConfig2 } from "tsc-prog";
|
|
171
|
-
import { DiagnosticCategory as DiagnosticCategory2 } from "typescript";
|
|
172
|
-
var packageCompileTscTypes = /* @__PURE__ */ __name((folder = "src", { verbose } = {}, compilerOptionsParam) => {
|
|
173
|
-
const pkg = process.env.INIT_CWD ?? cwd2();
|
|
174
|
-
if (verbose) {
|
|
175
|
-
console.log(`Compiling types with TSC [${pkg}]`);
|
|
176
|
-
}
|
|
177
|
-
const compilerOptions = {
|
|
178
|
-
...getCompilerOptions({
|
|
179
|
-
declaration: true,
|
|
180
|
-
emitDeclarationOnly: true,
|
|
181
|
-
outDir: "dist",
|
|
182
|
-
removeComments: true,
|
|
183
|
-
skipDefaultLibCheck: true,
|
|
184
|
-
skipLibCheck: true,
|
|
185
|
-
sourceMap: true
|
|
186
|
-
}),
|
|
187
|
-
...compilerOptionsParam
|
|
188
|
-
};
|
|
189
|
-
const files = buildEntries(folder, "all");
|
|
190
|
-
const result = createProgramFromConfig2({
|
|
191
|
-
basePath: pkg ?? cwd2(),
|
|
192
|
-
compilerOptions,
|
|
193
|
-
exclude: [
|
|
194
|
-
"dist",
|
|
195
|
-
"docs",
|
|
196
|
-
"**/*.spec.*",
|
|
197
|
-
"**/*.stories.*",
|
|
198
|
-
"src/**/spec/**/*"
|
|
199
|
-
],
|
|
200
|
-
files
|
|
201
|
-
}).emit();
|
|
202
|
-
const diagResults = result.diagnostics.length;
|
|
203
|
-
for (const diag of result.diagnostics) {
|
|
204
|
-
switch (diag.category) {
|
|
205
|
-
case DiagnosticCategory2.Error: {
|
|
206
|
-
console.error(chalk3.red(diag.messageText));
|
|
207
|
-
console.error(chalk3.grey(pkg));
|
|
208
|
-
console.error(chalk3.blue(diag.file?.fileName));
|
|
209
|
-
break;
|
|
210
|
-
}
|
|
211
|
-
case DiagnosticCategory2.Warning: {
|
|
212
|
-
console.error(chalk3.yellow(diag.messageText));
|
|
213
|
-
console.error(chalk3.grey(pkg));
|
|
214
|
-
console.error(chalk3.blue(diag.file?.fileName));
|
|
215
|
-
break;
|
|
216
|
-
}
|
|
217
|
-
case DiagnosticCategory2.Suggestion: {
|
|
218
|
-
console.error(chalk3.white(diag.messageText));
|
|
219
|
-
console.error(chalk3.grey(pkg));
|
|
220
|
-
console.error(chalk3.blue(diag.file?.fileName));
|
|
221
|
-
break;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
return diagResults;
|
|
226
|
-
}, "packageCompileTscTypes");
|
|
227
|
-
|
|
228
84
|
// src/actions/package/compile/packageCompileTsup.ts
|
|
229
|
-
var compileFolder = /* @__PURE__ */ __name(async (folder, entryMode = "single", options,
|
|
85
|
+
var compileFolder = /* @__PURE__ */ __name(async (folder, entryMode = "single", options, _verbose) => {
|
|
230
86
|
const outDir = options?.outDir ?? "dist";
|
|
231
87
|
const entry = buildEntries(folder, entryMode);
|
|
232
88
|
const optionsResult = defineConfig({
|
|
233
89
|
bundle: true,
|
|
234
90
|
cjsInterop: true,
|
|
235
91
|
clean: true,
|
|
236
|
-
dts:
|
|
92
|
+
dts: true,
|
|
237
93
|
entry,
|
|
238
94
|
format: [
|
|
239
95
|
"esm"
|
|
240
96
|
],
|
|
241
|
-
// minify: true,
|
|
242
97
|
outDir,
|
|
243
98
|
silent: true,
|
|
244
99
|
sourcemap: true,
|
|
245
100
|
splitting: false,
|
|
246
|
-
// terserOptions: { format: { comments: false } },
|
|
247
101
|
tsconfig: "tsconfig.json",
|
|
248
102
|
...options
|
|
249
103
|
});
|
|
@@ -258,11 +112,6 @@ var compileFolder = /* @__PURE__ */ __name(async (folder, entryMode = "single",
|
|
|
258
112
|
];
|
|
259
113
|
}))).flat();
|
|
260
114
|
await Promise.all(optionsList.map((options2) => build(options2)));
|
|
261
|
-
packageCompileTscTypes(folder, {
|
|
262
|
-
verbose
|
|
263
|
-
}, {
|
|
264
|
-
outDir
|
|
265
|
-
});
|
|
266
115
|
return 0;
|
|
267
116
|
}, "compileFolder");
|
|
268
117
|
var packageCompileTsup = /* @__PURE__ */ __name(async (config) => {
|
|
@@ -305,10 +154,7 @@ var packageCompileTsup = /* @__PURE__ */ __name(async (config) => {
|
|
|
305
154
|
sourcemap: true,
|
|
306
155
|
target: "esnext"
|
|
307
156
|
};
|
|
308
|
-
return await
|
|
309
|
-
publint: false,
|
|
310
|
-
verbose
|
|
311
|
-
}) || (await Promise.all(Object.entries(compileForNode).map(async ([folder, options]) => {
|
|
157
|
+
return (await Promise.all(Object.entries(compileForNode).map(async ([folder, options]) => {
|
|
312
158
|
const inEsBuildOptions = typeof compile?.node?.esbuildOptions === "object" ? compile?.node?.esbuildOptions : {};
|
|
313
159
|
return folder ? await compileFolder(folder, compile?.entryMode, {
|
|
314
160
|
...standardOptions,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/actions/package/compile/packageCompileTsup.ts","../../../../src/actions/package/publint.ts","../../../../src/actions/package/compile/inputs.ts","../../../../src/actions/package/compile/buildEntries.ts","../../../../src/actions/package/compile/packageCompileTsc.ts","../../../../src/actions/package/compile/getCompilerOptions.ts","../../../../src/actions/package/compile/packageCompileTscTypes.ts"],"sourcesContent":["import type { Loader } from 'esbuild'\nimport { build, defineConfig, Options } from 'tsup'\n\nimport { packagePublint } from '../publint.ts'\nimport { buildEntries } from './buildEntries.ts'\nimport { packageCompileTsc } from './packageCompileTsc.ts'\nimport { packageCompileTscTypes } from './packageCompileTscTypes.ts'\nimport { EntryMode, XyTsupConfig } from './XyConfig.ts'\n\nconst compileFolder = async (folder: string, entryMode: EntryMode = 'single', options?: Options, verbose?: boolean) => {\n const outDir = options?.outDir ?? 'dist'\n const entry = buildEntries(folder, entryMode)\n const optionsResult = defineConfig({\n bundle: true,\n cjsInterop: true,\n clean: true,\n dts: false,\n entry,\n format: ['esm'],\n // minify: true,\n outDir,\n silent: true,\n sourcemap: true,\n splitting: false,\n // terserOptions: { format: { comments: false } },\n tsconfig: 'tsconfig.json',\n ...options,\n })\n const optionsList = (\n await Promise.all(\n (Array.isArray(optionsResult) ? optionsResult : [optionsResult]).flatMap<Promise<Options[]>>(async (options) => {\n const result = typeof options === 'function' ? await options({}) : [options]\n return Array.isArray(result) ? result : [result]\n }),\n )\n ).flat()\n\n await Promise.all(optionsList.map(options => build(options)))\n packageCompileTscTypes(folder, { verbose }, { outDir })\n\n return 0\n}\n\n// eslint-disable-next-line complexity\nexport const packageCompileTsup = async (config?: XyTsupConfig) => {\n const compile = config?.compile\n const publint = config?.publint ?? true\n const verbose = config?.verbose ?? false\n if (verbose) {\n console.log(`Compiling with TSUP [Depth: ${compile?.depth}]`)\n }\n\n const compileForNode = compile?.node ?? { src: {} }\n const compileForBrowser = compile?.browser ?? { src: {} }\n const compileForNeutral = compile?.neutral ?? { src: {} }\n\n const standardLoaders: Record<string, Loader> = { '.gif': 'copy', '.html': 'copy', '.jpg': 'copy', '.json': 'json', '.png': 'copy', '.svg': 'copy', '.webp': 'copy' }\n const standardOptions: Options = {\n bundle: true,\n format: ['esm'],\n loader: standardLoaders,\n outExtension: ({ format }) => (format === 'esm' ? { js: '.mjs' } : { js: '.cjs' }),\n skipNodeModulesBundle: true,\n sourcemap: true,\n target: 'esnext',\n }\n\n return (\n (await packageCompileTsc(true, { publint: false, verbose }))\n || (\n await Promise.all(\n Object.entries(compileForNode).map(async ([folder, options]) => {\n const inEsBuildOptions = typeof compile?.node?.esbuildOptions === 'object' ? compile?.node?.esbuildOptions : {}\n return folder\n ? await compileFolder(\n folder,\n compile?.entryMode,\n {\n ...standardOptions,\n loader: {\n ...standardOptions.loader,\n ...inEsBuildOptions?.loader,\n },\n outDir: 'dist/node',\n platform: 'node',\n ...compile?.tsup?.options,\n ...(typeof options === 'object' ? options : {}),\n },\n verbose,\n )\n : 0\n }),\n )\n ).reduce((prev, value) => prev + value, 0)\n || (\n await Promise.all(\n Object.entries(compileForBrowser).map(async ([folder, options]) => {\n const inEsBuildOptions = typeof compile?.browser?.esbuildOptions === 'object' ? compile?.browser?.esbuildOptions : {}\n return folder\n ? await compileFolder(\n folder,\n compile?.entryMode,\n {\n ...standardOptions,\n loader: {\n ...standardOptions.loader,\n ...inEsBuildOptions?.loader,\n },\n outDir: 'dist/browser',\n platform: 'browser',\n ...compile?.tsup?.options,\n ...(typeof options === 'object' ? options : {}),\n },\n verbose,\n )\n : 0\n }),\n )\n ).reduce((prev, value) => prev + value, 0)\n || (\n await Promise.all(\n Object.entries(compileForNeutral).map(async ([folder, options]) => {\n const inEsBuildOptions = typeof compile?.neutral?.esbuildOptions === 'object' ? compile?.neutral?.esbuildOptions : {}\n return folder\n ? await compileFolder(\n folder,\n compile?.entryMode,\n {\n ...standardOptions,\n loader: {\n ...standardOptions.loader,\n ...inEsBuildOptions?.loader,\n },\n outDir: 'dist/neutral',\n platform: 'neutral',\n ...compile?.tsup?.options,\n ...(typeof options === 'object' ? options : {}),\n },\n verbose,\n )\n : 0\n }),\n )\n ).reduce((prev, value) => prev + value, 0)\n || (publint ? await packagePublint() : 0)\n )\n}\n","import { promises as fs } from 'node:fs'\n\nimport chalk from 'chalk'\nimport { Message } from 'publint'\n\nexport interface PackagePublintParams {\n verbose?: boolean\n}\n\nexport const packagePublint = async (params?: PackagePublintParams) => {\n const pkgDir = process.env.INIT_CWD\n const pkg = JSON.parse(await fs.readFile(`${pkgDir}/package.json`, 'utf8'))\n\n console.log(chalk.green(`Publint: ${pkg.name}`))\n console.log(chalk.gray(pkgDir))\n\n const { publint } = await import('publint')\n\n const { messages } = await publint({\n level: 'suggestion',\n pkgDir,\n strict: true,\n })\n\n // eslint-disable-next-line import/no-internal-modules\n const { formatMessage } = await import('publint/utils')\n\n const validMessage = (_message: Message): boolean => {\n return true\n /* try {\n const value = getValueFromPath(pkg, message.path)\n switch (message.code) {\n case 'FILE_INVALID_FORMAT':\n return !message.args?.actualFilePath?.includes('dist/browser') && !value?.includes('dist/browser')\n case 'EXPORT_TYPES_INVALID_FORMAT':\n return !`${value}`.includes('dist/browser')\n default:\n return true\n }\n } catch (ex) {\n const error = ex as Error\n console.error(chalk.red(`validMessage Excepted: ${error.message}`))\n console.error(chalk.gray(JSON.stringify(error.stack)))\n return true\n } */\n }\n\n // we filter out invalid file formats for the esm folder since it is intentionally done\n const validMessages = messages.filter(validMessage)\n for (const message of validMessages) {\n switch (message.type) {\n case 'error': {\n console.error(chalk.red(`[${message.code}] ${formatMessage(message, pkg)}`))\n break\n }\n case 'warning': {\n console.warn(chalk.yellow(`[${message.code}] ${formatMessage(message, pkg)}`))\n break\n }\n default: {\n console.log(chalk.white(`[${message.code}] ${formatMessage(message, pkg)}`))\n break\n }\n }\n }\n\n if (params?.verbose) {\n console.log(chalk.gray(`Publint [Finish]: ${pkgDir} [${validMessages.length}]`))\n }\n\n return validMessages.filter(message => message.type === 'error').length\n}\n","import { readdir } from 'node:fs/promises'\n\nimport { glob } from 'glob'\n\nexport const getInputs = async (subDir?: string) => {\n return (await readdir(subDir ? `src/${subDir}` : 'src', { recursive: false }))\n .filter(\n file => (file.endsWith('.ts') || file.endsWith('.tsx')) && !file.endsWith('d.ts') && !file.includes('.spec.') && !file.includes('.stories.'),\n )\n .map(file => (subDir ? `${subDir}/${file}` : file))\n}\n\nexport const getInputDirs = async (depth: number = 0) => {\n if (depth === 0) {\n return []\n }\n return [\n '.',\n ...(await readdir('src', { recursive: true, withFileTypes: true }))\n .filter(file => file.isDirectory())\n .map((file) => {\n const pathParts = file.path?.split('/') ?? []\n pathParts.shift()\n if (pathParts.length > 0) {\n const root = pathParts.join('/')\n return `${root}/${file.name}`\n } else {\n return file.name\n }\n }),\n ]\n}\n\nexport const getAllInputs = async (depth = 100) => {\n const dirs = await getInputDirs(depth)\n return (await Promise.all(dirs.map(async dir => await getInputs(dir)))).flat()\n}\n\nexport const getAllInputs2 = (folder: string) => {\n /* tsup wants posix paths */\n return glob.sync(`${folder}/**/*.*`, { ignore: ['**/*.spec.*', '**/*.stories.*', '**/spec/**/*'], posix: true })\n}\n","import { getAllInputs2 } from './inputs.ts'\nimport { EntryMode } from './XyConfig.ts'\n\nexport const buildEntries = (folder: string, entryMode?: EntryMode, verbose = false) => {\n switch (entryMode) {\n case 'platform': {\n if (verbose) console.log('buildEntries [platform]')\n return [`${folder}/index-node.ts`, `${folder}/index-browser.ts`]\n }\n case 'all': {\n if (verbose) console.log('buildEntries [all]')\n return getAllInputs2(folder).filter(entry => !entry.includes('.spec.') && !entry.includes('.story.'))\n }\n default: {\n if (verbose) console.log('buildEntries [single]')\n return [`${folder}/index.ts`]\n }\n }\n}\n","import { cwd } from 'node:process'\n\nimport chalk from 'chalk'\nimport { createProgramFromConfig, TsConfigCompilerOptions } from 'tsc-prog'\nimport {\n CompilerOptions,\n DiagnosticCategory,\n FormatDiagnosticsHost,\n formatDiagnosticsWithColorAndContext,\n getLineAndCharacterOfPosition,\n getPreEmitDiagnostics,\n LineAndCharacter,\n} from 'typescript'\n\nimport { packagePublint } from '../publint.ts'\nimport { getCompilerOptions } from './getCompilerOptions.ts'\nimport { XyTscConfig } from './XyConfig.ts'\n\nexport const packageCompileTsc = async (noEmit?: boolean, config?: XyTscConfig, compilerOptionsParam?: CompilerOptions): Promise<number> => {\n const pkg = process.env.INIT_CWD ?? cwd()\n\n const publint = config?.publint ?? true\n const verbose = config?.verbose ?? false\n\n const formatHost: FormatDiagnosticsHost = {\n getCanonicalFileName: fileName => fileName,\n getCurrentDirectory: () => pkg,\n getNewLine: () => '\\n',\n }\n\n if (verbose) {\n console.log(`Compiling with NoEmit TSC [${pkg}]`)\n }\n\n const compilerOptions = {\n ...(getCompilerOptions({\n outDir: 'dist',\n removeComments: true,\n rootDir: 'src',\n })),\n ...compilerOptionsParam,\n ...(noEmit === undefined ? {} : { noEmit }),\n } as TsConfigCompilerOptions\n\n const program = createProgramFromConfig({\n basePath: pkg ?? cwd(),\n compilerOptions,\n exclude: ['dist', 'docs', '**/*.spec.*', '**/*.stories.*', 'src/**/spec/**/*'],\n include: ['src'],\n })\n\n const results = getPreEmitDiagnostics(program)\n\n for (const diag of results) {\n const lineAndChar: LineAndCharacter = diag.file ? getLineAndCharacterOfPosition(diag.file, diag.start ?? 0) : { character: 0, line: 0 }\n console.log(chalk.cyan(`${diag.file?.fileName}:${lineAndChar.line + 1}:${lineAndChar.character + 1}`))\n console.log(formatDiagnosticsWithColorAndContext([diag], formatHost))\n }\n\n // eslint-disable-next-line unicorn/no-array-reduce\n return results.reduce((prev, diag) => (prev + diag.category === DiagnosticCategory.Error ? 1 : 0), 0) || (publint ? await packagePublint() : 0)\n}\n","import { createRequire } from 'node:module'\n\n// eslint-disable-next-line import/no-internal-modules\nimport merge from 'lodash/merge.js'\nimport { TsConfig } from 'tsc-prog'\nimport { CompilerOptions, findConfigFile, readConfigFile, sys } 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 { ...getNested(opts), ...config.compilerOptions } as CompilerOptions\n }\n\n return config.compilerOptions as CompilerOptions\n}\n\nexport const 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 merge({}, configFileCompilerOptions, options)\n}\n","import { cwd } from 'node:process'\n\nimport chalk from 'chalk'\nimport { createProgramFromConfig, TsConfigCompilerOptions } from 'tsc-prog'\nimport { CompilerOptions, DiagnosticCategory } from 'typescript'\n\nimport { buildEntries } from './buildEntries.ts'\nimport { getCompilerOptions } from './getCompilerOptions.ts'\nimport { XyConfig } from './XyConfig.ts'\n\nexport const packageCompileTscTypes = (\n folder: string = 'src',\n { verbose }: XyConfig = {},\n compilerOptionsParam?: CompilerOptions,\n): number => {\n const pkg = process.env.INIT_CWD ?? cwd()\n\n if (verbose) {\n console.log(`Compiling types with TSC [${pkg}]`)\n }\n\n const compilerOptions = {\n ...(getCompilerOptions({\n declaration: true,\n emitDeclarationOnly: true,\n outDir: 'dist',\n removeComments: true,\n skipDefaultLibCheck: true,\n skipLibCheck: true,\n sourceMap: true,\n })),\n ...compilerOptionsParam,\n } as TsConfigCompilerOptions\n\n // calling all here since the types do not get rolled up\n const files = buildEntries(folder, 'all')\n\n const result = createProgramFromConfig({\n basePath: pkg ?? cwd(),\n compilerOptions,\n exclude: ['dist', 'docs', '**/*.spec.*', '**/*.stories.*', 'src/**/spec/**/*'],\n files,\n }).emit()\n\n const diagResults = result.diagnostics.length\n for (const diag of result.diagnostics) {\n switch (diag.category) {\n case DiagnosticCategory.Error: {\n console.error(chalk.red(diag.messageText))\n console.error(chalk.grey(pkg))\n console.error(chalk.blue(diag.file?.fileName))\n break\n }\n case DiagnosticCategory.Warning: {\n console.error(chalk.yellow(diag.messageText))\n console.error(chalk.grey(pkg))\n console.error(chalk.blue(diag.file?.fileName))\n break\n }\n case DiagnosticCategory.Suggestion: {\n console.error(chalk.white(diag.messageText))\n console.error(chalk.grey(pkg))\n console.error(chalk.blue(diag.file?.fileName))\n break\n }\n }\n }\n return diagResults\n}\n"],"mappings":";;;;AACA,SAASA,OAAOC,oBAA6B;;;ACD7C,SAASC,YAAYC,UAAU;AAE/B,OAAOC,WAAW;AAOX,IAAMC,iBAAiB,8BAAOC,WAAAA;AACnC,QAAMC,SAASC,QAAQC,IAAIC;AAC3B,QAAMC,MAAMC,KAAKC,MAAM,MAAMC,GAAGC,SAAS,GAAGR,MAAAA,iBAAuB,MAAA,CAAA;AAEnES,UAAQC,IAAIC,MAAMC,MAAM,YAAYR,IAAIS,IAAI,EAAE,CAAA;AAC9CJ,UAAQC,IAAIC,MAAMG,KAAKd,MAAAA,CAAAA;AAEvB,QAAM,EAAEe,QAAO,IAAK,MAAM,OAAO,SAAA;AAEjC,QAAM,EAAEC,SAAQ,IAAK,MAAMD,QAAQ;IACjCE,OAAO;IACPjB;IACAkB,QAAQ;EACV,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AS9B,WACT;MACE,GAAG2C;MACHC,QAAQ;QACN,GAAGD,gBAAgBC;QACnB,GAAGQ,kBAAkBR;MACvB;MACAzC,QAAQ;MACRmD,UAAU;MACV,GAAGxB,SAASyB,MAAMtD;MAClB,GAAI,OAAOA,YAAY,WAAWA,UAAU,CAAC;IAC/C,GACAC,OAAAA,IAEA;EACN,CAAA,CAAA,GAEFsD,OAAO,CAACC,MAAMC,UAAUD,OAAOC,OAAO,CAAA,MAEtC,MAAMxC,QAAQC,IACZ+B,OAAOC,QAAQX,iBAAAA,EAAmBf,IAAI,OAAO,CAAC1B,QAAQE,OAAAA,MAAQ;AAC5D,UAAMmD,mBAAmB,OAAOtB,SAASW,SAASY,mBAAmB,WAAWvB,SAASW,SAASY,iBAAiB,CAAC;AACpH,WAAOtD,SACH,MAAMD,cACNC,QACA+B,SAAS9B,WACT;MACE,GAAG2C;MACHC,QAAQ;QACN,GAAGD,gBAAgBC;QACnB,GAAGQ,kBAAkBR;MACvB;MACAzC,QAAQ;MACRmD,UAAU;MACV,GAAGxB,SAASyB,MAAMtD;MAClB,GAAI,OAAOA,YAAY,WAAWA,UAAU,CAAC;IAC/C,GACAC,OAAAA,IAEA;EACN,CAAA,CAAA,GAEFsD,OAAO,CAACC,MAAMC,UAAUD,OAAOC,OAAO,CAAA,MACpC3B,UAAU,MAAM4B,eAAAA,IAAmB;AAE3C,GAtGkC;","names":["build","defineConfig","promises","fs","chalk","packagePublint","params","pkgDir","process","env","INIT_CWD","pkg","JSON","parse","fs","readFile","console","log","chalk","green","name","gray","publint","messages","level","strict","formatMessage","validMessage","_message","validMessages","filter","message","type","error","red","code","warn","yellow","white","verbose","length","glob","getAllInputs2","folder","glob","sync","ignore","posix","buildEntries","folder","entryMode","verbose","console","log","getAllInputs2","filter","entry","includes","cwd","chalk","createProgramFromConfig","DiagnosticCategory","formatDiagnosticsWithColorAndContext","getLineAndCharacterOfPosition","getPreEmitDiagnostics","createRequire","merge","findConfigFile","readConfigFile","sys","getNested","config","extends","require","createRequire","url","opts","compilerOptions","getCompilerOptionsJSONFollowExtends","filename","readConfigFile","sys","readFile","getCompilerOptions","options","tsconfig","configFileName","findConfigFile","fileExists","configFileCompilerOptions","undefined","merge","packageCompileTsc","noEmit","config","compilerOptionsParam","pkg","process","env","INIT_CWD","cwd","publint","verbose","formatHost","getCanonicalFileName","fileName","getCurrentDirectory","getNewLine","console","log","compilerOptions","getCompilerOptions","outDir","removeComments","rootDir","undefined","program","createProgramFromConfig","basePath","exclude","include","results","getPreEmitDiagnostics","diag","lineAndChar","file","getLineAndCharacterOfPosition","start","character","line","chalk","cyan","formatDiagnosticsWithColorAndContext","reduce","prev","category","DiagnosticCategory","Error","packagePublint","cwd","chalk","createProgramFromConfig","DiagnosticCategory","packageCompileTscTypes","folder","verbose","compilerOptionsParam","pkg","process","env","INIT_CWD","cwd","console","log","compilerOptions","getCompilerOptions","declaration","emitDeclarationOnly","outDir","removeComments","skipDefaultLibCheck","skipLibCheck","sourceMap","files","buildEntries","result","createProgramFromConfig","basePath","exclude","emit","diagResults","diagnostics","length","diag","category","DiagnosticCategory","Error","error","chalk","red","messageText","grey","blue","file","fileName","Warning","yellow","Suggestion","white","compileFolder","folder","entryMode","options","verbose","outDir","entry","buildEntries","optionsResult","defineConfig","bundle","cjsInterop","clean","dts","format","silent","sourcemap","splitting","tsconfig","optionsList","Promise","all","Array","isArray","flatMap","result","flat","map","build","packageCompileTscTypes","packageCompileTsup","config","compile","publint","console","log","depth","compileForNode","node","src","compileForBrowser","browser","compileForNeutral","neutral","standardLoaders","standardOptions","loader","outExtension","js","skipNodeModulesBundle","target","packageCompileTsc","Object","entries","inEsBuildOptions","esbuildOptions","platform","tsup","reduce","prev","value","packagePublint"]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/actions/package/compile/packageCompileTsup.ts","../../../../src/actions/package/publint.ts","../../../../src/actions/package/compile/inputs.ts","../../../../src/actions/package/compile/buildEntries.ts"],"sourcesContent":["import type { Loader } from 'esbuild'\nimport { build, defineConfig, Options } from 'tsup'\n\nimport { packagePublint } from '../publint.ts'\nimport { buildEntries } from './buildEntries.ts'\nimport { EntryMode, XyTsupConfig } from './XyConfig.ts'\n\nconst compileFolder = async (folder: string, entryMode: EntryMode = 'single', options?: Options, _verbose?: boolean) => {\n const outDir = options?.outDir ?? 'dist'\n const entry = buildEntries(folder, entryMode)\n const optionsResult = defineConfig({\n bundle: true,\n cjsInterop: true,\n clean: true,\n dts: true,\n entry,\n format: ['esm'],\n outDir,\n silent: true,\n sourcemap: true,\n splitting: false,\n tsconfig: 'tsconfig.json',\n ...options,\n })\n const optionsList = (\n await Promise.all(\n (Array.isArray(optionsResult) ? optionsResult : [optionsResult]).flatMap<Promise<Options[]>>(async (options) => {\n const result = typeof options === 'function' ? await options({}) : [options]\n return Array.isArray(result) ? result : [result]\n }),\n )\n ).flat()\n\n await Promise.all(optionsList.map(options => build(options)))\n // packageCompileTscTypes(folder, { verbose }, { outDir })\n\n return 0\n}\n\nexport const packageCompileTsup = async (config?: XyTsupConfig) => {\n const compile = config?.compile\n const publint = config?.publint ?? true\n const verbose = config?.verbose ?? false\n if (verbose) {\n console.log(`Compiling with TSUP [Depth: ${compile?.depth}]`)\n }\n\n const compileForNode = compile?.node ?? { src: {} }\n const compileForBrowser = compile?.browser ?? { src: {} }\n const compileForNeutral = compile?.neutral ?? { src: {} }\n\n const standardLoaders: Record<string, Loader> = { '.gif': 'copy', '.html': 'copy', '.jpg': 'copy', '.json': 'json', '.png': 'copy', '.svg': 'copy', '.webp': 'copy' }\n const standardOptions: Options = {\n bundle: true,\n format: ['esm'],\n loader: standardLoaders,\n outExtension: ({ format }) => (format === 'esm' ? { js: '.mjs' } : { js: '.cjs' }),\n skipNodeModulesBundle: true,\n sourcemap: true,\n target: 'esnext',\n }\n\n return (\n (\n await Promise.all(\n Object.entries(compileForNode).map(async ([folder, options]) => {\n const inEsBuildOptions = typeof compile?.node?.esbuildOptions === 'object' ? compile?.node?.esbuildOptions : {}\n return folder\n ? await compileFolder(\n folder,\n compile?.entryMode,\n {\n ...standardOptions,\n loader: {\n ...standardOptions.loader,\n ...inEsBuildOptions?.loader,\n },\n outDir: 'dist/node',\n platform: 'node',\n ...compile?.tsup?.options,\n ...(typeof options === 'object' ? options : {}),\n },\n verbose,\n )\n : 0\n }),\n )\n ).reduce((prev, value) => prev + value, 0)\n || (\n await Promise.all(\n Object.entries(compileForBrowser).map(async ([folder, options]) => {\n const inEsBuildOptions = typeof compile?.browser?.esbuildOptions === 'object' ? compile?.browser?.esbuildOptions : {}\n return folder\n ? await compileFolder(\n folder,\n compile?.entryMode,\n {\n ...standardOptions,\n loader: {\n ...standardOptions.loader,\n ...inEsBuildOptions?.loader,\n },\n outDir: 'dist/browser',\n platform: 'browser',\n ...compile?.tsup?.options,\n ...(typeof options === 'object' ? options : {}),\n },\n verbose,\n )\n : 0\n }),\n )\n ).reduce((prev, value) => prev + value, 0)\n || (\n await Promise.all(\n Object.entries(compileForNeutral).map(async ([folder, options]) => {\n const inEsBuildOptions = typeof compile?.neutral?.esbuildOptions === 'object' ? compile?.neutral?.esbuildOptions : {}\n return folder\n ? await compileFolder(\n folder,\n compile?.entryMode,\n {\n ...standardOptions,\n loader: {\n ...standardOptions.loader,\n ...inEsBuildOptions?.loader,\n },\n outDir: 'dist/neutral',\n platform: 'neutral',\n ...compile?.tsup?.options,\n ...(typeof options === 'object' ? options : {}),\n },\n verbose,\n )\n : 0\n }),\n )\n ).reduce((prev, value) => prev + value, 0)\n || (publint ? await packagePublint() : 0)\n )\n}\n","import { promises as fs } from 'node:fs'\n\nimport chalk from 'chalk'\nimport { Message } from 'publint'\n\nexport interface PackagePublintParams {\n verbose?: boolean\n}\n\nexport const packagePublint = async (params?: PackagePublintParams) => {\n const pkgDir = process.env.INIT_CWD\n const pkg = JSON.parse(await fs.readFile(`${pkgDir}/package.json`, 'utf8'))\n\n console.log(chalk.green(`Publint: ${pkg.name}`))\n console.log(chalk.gray(pkgDir))\n\n const { publint } = await import('publint')\n\n const { messages } = await publint({\n level: 'suggestion',\n pkgDir,\n strict: true,\n })\n\n // eslint-disable-next-line import/no-internal-modules\n const { formatMessage } = await import('publint/utils')\n\n const validMessage = (_message: Message): boolean => {\n return true\n /* try {\n const value = getValueFromPath(pkg, message.path)\n switch (message.code) {\n case 'FILE_INVALID_FORMAT':\n return !message.args?.actualFilePath?.includes('dist/browser') && !value?.includes('dist/browser')\n case 'EXPORT_TYPES_INVALID_FORMAT':\n return !`${value}`.includes('dist/browser')\n default:\n return true\n }\n } catch (ex) {\n const error = ex as Error\n console.error(chalk.red(`validMessage Excepted: ${error.message}`))\n console.error(chalk.gray(JSON.stringify(error.stack)))\n return true\n } */\n }\n\n // we filter out invalid file formats for the esm folder since it is intentionally done\n const validMessages = messages.filter(validMessage)\n for (const message of validMessages) {\n switch (message.type) {\n case 'error': {\n console.error(chalk.red(`[${message.code}] ${formatMessage(message, pkg)}`))\n break\n }\n case 'warning': {\n console.warn(chalk.yellow(`[${message.code}] ${formatMessage(message, pkg)}`))\n break\n }\n default: {\n console.log(chalk.white(`[${message.code}] ${formatMessage(message, pkg)}`))\n break\n }\n }\n }\n\n if (params?.verbose) {\n console.log(chalk.gray(`Publint [Finish]: ${pkgDir} [${validMessages.length}]`))\n }\n\n return validMessages.filter(message => message.type === 'error').length\n}\n","import { readdir } from 'node:fs/promises'\n\nimport { glob } from 'glob'\n\nexport const getInputs = async (subDir?: string) => {\n return (await readdir(subDir ? `src/${subDir}` : 'src', { recursive: false }))\n .filter(\n file => (file.endsWith('.ts') || file.endsWith('.tsx')) && !file.endsWith('d.ts') && !file.includes('.spec.') && !file.includes('.stories.'),\n )\n .map(file => (subDir ? `${subDir}/${file}` : file))\n}\n\nexport const getInputDirs = async (depth: number = 0) => {\n if (depth === 0) {\n return []\n }\n return [\n '.',\n ...(await readdir('src', { recursive: true, withFileTypes: true }))\n .filter(file => file.isDirectory())\n .map((file) => {\n const pathParts = file.path?.split('/') ?? []\n pathParts.shift()\n if (pathParts.length > 0) {\n const root = pathParts.join('/')\n return `${root}/${file.name}`\n } else {\n return file.name\n }\n }),\n ]\n}\n\nexport const getAllInputs = async (depth = 100) => {\n const dirs = await getInputDirs(depth)\n return (await Promise.all(dirs.map(async dir => await getInputs(dir)))).flat()\n}\n\nexport const getAllInputs2 = (folder: string) => {\n /* tsup wants posix paths */\n return glob.sync(`${folder}/**/*.*`, { ignore: ['**/*.spec.*', '**/*.stories.*', '**/spec/**/*'], posix: true })\n}\n","import { getAllInputs2 } from './inputs.ts'\nimport { EntryMode } from './XyConfig.ts'\n\nexport const buildEntries = (folder: string, entryMode?: EntryMode, verbose = false) => {\n switch (entryMode) {\n case 'platform': {\n if (verbose) console.log('buildEntries [platform]')\n return [`${folder}/index-node.ts`, `${folder}/index-browser.ts`]\n }\n case 'all': {\n if (verbose) console.log('buildEntries [all]')\n return getAllInputs2(folder).filter(entry => !entry.includes('.spec.') && !entry.includes('.story.'))\n }\n default: {\n if (verbose) console.log('buildEntries [single]')\n return [`${folder}/index.ts`]\n }\n }\n}\n"],"mappings":";;;;AACA,SAASA,OAAOC,oBAA6B;;;ACD7C,SAASC,YAAYC,UAAU;AAE/B,OAAOC,WAAW;AAOX,IAAMC,iBAAiB,8BAAOC,WAAAA;AACnC,QAAMC,SAASC,QAAQC,IAAIC;AAC3B,QAAMC,MAAMC,KAAKC,MAAM,MAAMC,GAAGC,SAAS,GAAGR,MAAAA,iBAAuB,MAAA,CAAA;AAEnES,UAAQC,IAAIC,MAAMC,MAAM,YAAYR,IAAIS,IAAI,EAAE,CAAA;AAC9CJ,UAAQC,IAAIC,MAAMG,KAAKd,MAAAA,CAAAA;AAEvB,QAAM,EAAEe,QAAO,IAAK,MAAM,OAAO,SAAA;AAEjC,QAAM,EAAEC,SAAQ,IAAK,MAAMD,QAAQ;IACjCE,OAAO;IACPjB;IACAkB,QAAQ;EACV,CAAA;AAGA,QAAM,EAAEC,cAAa,IAAK,MAAM,OAAO,eAAA;AAEvC,QAAMC,eAAe,w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HC,QAAQ;QACN,GAAGD,gBAAgBC;QACnB,GAAGO,kBAAkBP;MACvB;MACAzC,QAAQ;MACRkD,UAAU;MACV,GAAGxB,SAASyB,MAAMrD;MAClB,GAAI,OAAOA,YAAY,WAAWA,UAAU,CAAC;IAC/C,GACA8B,OAAAA,IAEA;EACN,CAAA,CAAA,GAEFwB,OAAO,CAACC,MAAMC,UAAUD,OAAOC,OAAO,CAAA,MAEtC,MAAMvC,QAAQC,IACZ8B,OAAOC,QAAQV,iBAAAA,EAAmBf,IAAI,OAAO,CAAC1B,QAAQE,OAAAA,MAAQ;AAC5D,UAAMkD,mBAAmB,OAAOtB,SAASY,SAASW,mBAAmB,WAAWvB,SAASY,SAASW,iBAAiB,CAAC;AACpH,WAAOrD,SACH,MAAMD,cACNC,QACA8B,SAAS7B,WACT;MACE,GAAG2C;MACHC,QAAQ;QACN,GAAGD,gBAAgBC;QACnB,GAAGO,kBAAkBP;MACvB;MACAzC,QAAQ;MACRkD,UAAU;MACV,GAAGxB,SAASyB,MAAMrD;MAClB,GAAI,OAAOA,YAAY,WAAWA,UAAU,CAAC;IAC/C,GACA8B,OAAAA,IAEA;EACN,CAAA,CAAA,GAEFwB,OAAO,CAACC,MAAMC,UAAUD,OAAOC,OAAO,CAAA,MACpC3B,UAAU,MAAM4B,eAAAA,IAAmB;AAE3C,GArGkC;","names":["build","defineConfig","promises","fs","chalk","packagePublint","params","pkgDir","process","env","INIT_CWD","pkg","JSON","parse","fs","readFile","console","log","chalk","green","name","gray","publint","messages","level","strict","formatMessage","validMessage","_message","validMessages","filter","message","type","error","red","code","warn","yellow","white","verbose","length","glob","getAllInputs2","folder","glob","sync","ignore","posix","buildEntries","folder","entryMode","verbose","console","log","getAllInputs2","filter","entry","includes","compileFolder","folder","entryMode","options","_verbose","outDir","entry","buildEntries","optionsResult","defineConfig","bundle","cjsInterop","clean","dts","format","silent","sourcemap","splitting","tsconfig","optionsList","Promise","all","Array","isArray","flatMap","result","flat","map","build","packageCompileTsup","config","compile","publint","verbose","console","log","depth","compileForNode","node","src","compileForBrowser","browser","compileForNeutral","neutral","standardLoaders","standardOptions","loader","outExtension","js","skipNodeModulesBundle","target","Object","entries","inEsBuildOptions","esbuildOptions","platform","tsup","reduce","prev","value","packagePublint"]}
|
|
@@ -44,7 +44,7 @@ var packageClean = /* @__PURE__ */ __name(async () => {
|
|
|
44
44
|
}, "packageClean");
|
|
45
45
|
|
|
46
46
|
// src/actions/package/compile/compile.ts
|
|
47
|
-
import
|
|
47
|
+
import chalk7 from "chalk";
|
|
48
48
|
|
|
49
49
|
// src/lib/checkResult.ts
|
|
50
50
|
import chalk3 from "chalk";
|
|
@@ -242,86 +242,23 @@ var buildEntries = /* @__PURE__ */ __name((folder, entryMode, verbose = false) =
|
|
|
242
242
|
}
|
|
243
243
|
}, "buildEntries");
|
|
244
244
|
|
|
245
|
-
// src/actions/package/compile/packageCompileTscTypes.ts
|
|
246
|
-
import { cwd as cwd2 } from "node:process";
|
|
247
|
-
import chalk7 from "chalk";
|
|
248
|
-
import { createProgramFromConfig as createProgramFromConfig2 } from "tsc-prog";
|
|
249
|
-
import { DiagnosticCategory as DiagnosticCategory2 } from "typescript";
|
|
250
|
-
var packageCompileTscTypes = /* @__PURE__ */ __name((folder = "src", { verbose } = {}, compilerOptionsParam) => {
|
|
251
|
-
const pkg = process.env.INIT_CWD ?? cwd2();
|
|
252
|
-
if (verbose) {
|
|
253
|
-
console.log(`Compiling types with TSC [${pkg}]`);
|
|
254
|
-
}
|
|
255
|
-
const compilerOptions = {
|
|
256
|
-
...getCompilerOptions({
|
|
257
|
-
declaration: true,
|
|
258
|
-
emitDeclarationOnly: true,
|
|
259
|
-
outDir: "dist",
|
|
260
|
-
removeComments: true,
|
|
261
|
-
skipDefaultLibCheck: true,
|
|
262
|
-
skipLibCheck: true,
|
|
263
|
-
sourceMap: true
|
|
264
|
-
}),
|
|
265
|
-
...compilerOptionsParam
|
|
266
|
-
};
|
|
267
|
-
const files = buildEntries(folder, "all");
|
|
268
|
-
const result = createProgramFromConfig2({
|
|
269
|
-
basePath: pkg ?? cwd2(),
|
|
270
|
-
compilerOptions,
|
|
271
|
-
exclude: [
|
|
272
|
-
"dist",
|
|
273
|
-
"docs",
|
|
274
|
-
"**/*.spec.*",
|
|
275
|
-
"**/*.stories.*",
|
|
276
|
-
"src/**/spec/**/*"
|
|
277
|
-
],
|
|
278
|
-
files
|
|
279
|
-
}).emit();
|
|
280
|
-
const diagResults = result.diagnostics.length;
|
|
281
|
-
for (const diag of result.diagnostics) {
|
|
282
|
-
switch (diag.category) {
|
|
283
|
-
case DiagnosticCategory2.Error: {
|
|
284
|
-
console.error(chalk7.red(diag.messageText));
|
|
285
|
-
console.error(chalk7.grey(pkg));
|
|
286
|
-
console.error(chalk7.blue(diag.file?.fileName));
|
|
287
|
-
break;
|
|
288
|
-
}
|
|
289
|
-
case DiagnosticCategory2.Warning: {
|
|
290
|
-
console.error(chalk7.yellow(diag.messageText));
|
|
291
|
-
console.error(chalk7.grey(pkg));
|
|
292
|
-
console.error(chalk7.blue(diag.file?.fileName));
|
|
293
|
-
break;
|
|
294
|
-
}
|
|
295
|
-
case DiagnosticCategory2.Suggestion: {
|
|
296
|
-
console.error(chalk7.white(diag.messageText));
|
|
297
|
-
console.error(chalk7.grey(pkg));
|
|
298
|
-
console.error(chalk7.blue(diag.file?.fileName));
|
|
299
|
-
break;
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
return diagResults;
|
|
304
|
-
}, "packageCompileTscTypes");
|
|
305
|
-
|
|
306
245
|
// src/actions/package/compile/packageCompileTsup.ts
|
|
307
|
-
var compileFolder = /* @__PURE__ */ __name(async (folder, entryMode = "single", options,
|
|
246
|
+
var compileFolder = /* @__PURE__ */ __name(async (folder, entryMode = "single", options, _verbose) => {
|
|
308
247
|
const outDir = options?.outDir ?? "dist";
|
|
309
248
|
const entry = buildEntries(folder, entryMode);
|
|
310
249
|
const optionsResult = defineConfig({
|
|
311
250
|
bundle: true,
|
|
312
251
|
cjsInterop: true,
|
|
313
252
|
clean: true,
|
|
314
|
-
dts:
|
|
253
|
+
dts: true,
|
|
315
254
|
entry,
|
|
316
255
|
format: [
|
|
317
256
|
"esm"
|
|
318
257
|
],
|
|
319
|
-
// minify: true,
|
|
320
258
|
outDir,
|
|
321
259
|
silent: true,
|
|
322
260
|
sourcemap: true,
|
|
323
261
|
splitting: false,
|
|
324
|
-
// terserOptions: { format: { comments: false } },
|
|
325
262
|
tsconfig: "tsconfig.json",
|
|
326
263
|
...options
|
|
327
264
|
});
|
|
@@ -336,11 +273,6 @@ var compileFolder = /* @__PURE__ */ __name(async (folder, entryMode = "single",
|
|
|
336
273
|
];
|
|
337
274
|
}))).flat();
|
|
338
275
|
await Promise.all(optionsList.map((options2) => build(options2)));
|
|
339
|
-
packageCompileTscTypes(folder, {
|
|
340
|
-
verbose
|
|
341
|
-
}, {
|
|
342
|
-
outDir
|
|
343
|
-
});
|
|
344
276
|
return 0;
|
|
345
277
|
}, "compileFolder");
|
|
346
278
|
var packageCompileTsup = /* @__PURE__ */ __name(async (config2) => {
|
|
@@ -383,10 +315,7 @@ var packageCompileTsup = /* @__PURE__ */ __name(async (config2) => {
|
|
|
383
315
|
sourcemap: true,
|
|
384
316
|
target: "esnext"
|
|
385
317
|
};
|
|
386
|
-
return await
|
|
387
|
-
publint: false,
|
|
388
|
-
verbose
|
|
389
|
-
}) || (await Promise.all(Object.entries(compileForNode).map(async ([folder, options]) => {
|
|
318
|
+
return (await Promise.all(Object.entries(compileForNode).map(async ([folder, options]) => {
|
|
390
319
|
const inEsBuildOptions = typeof compile?.node?.esbuildOptions === "object" ? compile?.node?.esbuildOptions : {};
|
|
391
320
|
return folder ? await compileFolder(folder, compile?.entryMode, {
|
|
392
321
|
...standardOptions,
|
|
@@ -431,7 +360,7 @@ var packageCompileTsup = /* @__PURE__ */ __name(async (config2) => {
|
|
|
431
360
|
// src/actions/package/compile/compile.ts
|
|
432
361
|
var packageCompile = /* @__PURE__ */ __name(async (inConfig = {}) => {
|
|
433
362
|
const pkg = process.env.INIT_CWD;
|
|
434
|
-
console.log(
|
|
363
|
+
console.log(chalk7.green(`Compiling ${pkg}`));
|
|
435
364
|
const config2 = await loadConfig(inConfig);
|
|
436
365
|
const publint = config2.publint;
|
|
437
366
|
const mode = config2.compile?.mode ?? "tsup";
|
|
@@ -451,7 +380,7 @@ var packageCompile = /* @__PURE__ */ __name(async (inConfig = {}) => {
|
|
|
451
380
|
|
|
452
381
|
// src/actions/package/copy-assets.ts
|
|
453
382
|
import path3 from "node:path/posix";
|
|
454
|
-
import
|
|
383
|
+
import chalk8 from "chalk";
|
|
455
384
|
import cpy from "cpy";
|
|
456
385
|
var copyTargetAssets = /* @__PURE__ */ __name(async (target, name, location) => {
|
|
457
386
|
try {
|
|
@@ -470,7 +399,7 @@ var copyTargetAssets = /* @__PURE__ */ __name(async (target, name, location) =>
|
|
|
470
399
|
flat: false
|
|
471
400
|
});
|
|
472
401
|
if (values.length > 0) {
|
|
473
|
-
console.log(
|
|
402
|
+
console.log(chalk8.green(`Copying Assets [${target.toUpperCase()}] - ${name} - ${location}`));
|
|
474
403
|
}
|
|
475
404
|
for (const value of values) {
|
|
476
405
|
console.log(`${value.split("/").pop()} => ./dist/${target}`);
|
|
@@ -500,8 +429,8 @@ var packageCopyAssets = /* @__PURE__ */ __name(async ({ target }) => {
|
|
|
500
429
|
|
|
501
430
|
// src/actions/package/deps.ts
|
|
502
431
|
import { existsSync, readFileSync } from "node:fs";
|
|
503
|
-
import { cwd as
|
|
504
|
-
import
|
|
432
|
+
import { cwd as cwd2 } from "node:process";
|
|
433
|
+
import chalk9 from "chalk";
|
|
505
434
|
import depcheck from "depcheck";
|
|
506
435
|
var special = depcheck.special;
|
|
507
436
|
var defaultIgnorePatterns = [
|
|
@@ -528,21 +457,21 @@ var defaultIgnoreDevPatterns = [
|
|
|
528
457
|
var reportUnused = /* @__PURE__ */ __name((name, unused) => {
|
|
529
458
|
if (unused.length > 0) {
|
|
530
459
|
const message = [
|
|
531
|
-
|
|
460
|
+
chalk9.yellow(`${unused.length} Unused ${name}`)
|
|
532
461
|
];
|
|
533
|
-
for (const value of unused) message.push(
|
|
462
|
+
for (const value of unused) message.push(chalk9.gray(` ${value}`));
|
|
534
463
|
console.log(message.join("\n"));
|
|
535
464
|
}
|
|
536
465
|
}, "reportUnused");
|
|
537
466
|
var reportMissing = /* @__PURE__ */ __name((name, missing) => {
|
|
538
467
|
if (Object.keys(missing).length > 0) {
|
|
539
468
|
const message = [
|
|
540
|
-
|
|
469
|
+
chalk9.yellow(`${Object.entries(missing).length} Missing ${name}`)
|
|
541
470
|
];
|
|
542
471
|
for (const [key, value] of Object.entries(missing)) {
|
|
543
|
-
message.push(`${key}`,
|
|
472
|
+
message.push(`${key}`, chalk9.gray(` ${value.at(0)}`));
|
|
544
473
|
}
|
|
545
|
-
console.log(
|
|
474
|
+
console.log(chalk9.yellow(message.join("\n")));
|
|
546
475
|
}
|
|
547
476
|
}, "reportMissing");
|
|
548
477
|
var analyzeDeps = /* @__PURE__ */ __name(async (pkg, ignoreMatches) => {
|
|
@@ -597,7 +526,7 @@ var analyzeDeps = /* @__PURE__ */ __name(async (pkg, ignoreMatches) => {
|
|
|
597
526
|
};
|
|
598
527
|
}, "analyzeDeps");
|
|
599
528
|
var packageDeps = /* @__PURE__ */ __name(async () => {
|
|
600
|
-
const pkg = process.env.INIT_CWD ??
|
|
529
|
+
const pkg = process.env.INIT_CWD ?? cwd2();
|
|
601
530
|
const pkgName = process.env.npm_package_name;
|
|
602
531
|
const packageContent = existsSync(`${pkg}/package.json`) ? JSON.parse(readFileSync(`${pkg}/package.json`, {
|
|
603
532
|
encoding: "utf8"
|
|
@@ -647,10 +576,10 @@ var packageDeps = /* @__PURE__ */ __name(async () => {
|
|
|
647
576
|
reportUnused("dependencies", unusedDeps);
|
|
648
577
|
reportUnused("devDependencies", unusedDevDeps);
|
|
649
578
|
if (Object.entries(invalidDirs).length > 0) {
|
|
650
|
-
for (const [key, value] of Object.entries(invalidDirs)) console.warn(
|
|
579
|
+
for (const [key, value] of Object.entries(invalidDirs)) console.warn(chalk9.gray(`Invalid Dir: ${key}: ${value}`));
|
|
651
580
|
}
|
|
652
581
|
if (Object.entries(invalidFiles).length > 0) {
|
|
653
|
-
for (const [key, value] of Object.entries(invalidFiles)) console.warn(
|
|
582
|
+
for (const [key, value] of Object.entries(invalidFiles)) console.warn(chalk9.gray(`Invalid File: ${key}: ${value}`));
|
|
654
583
|
}
|
|
655
584
|
reportMissing("dependencies", missingDepsObject);
|
|
656
585
|
reportMissing("devDependencies", missingDevDepsObject);
|
|
@@ -661,7 +590,7 @@ var packageDeps = /* @__PURE__ */ __name(async () => {
|
|
|
661
590
|
// src/actions/package/gen-docs.ts
|
|
662
591
|
import { existsSync as existsSync2 } from "node:fs";
|
|
663
592
|
import path4 from "node:path";
|
|
664
|
-
import
|
|
593
|
+
import chalk10 from "chalk";
|
|
665
594
|
import { Application, ArgumentsReader, TSConfigReader, TypeDocReader } from "typedoc";
|
|
666
595
|
var ExitCodes = {
|
|
667
596
|
CompileError: 3,
|
|
@@ -763,7 +692,7 @@ var runTypeDoc = /* @__PURE__ */ __name(async (app) => {
|
|
|
763
692
|
return ExitCodes.OutputError;
|
|
764
693
|
}
|
|
765
694
|
}
|
|
766
|
-
console.log(
|
|
695
|
+
console.log(chalk10.green(`${pkgName} - Ok`));
|
|
767
696
|
return ExitCodes.Ok;
|
|
768
697
|
}, "runTypeDoc");
|
|
769
698
|
|