@deltabox/toolchain 2.1.1 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +398 -628
- package/README.md +6 -0
- package/dist/changelog.d.ts +6 -5
- package/dist/changelog.js +1 -1
- package/dist/cli/commands/providers.js +1 -1
- package/dist/cli/commands/reset.js +1 -1
- package/dist/cli/config-selection.js +1 -1
- package/dist/cli/index.d.ts +2 -2
- package/dist/cli/index.js +1 -1
- package/dist/cli/update-check.js +1 -1
- package/dist/config.d.ts +2 -2
- package/dist/config.js +1 -1
- package/dist/index.d.ts +38 -30
- package/dist/index.js +1 -1
- package/dist/migrate.d.ts +2 -2
- package/dist/migrate.js +1 -1
- package/dist/package.js +1 -1
- package/dist/packages/changelog/src/cli/index.js +1 -1
- package/dist/packages/changelog/src/index.d.ts +7 -6
- package/dist/packages/changelog/src/index.js +1 -1
- package/dist/packages/changelog/src/run-workflows.d.ts +39 -2
- package/dist/packages/changelog/src/run-workflows.js +1 -1
- package/dist/packages/changelog/src/run.d.ts +1 -1
- package/dist/packages/changelog/src/run.js +1 -1
- package/dist/packages/changelog/src/sync.js +1 -1
- package/dist/packages/changelog/src/templates.js +1 -1
- package/dist/packages/changelog/src/utils/format.d.ts +5 -3
- package/dist/packages/changelog/src/utils/format.js +5 -5
- package/dist/packages/changelog/src/utils/git.d.ts +1 -1
- package/dist/packages/changelog/src/utils/git.js +1 -1
- package/dist/packages/changelog/src/utils/reformat.d.ts +7 -2
- package/dist/packages/changelog/src/utils/reformat.js +5 -4
- package/dist/packages/changelog/src/utils/release-notes.js +1 -1
- package/dist/packages/changelog/src/utils/repo.js +1 -1
- package/dist/packages/changelog/src/utils/summary.d.ts +1 -1
- package/dist/packages/changelog/src/utils/types.d.ts +9 -46
- package/dist/packages/changelog/src/utils/versioning.d.ts +11 -14
- package/dist/packages/changelog/src/utils/write.js +1 -1
- package/dist/packages/changelog/src/workflows.d.ts +11 -3
- package/dist/packages/changelog/src/workflows.js +5 -5
- package/dist/packages/config/src/cli/index.d.ts +1 -1
- package/dist/packages/config/src/collect.js +1 -1
- package/dist/packages/config/src/config-json.js +1 -1
- package/dist/packages/config/src/generators/env.js +2 -2
- package/dist/packages/config/src/generators/markdown.js +8 -8
- package/dist/packages/config/src/generators/output.js +1 -0
- package/dist/packages/config/src/generators/types.js +3 -3
- package/dist/packages/config/src/index.d.ts +3 -3
- package/dist/packages/config/src/index.js +1 -1
- package/dist/packages/config/src/schema.d.ts +16 -0
- package/dist/packages/config/src/schema.js +1 -1
- package/dist/packages/config/src/types.d.ts +5 -0
- package/dist/packages/core/src/editor-config.js +1 -1
- package/dist/packages/core/src/loader.js +1 -1
- package/dist/packages/core/src/manifest.js +1 -1
- package/dist/packages/core/src/paths.js +1 -0
- package/dist/packages/core/src/provider-registry.js +1 -1
- package/dist/packages/core/src/reset.d.ts +3 -0
- package/dist/packages/core/src/reset.js +1 -1
- package/dist/packages/core/src/sync.js +1 -1
- package/dist/packages/core/src/vscode.js +1 -1
- package/dist/packages/core/src/watch.d.ts +1 -1
- package/dist/packages/core/src/watch.js +1 -1
- package/dist/packages/migrate/src/cli/index.js +1 -1
- package/dist/packages/migrate/src/eslint.js +1 -1
- package/dist/packages/migrate/src/index.d.ts +2 -2
- package/dist/packages/migrate/src/index.js +1 -1
- package/dist/packages/migrate/src/prettier.d.ts +2 -0
- package/dist/packages/migrate/src/prettier.js +2 -2
- package/dist/packages/migrate/src/vite-target.js +1 -1
- package/dist/packages/project/src/cli/index.js +1 -1
- package/dist/packages/project/src/index.d.ts +4 -4
- package/dist/packages/project/src/index.js +1 -1
- package/dist/packages/project/src/typescript.d.ts +4 -2
- package/dist/packages/project/src/typescript.js +2 -2
- package/dist/packages/shared/src/changelog-callbacks.d.ts +72 -0
- package/dist/packages/shared/src/config-schema/biome.d.ts +8 -1
- package/dist/packages/shared/src/config-schema/biome.js +1 -1
- package/dist/packages/shared/src/config-schema/changelog.d.ts +3049 -30
- package/dist/packages/shared/src/config-schema/changelog.js +1 -1
- package/dist/packages/shared/src/config-schema/ci.d.ts +1163 -23
- package/dist/packages/shared/src/config-schema/external.js +1 -0
- package/dist/packages/shared/src/config-schema/format.d.ts +16 -10
- package/dist/packages/shared/src/config-schema/format.js +1 -1
- package/dist/packages/shared/src/config-schema/generated/azure-pipelines.d.ts +10501 -0
- package/dist/packages/shared/src/config-schema/generated/biome-config.d.ts +5962 -0
- package/dist/packages/shared/src/config-schema/generated/github-workflow.d.ts +179 -0
- package/dist/packages/shared/src/config-schema/generated/gitlab-ci.d.ts +296 -0
- package/dist/packages/shared/src/config-schema/generated/oxfmt-config.d.ts +411 -0
- package/dist/packages/shared/src/config-schema/generated/oxlint-config.d.ts +2218 -0
- package/dist/packages/shared/src/config-schema/index.d.ts +5355 -142
- package/dist/packages/shared/src/config-schema/index.js +1 -1
- package/dist/packages/shared/src/config-schema/json.d.ts +18 -0
- package/dist/packages/shared/src/config-schema/json.js +1 -0
- package/dist/packages/shared/src/config-schema/logger.d.ts +10 -1
- package/dist/packages/shared/src/config-schema/logger.js +1 -1
- package/dist/packages/shared/src/config-schema/tsconfig.d.ts +5 -4
- package/dist/packages/shared/src/config-schema/tsconfig.js +1 -1
- package/dist/packages/shared/src/config-schema/vite.d.ts +5 -3
- package/dist/packages/shared/src/config-schema/vite.js +1 -1
- package/dist/packages/shared/src/config-schema/workflow.d.ts +946 -31
- package/dist/packages/shared/src/config-schema/workflow.js +1 -1
- package/dist/packages/shared/src/config-types.d.ts +257 -33
- package/dist/packages/shared/src/fs-utils.d.ts +12 -0
- package/dist/packages/shared/src/fs-utils.js +8 -1
- package/dist/packages/shared/src/index.d.ts +19 -11
- package/dist/packages/shared/src/index.js +1 -1
- package/dist/packages/shared/src/object-utils.d.ts +2 -0
- package/dist/packages/shared/src/object-utils.js +1 -1
- package/dist/packages/shared/src/registry-policy.d.ts +3 -2
- package/dist/packages/shared/src/registry-policy.js +1 -1
- package/dist/packages/shared/src/run.d.ts +2 -0
- package/dist/packages/shared/src/run.js +1 -1
- package/dist/packages/shared/src/string-utils.d.ts +7 -5
- package/dist/packages/shared/src/string-utils.js +2 -2
- package/dist/packages/shared/src/template.d.ts +2 -1
- package/dist/packages/shared/src/template.js +1 -1
- package/dist/packages/shared/src/toolchain.d.ts +14 -7
- package/dist/packages/shared/src/toolchain.js +1 -1
- package/dist/packages/shared/src/types.d.ts +5 -0
- package/dist/packages/shared/src/vite-defaults.d.ts +4 -3
- package/dist/packages/shared/src/vite-defaults.js +1 -1
- package/dist/packages/shared/src/yaml.js +5 -5
- package/dist/packages/template/src/scaffold.js +1 -1
- package/dist/packages/tsconfig/src/cli/generate/index.js +1 -1
- package/dist/packages/tsconfig/src/overrides.d.ts +5 -5
- package/dist/packages/tsdown/src/config/node.d.ts +5 -0
- package/dist/packages/tsdown/src/config/node.js +2 -2
- package/dist/packages/tsdown/src/index.d.ts +3 -3
- package/dist/packages/tsdown/src/index.js +1 -1
- package/dist/packages/vite/src/plugin.js +1 -1
- package/dist/packages/vite/src/vp.js +1 -1
- package/dist/project.d.ts +3 -3
- package/dist/project.js +1 -1
- package/dist/shared.d.ts +18 -10
- package/dist/shared.js +1 -1
- package/dist/tooling.js +1 -1
- package/dist/tsdown.d.ts +2 -2
- package/dist/tsdown.js +1 -1
- package/package.json +25 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as e}from"node:path";import"node:url";import.meta.url;import{logger as t}from"../../../shared/src/logger.js";import"../../../shared/src/index.js";import{loadToolchainConfig as n}from"../../../core/src/loader.js";import{selectProjects as r}from"../../../core/src/select.js";import{runSync as i}from"../../../core/src/sync.js";import"../../../core/src/index.js";import{diffFiles as a,hasPending as o}from"../check.js";import{listMigrations as s,migrations as c}from"../registry.js";import{cancel as
|
|
1
|
+
import{default as e}from"node:path";import"node:url";import.meta.url;import{logger as t}from"../../../shared/src/logger.js";import"../../../shared/src/index.js";import{loadToolchainConfig as n}from"../../../core/src/loader.js";import{selectProjects as r}from"../../../core/src/select.js";import{runSync as i}from"../../../core/src/sync.js";import"../../../core/src/index.js";import{diffFiles as a,hasPending as o}from"../check.js";import{listMigrations as s,migrations as c}from"../registry.js";import l from"node:fs";import{cancel as u,isCancel as d,multiselect as f}from"@clack/prompts";function p(e){return!!(process.stdin.isTTY&&process.stdout.isTTY)&&e.json!==!0}function m(){u(`Cancelled.`),process.exitCode=1}function h(){return[{name:`migrate`,description:`Migrate Biome / ESLint / Prettier / Dprint / Oxc config, or fold vite.config.* into dbx.config.`,options:[{flags:`--from <tool>`,description:`Source tool (repeatable): biome | eslint | prettier | dprint | oxc | vite | all.`,multiple:!0},{flags:`--to <tool>`,description:`Target tool (default: oxc).`,default:`oxc`},{flags:`--cwd <dir>`,description:`Project root (default: cwd).`},{flags:`--recursive`,description:`Also migrate the discovered projects under the root (default: root only).`},{flags:`--write`,description:`Write the files (default: dry-run).`},{flags:`--dry-run`,description:`Do not write anything (default).`},{flags:`--check`,description:`CI: exit non-zero when the oxc config is stale.`},{flags:`--target <target>`,description:`files (default) | vite.`},{flags:`--online`,description:`Allow network (e.g. @oxlint/migrate).`},{flags:`--ignore-vite-config-file`,description:"Do not remove the folded `vite.config.*`."},{flags:`--ignore-managed-files`,description:`Skip the post-migration sync (leave the toolchain-managed files as-is).`},{flags:`--ignore-changelog`,description:`Skip the changelog task in the post-migration sync.`},{flags:`--json`,description:`Print the result as JSON.`}],run:async(s,u)=>{let h=s.cwd??u.cwd,g=!!s.check,_=!!s.write&&!s.dryRun&&!g,v=!!s.online,y=s.from,b=Array.isArray(y)?y:y?[y]:[],x=b.includes(`all`),S=b.filter(e=>e!==`all`),C=e=>b.length===0||x||S.includes(e.from),w=s.target??`files`,T=String(s.to??`oxc`);if(T!==`oxc`)throw Error(`--to ${T} is not supported (only 'oxc').`);let E=!!s.recursive,D=e=>{let t=c().filter(t=>C(t)&&t.detect(e));if(b.length>0)return t;let n=new Map(t.map(e=>[e.id,e])),r=[],i=n.get(`biome-to-oxc`);if(i)r.push(i);else{let e=[`prettier-to-oxc`,`dprint-to-oxc`].map(e=>n.get(e)).find(Boolean);e&&r.push(e);let t=n.get(`eslint-to-oxc`);t&&r.push(t)}for(let e of[`oxc-to-toolchain`,`vite-to-toolchain`]){let t=n.get(e);t&&r.push(t)}return r},O=[h];if(E){let n=r({root:h}).filter(e=>D(e.dir).length>0);if(n.length===0){t.info(`nothing to migrate under ${h}.`);return}let i=n;if(p(s)){let t=await f({message:`Which projects should I migrate?`,required:!0,options:[{value:`__all__`,label:`All projects`},...n.map(t=>({value:t.dir,label:t.rel===`.`?e.basename(h):t.rel,...t.name?{hint:t.name}:{}}))]});if(d(t)){m();return}let r=t;i=r.includes(`__all__`)?n:n.filter(e=>r.includes(e.dir))}O=i.map(e=>e.dir)}let k=[];for(let e of O)for(let t of D(e))k.push({dir:e,result:await t.run({cwd:e,write:_,online:v,target:w,ignoreViteConfigFile:!!s.ignoreViteConfigFile,ignoreManagedFiles:!!s.ignoreManagedFiles,ignoreChangelog:!!s.ignoreChangelog})});if(k.length===0){let e=c().some(e=>C(e));t.info(S.length>0&&!x&&!e?`no migration registered for: ${S.join(`, `)}.`:`nothing to migrate (no Biome/ESLint/Prettier/Dprint/Oxc/vite config detected).`);return}let A=t=>E?`${e.relative(h,t)||`.`}: `:``,j=[...new Set(k.filter(({result:e})=>e.written.length>0||(e.removed?.length??0)>0).map(({dir:e})=>e))];if(g){let n=k.flatMap(({result:e})=>a(e.files??[])),r=n.filter(e=>e.status!==`same`),i=k.flatMap(({result:e})=>e.removed??[]).filter(e=>l.existsSync(e));if(s.json)t.raw(JSON.stringify(k.map(e=>e.result),null,4));else if(r.length||i.length){for(let n of r)t.info(`${n.status} ${e.relative(h,n.path)||n.path}`);for(let n of i)t.info(`D ${e.relative(h,n)||n}`);t.info(`${r.length+i.length} file(s) out of date — run \`migrate --write\` to apply.`)}else t.info(`up to date.`);(o(n)||i.length>0)&&(process.exitCode=1);return}let M=async()=>{if(!_||j.length===0||s.ignoreManagedFiles||!u.syncTasks?.length)return;let e=s.ignoreChangelog?u.syncTasks.filter(e=>e.name!==`changelog`):u.syncTasks;for(let r of j){let a=await n(r);s.json||t.info(`${A(r)}regenerating managed files.`),await i({tasks:e,cwd:r,projectType:a.projectType,config:a.config,ownConfig:a.ownConfig,tokens:a.tokens,quiet:s.json===!0})}};if(s.json)await M(),t.raw(JSON.stringify(k.map(e=>e.result),null,4));else{for(let{dir:e,result:n}of k){t.info(`${A(e)}${n.from} -> ${n.to} ${_?`wrote`:`would write`}`);for(let e of n.written)t.info(` ${_?`+`:`?`} ${e}`);for(let e of n.removed??[])t.info(` ${_?`-`:`?`} ${e}`);for(let e of n.notes??[])t.info(` ${e}`);if(n.unmapped?.length){t.info(` unmapped (${n.unmapped.length}):`);for(let e of n.unmapped.slice(0,25))t.info(` - ${e.source}: ${e.reason}`)}}!_&&j.length>0&&!s.ignoreManagedFiles&&t.info(`managed files are regenerated after --write; pass --ignore-managed-files to skip.`),await M(),_||t.info(`dry-run — re-run with --write to apply.`)}}},{name:`migrate:list`,description:`List the registered migrations and whether each is detected.`,options:[{flags:`--cwd <dir>`,description:`Project root (default: cwd).`},{flags:`--json`,description:`Print as JSON.`}],run:(e,n)=>{let r=e.cwd??n.cwd,i=s(r);if(e.json)t.raw(JSON.stringify(i,null,4));else for(let e of i)t.info(` ${e.id.padEnd(16)} ${e.from} -> ${e.to} [${e.detected?`detected`:`not found`}]`),t.info(` ${e.description}`)}}]}export{h as migrateCommands};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as e}from"node:path";import"node:url";import.meta.url;import{spawnCross as t}from"../../shared/src/run.js";import"../../shared/src/index.js";import{renderViteTarget as n}from"./vite-target.js";import r from"node:fs";const i=[`.eslintrc.json`,`.eslintrc`],a=[`eslint.config.js`,`eslint.config.mjs`,`eslint.config.cjs`,`eslint.config.ts`,`.eslintrc.js`,`.eslintrc.cjs`];function o(t){for(let n of i){let i=e.join(t,n);if(r.existsSync(i))return{file:i,json:!0}}for(let n of a){let i=e.join(t,n);if(r.existsSync(i))return{file:i,json:!1}}}function s(e){let t=Array.isArray(e)?e[0]:e;return t===2||t===`error`?`error`:t===1||t===`warn`?`warn`:`off`}function c(e){return e.startsWith(`@typescript-eslint/`)?{name:`typescript/${e.slice(19)}`,mapped:!0}:{name:e,mapped:!0}}function l(e,t,n){for(let[r,i]of Object.entries(e??{})){let e=c(r);t[e.name]=s(i),e.mapped||n.push({source:r,reason:`unknown plugin prefix`})}}function u(e,n,r){return new Promise(i=>{let a=t(e,n,{cwd:r,stdio:`inherit`});a.on(`error`,()=>i(1)),a.on(`exit`,e=>i(e??0))})}async function d(t){let n=e.join(t,`.oxlintrc.json`);if(await u(`npx`,[`--yes`,`@oxlint/migrate`],t)===0&&r.existsSync(n))try{return JSON.parse(r.readFileSync(n,`utf-8`).replace(/^\uFEFF/,``))}catch{return}}const f={id:`eslint-to-oxc`,from:`eslint`,to:`oxlint`,description:`Migrate ESLint to Oxlint (JSON configs; flat configs via @oxlint/migrate --online).`,detect:e=>!!o(e),run:async t=>{let i=o(t.cwd);if(!i)throw Error(`eslint-to-oxc: no ESLint config found.`);let a={},s=[],c=[`Source: ${e.basename(i.file)}.`];if(i.json)
|
|
1
|
+
import{default as e}from"node:path";import"node:url";import.meta.url;import{spawnCross as t}from"../../shared/src/run.js";import"../../shared/src/index.js";import{renderViteTarget as n}from"./vite-target.js";import r from"node:fs";const i=[`.eslintrc.json`,`.eslintrc`],a=[`eslint.config.js`,`eslint.config.mjs`,`eslint.config.cjs`,`eslint.config.ts`,`.eslintrc.js`,`.eslintrc.cjs`];function o(t){for(let n of i){let i=e.join(t,n);if(r.existsSync(i))return{file:i,json:!0}}for(let n of a){let i=e.join(t,n);if(r.existsSync(i))return{file:i,json:!1}}}function s(e){let t=Array.isArray(e)?e[0]:e;return t===2||t===`error`?`error`:t===1||t===`warn`?`warn`:`off`}function c(e){return e.startsWith(`@typescript-eslint/`)?{name:`typescript/${e.slice(19)}`,mapped:!0}:{name:e,mapped:!0}}function l(e,t,n){for(let[r,i]of Object.entries(e??{})){let e=c(r);t[e.name]=s(i),e.mapped||n.push({source:r,reason:`unknown plugin prefix`})}}function u(e,n,r){return new Promise(i=>{let a=t(e,n,{cwd:r,stdio:`inherit`});a.on(`error`,()=>i(1)),a.on(`exit`,e=>i(e??0))})}async function d(t){let n=e.join(t,`.oxlintrc.json`);if(await u(`npx`,[`--yes`,`@oxlint/migrate`],t)===0&&r.existsSync(n))try{return JSON.parse(r.readFileSync(n,`utf-8`).replace(/^\uFEFF/,``))}catch{return}}const f={id:`eslint-to-oxc`,from:`eslint`,to:`oxlint`,description:`Migrate ESLint to Oxlint (JSON configs; flat configs via @oxlint/migrate --online).`,detect:e=>!!o(e),run:async t=>{let i=o(t.cwd);if(!i)throw Error(`eslint-to-oxc: no ESLint config found.`);let a={},s=[],c=[`Source: ${e.basename(i.file)}.`];if(i.json){let t;try{t=JSON.parse(r.readFileSync(i.file,`utf-8`).replace(/^\uFEFF/,``))}catch{throw Error(`cannot parse ${e.basename(i.file)}: only JSON ESLint configs are supported; use --online for JS/flat configs.`)}l(t.rules,a,s)}else if(t.online&&t.write){let e=await d(t.cwd);e?(l(e.rules,a,s),c.push("Rules evaluated with `@oxlint/migrate` (online).")):c.push("`@oxlint/migrate` did not produce `.oxlintrc.json`; hand-map the rules.")}else t.online?c.push("Flat config: online evaluation runs `@oxlint/migrate`, which writes `.oxlintrc.json` — re-run with `--write`."):c.push("Flat config detected — re-run with `--online --write` to use `@oxlint/migrate`, or hand-map the rules.");let u={$schema:`./node_modules/oxlint/configuration_schema.json`,rules:a};if((t.target??`files`)===`vite`){let e=n(t.cwd,{lint:u});return t.write&&r.writeFileSync(e.path,e.content,`utf-8`),{id:f.id,from:`eslint`,to:`oxlint`,written:[e.path],files:[e],oxlint:u,unmapped:s,notes:[...c,"Folded into vite.config.ts (`lint`)."]}}let p={path:e.join(t.cwd,`.oxlintrc.json`),content:`${JSON.stringify(u,null,4)}\n`};return t.write&&r.writeFileSync(p.path,p.content,`utf-8`),{id:f.id,from:`eslint`,to:`oxlint`,written:[p.path],files:[p],oxlint:u,unmapped:s,notes:c}}};export{f as eslintToOx,o as findEslintConfig,c as mapRuleName,d as runOxlintMigrate};
|
|
@@ -9,8 +9,8 @@ import { eslintToOx, findEslintConfig, mapRuleName, runOxlintMigrate } from "./e
|
|
|
9
9
|
import { OXC_FMT_FILE, OXC_LINT_FILE, findOxcConfigs, oxcToToolchain } from "./oxc.js";
|
|
10
10
|
import { DEFAULT_IGNORE, OxfmtMapping, mapBiomeFormatter, mapBiomeIncludes, mapBiomeToOxfmt, mapOrganizeImports } from "./oxfmt-map.js";
|
|
11
11
|
import { OxlintMapping, RULE_MAP, mapBiomeToOxlint } from "./oxlint-map.js";
|
|
12
|
-
import { findPrettierConfig, mapPrettierToOxfmt, prettierToOx, readPrettierIgnore } from "./prettier.js";
|
|
12
|
+
import { findPrettierConfig, hasPrettierConfig, mapPrettierToOxfmt, prettierToOx, readPrettierIgnore } from "./prettier.js";
|
|
13
13
|
import { MigrationInfo, detectMigrations, findMigration, listMigrations, migrations, runDetectedMigrations, runMigration } from "./registry.js";
|
|
14
14
|
import { VITE_CONFIG_FILES, ensureViteFmtIgnore, extractViteObject, findDbxConfig, findViteConfig, foldToolchainSection, foldViteIntoConfig, mergeViteObjects, renderFreshSectionsConfig, scanLiteralObject, viteToToolchain } from "./vite.js";
|
|
15
15
|
import { findTopLevelValue, matchBracket, mergeViteConfig, renderViteTarget, serializeTs, writeViteTarget } from "./vite-target.js";
|
|
16
|
-
export { BIOME_CONFIG_FILES, DEFAULT_IGNORE, FileDiff, FileStatus, MigrateTarget, MigrateTool, MigrationContext, MigrationFile, MigrationInfo, MigrationResult, OXC_FMT_FILE, OXC_LINT_FILE, OxfmtMapping, OxlintMapping, RULE_MAP, ToolchainMigration, UnmappedItem, VITE_CONFIG_FILES, biomeToOx, detectMigrations, diffFiles, dprintToOx, ensureViteFmtIgnore, eslintToOx, extractViteObject, findBiomeConfig, findDbxConfig, findDprintConfig, findEslintConfig, findMigration, findOxcConfigs, findPrettierConfig, findTopLevelValue, findViteConfig, foldToolchainSection, foldViteIntoConfig, hasPending, listMigrations, mapBiomeFormatter, mapBiomeIncludes, mapBiomeToOxfmt, mapBiomeToOxlint, mapDprintToOxfmt, mapOrganizeImports, mapPrettierToOxfmt, mapRuleName, matchBracket, mergeViteConfig, mergeViteObjects, migrateCommands, migrations, oxcToToolchain, prettierToOx, readJsonc, readPrettierIgnore, renderFreshSectionsConfig, renderViteTarget, runDetectedMigrations, runMigration, runOxlintMigrate, scanLiteralObject, serializeTs, stripJsonc, viteToToolchain, writeViteTarget };
|
|
16
|
+
export { BIOME_CONFIG_FILES, DEFAULT_IGNORE, FileDiff, FileStatus, MigrateTarget, MigrateTool, MigrationContext, MigrationFile, MigrationInfo, MigrationResult, OXC_FMT_FILE, OXC_LINT_FILE, OxfmtMapping, OxlintMapping, RULE_MAP, ToolchainMigration, UnmappedItem, VITE_CONFIG_FILES, biomeToOx, detectMigrations, diffFiles, dprintToOx, ensureViteFmtIgnore, eslintToOx, extractViteObject, findBiomeConfig, findDbxConfig, findDprintConfig, findEslintConfig, findMigration, findOxcConfigs, findPrettierConfig, findTopLevelValue, findViteConfig, foldToolchainSection, foldViteIntoConfig, hasPending, hasPrettierConfig, listMigrations, mapBiomeFormatter, mapBiomeIncludes, mapBiomeToOxfmt, mapBiomeToOxlint, mapDprintToOxfmt, mapOrganizeImports, mapPrettierToOxfmt, mapRuleName, matchBracket, mergeViteConfig, mergeViteObjects, migrateCommands, migrations, oxcToToolchain, prettierToOx, readJsonc, readPrettierIgnore, renderFreshSectionsConfig, renderViteTarget, runDetectedMigrations, runMigration, runOxlintMigrate, scanLiteralObject, serializeTs, stripJsonc, viteToToolchain, writeViteTarget };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"node:path";import"node:url";import.meta.url;import{DEFAULT_IGNORE as e,mapBiomeFormatter as t,mapBiomeIncludes as n,mapBiomeToOxfmt as r,mapOrganizeImports as i}from"./oxfmt-map.js";import{RULE_MAP as a,mapBiomeToOxlint as o}from"./oxlint-map.js";import{findTopLevelValue as s,matchBracket as c,mergeViteConfig as l,renderViteTarget as u,serializeTs as d,writeViteTarget as f}from"./vite-target.js";import{BIOME_CONFIG_FILES as p,biomeToOx as m,findBiomeConfig as h,readJsonc as g,stripJsonc as _}from"./biome.js";import{diffFiles as v,hasPending as y}from"./check.js";import{dprintToOx as b,findDprintConfig as x,mapDprintToOxfmt as S}from"./dprint.js";import{eslintToOx as C,findEslintConfig as w,mapRuleName as T,runOxlintMigrate as E}from"./eslint.js";import{VITE_CONFIG_FILES as D,ensureViteFmtIgnore as O,extractViteObject as k,findDbxConfig as A,findViteConfig as j,foldToolchainSection as M,foldViteIntoConfig as N,mergeViteObjects as P,renderFreshSectionsConfig as F,scanLiteralObject as I,viteToToolchain as L}from"./vite.js";import{OXC_FMT_FILE as R,OXC_LINT_FILE as z,findOxcConfigs as B,oxcToToolchain as V}from"./oxc.js";import{findPrettierConfig as H,
|
|
1
|
+
import"node:path";import"node:url";import.meta.url;import{DEFAULT_IGNORE as e,mapBiomeFormatter as t,mapBiomeIncludes as n,mapBiomeToOxfmt as r,mapOrganizeImports as i}from"./oxfmt-map.js";import{RULE_MAP as a,mapBiomeToOxlint as o}from"./oxlint-map.js";import{findTopLevelValue as s,matchBracket as c,mergeViteConfig as l,renderViteTarget as u,serializeTs as d,writeViteTarget as f}from"./vite-target.js";import{BIOME_CONFIG_FILES as p,biomeToOx as m,findBiomeConfig as h,readJsonc as g,stripJsonc as _}from"./biome.js";import{diffFiles as v,hasPending as y}from"./check.js";import{dprintToOx as b,findDprintConfig as x,mapDprintToOxfmt as S}from"./dprint.js";import{eslintToOx as C,findEslintConfig as w,mapRuleName as T,runOxlintMigrate as E}from"./eslint.js";import{VITE_CONFIG_FILES as D,ensureViteFmtIgnore as O,extractViteObject as k,findDbxConfig as A,findViteConfig as j,foldToolchainSection as M,foldViteIntoConfig as N,mergeViteObjects as P,renderFreshSectionsConfig as F,scanLiteralObject as I,viteToToolchain as L}from"./vite.js";import{OXC_FMT_FILE as R,OXC_LINT_FILE as z,findOxcConfigs as B,oxcToToolchain as V}from"./oxc.js";import{findPrettierConfig as H,hasPrettierConfig as U,mapPrettierToOxfmt as W,prettierToOx as G,readPrettierIgnore as K}from"./prettier.js";import{detectMigrations as q,findMigration as J,listMigrations as Y,migrations as X,runDetectedMigrations as Z,runMigration as Q}from"./registry.js";import{migrateCommands as $}from"./cli/index.js";export{p as BIOME_CONFIG_FILES,e as DEFAULT_IGNORE,R as OXC_FMT_FILE,z as OXC_LINT_FILE,a as RULE_MAP,D as VITE_CONFIG_FILES,m as biomeToOx,q as detectMigrations,v as diffFiles,b as dprintToOx,O as ensureViteFmtIgnore,C as eslintToOx,k as extractViteObject,h as findBiomeConfig,A as findDbxConfig,x as findDprintConfig,w as findEslintConfig,J as findMigration,B as findOxcConfigs,H as findPrettierConfig,s as findTopLevelValue,j as findViteConfig,M as foldToolchainSection,N as foldViteIntoConfig,y as hasPending,U as hasPrettierConfig,Y as listMigrations,t as mapBiomeFormatter,n as mapBiomeIncludes,r as mapBiomeToOxfmt,o as mapBiomeToOxlint,S as mapDprintToOxfmt,i as mapOrganizeImports,W as mapPrettierToOxfmt,T as mapRuleName,c as matchBracket,l as mergeViteConfig,P as mergeViteObjects,$ as migrateCommands,X as migrations,V as oxcToToolchain,G as prettierToOx,g as readJsonc,K as readPrettierIgnore,F as renderFreshSectionsConfig,u as renderViteTarget,Z as runDetectedMigrations,Q as runMigration,E as runOxlintMigrate,I as scanLiteralObject,d as serializeTs,_ as stripJsonc,L as viteToToolchain,f as writeViteTarget};
|
|
@@ -3,6 +3,8 @@ import __tsdown_shims_url from 'node:url';
|
|
|
3
3
|
import { ToolchainMigration } from "./types.js";
|
|
4
4
|
//#region packages/migrate/src/prettier.d.ts
|
|
5
5
|
type Json = Record<string, any>;
|
|
6
|
+
/** Whether a Prettier config file/field exists (without parsing it). */
|
|
7
|
+
export declare function hasPrettierConfig(cwd: string): boolean;
|
|
6
8
|
/** Locate a Prettier config (JSON files or the `prettier` package.json field). */
|
|
7
9
|
export declare function findPrettierConfig(cwd: string): {
|
|
8
10
|
file: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{default as e}from"node:path";import"node:url";import.meta.url;import{renderViteTarget as t}from"./vite-target.js";import n from"node:fs";const r=[`.prettierrc`,`.prettierrc.json`,`.prettierrc.jsonc`,`prettier.config.json`],i=[`printWidth`,`tabWidth`,`useTabs`,`semi`,`singleQuote`,`jsxSingleQuote`,`quoteProps`,`trailingComma`,`bracketSpacing`,`bracketSameLine`,`arrowParens`,`endOfLine`,`singleAttributePerLine`,`htmlWhitespaceSensitivity`,`vueIndentScriptAndStyle`];function a(t){for(let i of r){let r=e.join(t,i);if(n.existsSync(r)){let
|
|
2
|
-
`).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`#`)):[]}function
|
|
1
|
+
import{default as e}from"node:path";import"node:url";import.meta.url;import{renderViteTarget as t}from"./vite-target.js";import n from"node:fs";const r=[`.prettierrc`,`.prettierrc.json`,`.prettierrc.jsonc`,`prettier.config.json`],i=[`printWidth`,`tabWidth`,`useTabs`,`semi`,`singleQuote`,`jsxSingleQuote`,`quoteProps`,`trailingComma`,`bracketSpacing`,`bracketSameLine`,`arrowParens`,`endOfLine`,`singleAttributePerLine`,`htmlWhitespaceSensitivity`,`vueIndentScriptAndStyle`];function a(t){if(r.some(r=>n.existsSync(e.join(t,r))))return!0;let i=e.join(t,`package.json`);if(!n.existsSync(i))return!1;try{let e=JSON.parse(n.readFileSync(i,`utf-8`));return!!(e.prettier&&typeof e.prettier==`object`)}catch{return!1}}function o(t){for(let i of r){let r=e.join(t,i);if(n.existsSync(r)){let t=n.readFileSync(r,`utf-8`).replace(/^\uFEFF/,``);try{return{file:r,config:JSON.parse(t)}}catch{throw Error(`cannot parse ${e.basename(r)}: only JSON Prettier configs are supported.`)}}}let i=e.join(t,`package.json`);if(n.existsSync(i))try{let e=JSON.parse(n.readFileSync(i,`utf-8`));if(e.prettier&&typeof e.prettier==`object`)return{file:i,config:e.prettier}}catch{}}function s(t){let r=e.join(t,`.prettierignore`);return n.existsSync(r)?n.readFileSync(r,`utf-8`).split(`
|
|
2
|
+
`).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`#`)):[]}function c(e){let t={},n=[];for(let n of i)n in e&&(t[n]=e[n]);let r=Array.isArray(e.plugins)?e.plugins:[];for(let e of r)e.includes(`tailwindcss`)?t.sortTailwindcss=!0:e.includes(`packagejson`)?t.sortPackageJson=!0:n.push(`plugin: ${e}`);for(let t of Object.keys(e))!i.includes(t)&&t!==`plugins`&&t!==`overrides`&&n.push(`option: ${t}`),t===`overrides`&&n.push("option: overrides (convert to Oxfmt `overrides` manually)");return{oxfmt:t,unmapped:n}}const l={id:`prettier-to-oxc`,from:`prettier`,to:`oxfmt`,description:`Migrate a Prettier config to Oxfmt (.oxfmtrc.json).`,detect:e=>a(e),run:async r=>{let i=o(r.cwd);if(!i)throw Error(`prettier-to-oxc: no Prettier config found.`);let a=c(i.config),u=s(r.cwd);u.length&&(a.oxfmt.ignorePatterns=u);let d=a.unmapped.map(e=>({source:e,reason:`no Oxfmt equivalent`}));if((r.target??`files`)===`vite`){let o=t(r.cwd,{fmt:a.oxfmt});return r.write&&n.writeFileSync(o.path,o.content,`utf-8`),{id:l.id,from:`prettier`,to:`oxfmt`,written:[o.path],files:[o],oxfmt:a.oxfmt,unmapped:d,notes:[`Source: ${e.basename(i.file)}.`,"Folded into vite.config.ts (`fmt`)."]}}let f={path:e.join(r.cwd,`.oxfmtrc.json`),content:`${JSON.stringify(a.oxfmt,null,4)}\n`};return r.write&&n.writeFileSync(f.path,f.content,`utf-8`),{id:l.id,from:`prettier`,to:`oxfmt`,written:[f.path],files:[f],oxfmt:a.oxfmt,unmapped:d,notes:[`Source: ${e.basename(i.file)}.`]}}};export{o as findPrettierConfig,a as hasPrettierConfig,c as mapPrettierToOxfmt,l as prettierToOx,s as readPrettierIgnore};
|
|
@@ -2,4 +2,4 @@ import{default as e}from"node:path";import"node:url";import.meta.url;import t fr
|
|
|
2
2
|
`)},\n${i}]`;if(typeof e==`object`){let o=Object.entries(e);return o.length===0?`{}`:`{\n${o.map(([e,i])=>{let o=n.test(e)?e:JSON.stringify(e);return`${a}${o}: ${r(i,t+1)}`}).join(`,
|
|
3
3
|
`)},\n${i}}`}return JSON.stringify(e)}function i(e,t){let n=e[t],r=e[t+1];if(n===`/`&&r===`/`){for(;t<e.length&&e[t]!==`
|
|
4
4
|
`;)t++;return t}if(n===`/`&&r===`*`){for(t+=2;t<e.length&&(e[t]!==`*`||e[t+1]!==`/`);)t++;return t+2}if(n===`"`||n===`'`||n==="`"){let r=n;for(t++;t<e.length&&e[t]!==r;)e[t]===`\\`&&t++,t++;return t+1}return t}function a(e,t){let n={"{":`}`,"[":`]`}[e[t]];if(!n)return-1;let r=0;for(let a=t;a<e.length;a++){let o=i(e,a);if(o!==a)a=o-1;else if(e[a]===e[t])r++;else if(e[a]===n&&(r--,r===0))return a+1}return-1}function o(e,t,r,o){let s=1;for(let c=t+1;c<r;c++){let t=i(e,c);if(t!==c){c=t-1;continue}let l=e[c];if(l===`{`||l===`[`)s++;else if(l===`}`||l===`]`)s--;else if(s===1&&n.test(l)){let t=c;for(;t<r&&/[\w$]/.test(e[t]);)t++;let n=e.slice(c,t),i=t;for(;i<r&&/\s/.test(e[i]);)i++;if(n===o&&e[i]===`:`){let t=i+1;for(;t<r&&/\s/.test(e[t]);)t++;let n=e[t];if(n===`{`||n===`[`)return[t,a(e,t)];let o=t;for(;o<r&&e[o]!==`,`&&e[o]!==`}`;)o++;for(;o>t&&/\s/.test(e[o-1]);)o--;return[t,o]}c=t-1}}}function s(e,t){let n=Object.entries(t).filter(([,e])=>e!==void 0);if(!e)return`import { defineConfig } from 'vite-plus';\n\nexport default defineConfig({\n${n.map(([e,t])=>` ${e}: ${r(t,1)},`).join(`
|
|
5
|
-
`)}\n});\n`;let i=e,s=i.match(/defineConfig\s*\(\s*\{/);if(!s||s.index===void 0)
|
|
5
|
+
`)}\n});\n`;let i=e,s=i.match(/defineConfig\s*\(\s*\{/);if(!s||s.index===void 0)throw Error("cannot merge into a function/async vite config; add `fmt`/`lint` manually.");for(let[e,t]of n){let n=i.match(/defineConfig\s*\(\s*\{/);if(!n||n.index===void 0)break;let s=i.indexOf(`{`,n.index),c=a(i,s);if(c===-1)break;let l=r(t,1),u=o(i,s,c,e);i=u?`${i.slice(0,u[0])}${l}${i.slice(u[1])}`:`${i.slice(0,s+1)}\n ${e}: ${l},${i.slice(s+1)}`}return i}function c(n,r){let i=e.join(n,`vite.config.ts`);return{path:i,content:s(t.existsSync(i)?t.readFileSync(i,`utf-8`):void 0,r)}}function l(e,n,r){let i=c(e,n);return r&&t.writeFileSync(i.path,i.content,`utf-8`),i.path}export{o as findTopLevelValue,a as matchBracket,s as mergeViteConfig,c as renderViteTarget,r as serializeTs,l as writeViteTarget};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as e}from"node:path";import"node:url";import.meta.url;import{logger as t}from"../../../shared/src/logger.js";import{sectionConfig as n}from"../../../shared/src/toolchain.js";import"../../../shared/src/index.js";import{loadToolchainConfig as r}from"../../../core/src/loader.js";import"../../../core/src/index.js";import{hasCatalog as i}from"../catalogs.js";import{tsconfigFileNames as a}from"../../../tsconfig/src/sync.js";import"../../../tsconfig/src/index.js";import{SCAFFOLD_CATALOG as o,createMonorepoRootFiles as s,createRootProjectFiles as c,createWorkspaceFiles as l,findRootOxcFiles as u,upsertWorkspaceTsconfig as d,writeGeneratedFiles as
|
|
1
|
+
import{default as e}from"node:path";import"node:url";import.meta.url;import{logger as t}from"../../../shared/src/logger.js";import{sectionConfig as n}from"../../../shared/src/toolchain.js";import"../../../shared/src/index.js";import{loadToolchainConfig as r}from"../../../core/src/loader.js";import"../../../core/src/index.js";import{hasCatalog as i}from"../catalogs.js";import{tsconfigFileNames as a}from"../../../tsconfig/src/sync.js";import"../../../tsconfig/src/index.js";import{SCAFFOLD_CATALOG as o,createMonorepoRootFiles as s,createRootProjectFiles as c,createWorkspaceFiles as l,findRootOxcFiles as u,upsertWorkspaceTsconfig as d,workspaceDirForTsconfig as f,writeGeneratedFiles as p}from"../typescript.js";import{generateProjectConfigs as m}from"../config.js";const h=[{flags:`--no-config`,description:`Skip the dbx.config.ts file.`},{flags:`--type <type>`,description:`Project type: project | monorepo-root | monorepo-workspace.`},{flags:`--force`,description:`Overwrite existing files in the output directory.`}],g={flags:`--package-manager <pm>`,description:`Package manager: yarn (default) | pnpm | npm | bun.`},_=[`project`,`monorepo-root`,`monorepo-workspace`];function v(e){if(e!=null&&e!==``)return String(e)}function y(e,t={}){let n=v(e.description);return{...t.description!==!1&&n?{description:n}:{},...v(e.author)?{author:v(e.author)}:{},...v(e.license)?{license:v(e.license)}:{},...v(e.homepage)?{homepage:v(e.homepage)}:{},...v(e.repo)?{repo:v(e.repo)}:{},...v(e.nodeVersion)?{nodeVersion:v(e.nodeVersion)}:{}}}function b(e,t){let n=v(t.packageManager),r=e.packageManager??n??`yarn`,i=r===n?v(t.packageManagerVersion)??v(t.yarnVersion):void 0;return{packageManager:r,...i?{packageManagerVersion:i}:{}}}function x(e,t){let n=String(e.name??t.project?.name??``).trim();if(!n)throw Error("a project name is required: pass `--name <name>` or set `project.name` in dbx.config.*.");return n}function S(t,n){return t===`.`?e.basename(e.resolve(n)):t}function C(e,t){let n=e.type??t;if(!_.includes(n))throw Error(`invalid project type "${n}" (expected one of: ${_.join(`, `)}).`);return n}function w(e){return n(e.tsconfig)?.extends}function T(){return[{name:`project:init`,description:`Scaffold a single-package TypeScript project.`,options:[{flags:`-n, --name <name>`,description:`Project name.`},{flags:`-s, --scope <scope>`,description:`npm scope, eg. @acme.`},{flags:`-o, --out <dir>`,description:`Output directory (default: cwd).`},g,...h],run:(e,n)=>{let r=e.out??n.cwd,i=S(x(e,n.config),r),a=w(n.config),o=e.scope??v(n.tokens.scope),s=c({...y(n.tokens),name:i,...o?{scope:o}:{},...b(e,n.tokens),type:C(e,`project`),includeConfig:n.noConfig?!1:e.config??!0,rootOxc:u(r),...a?{tsconfigExtends:a}:{}}),l=p(s,r,{force:!!e.force});for(let e of l)t.info(`Created ${e}`)}},{name:`project:init:monorepo`,description:`Scaffold a monorepo root (add --example for one example workspace).`,options:[{flags:`-n, --name <name>`,description:`Project name.`},{flags:`-s, --scope <scope>`,description:`npm scope, eg. @acme.`},{flags:`-o, --out <dir>`,description:`Output directory (default: cwd).`},{flags:`--example`,description:`Also scaffold one example workspace package.`},g,...h],run:(e,n)=>{let r=e.out??n.cwd,i=S(x(e,n.config),r),a=e.scope??v(n.tokens.scope)??`@${i}`,o=n.noConfig?!1:e.config??!0,c=C(e,`monorepo-root`),u=!!e.example,d=b(e,n.tokens),f=w(n.config),m=s({...y(n.tokens),name:i,scope:a,type:c,includeConfig:o,...d,...f?{tsconfigExtends:f}:{},workspaces:u?[{alias:`core`,dir:`packages/core`}]:[]});u&&m.push(...l({...y(n.tokens,{description:!1}),name:i,scope:a,wsName:`core`,wsDir:`packages/core`,type:`monorepo-workspace`,includeConfig:o,useCatalog:!0,...d,...f?{tsconfigExtends:f}:{}}).map(e=>({...e,path:`packages/core/${e.path}`})));let h=p(m,r,{force:!!e.force});for(let e of h)t.info(`Created ${e}`)}},{name:`project:init:workspace`,description:`Scaffold a monorepo workspace package into an existing monorepo root.`,options:[{flags:`-n, --name <name>`,description:`Workspace package name (unscoped).`},{flags:`-s, --scope <scope>`,description:`npm scope, eg. @acme.`},{flags:`-r, --root <dir>`,description:`Monorepo root (default: cwd).`},{flags:`-d, --dir <dir>`,description:`Workspace dir relative to the root (default: packages/<name>).`},g,...h],run:async(n,s)=>{let c=n.root??s.cwd,{config:u,tokens:m}=e.resolve(c)===e.resolve(s.cwd)?{config:s.config,tokens:s.tokens}:await r(c,{tolerant:!0,skipHooks:!0,...s.noConfig?{noConfig:!0}:{}}),h=String(n.name??``).trim();if(!h)throw Error("a workspace name is required: pass `--name <name>` (the root project name is not the workspace name).");let g=S(h,c),_=v(m.name)??e.basename(e.resolve(c)),x=n.scope??v(m.scope)??`@${_}`,T=(n.dir??`packages/${g}`).replace(/\\/g,`/`).replace(/\/+$/,``);f(T);let E=s.noConfig?!1:n.config??!0,D=C(n,`monorepo-workspace`),O=b(n,m),k=w(u),A=l({...y(m,{description:!1}),name:g,scope:x,wsName:g,wsDir:T,type:D,includeConfig:E,useCatalog:i(c,O.packageManager,Object.keys(o)),...O,...k?{tsconfigExtends:k}:{}}).map(e=>({...e,path:`${T}/${e.path}`})),j=p(A,c,{force:!!n.force});d(c,{alias:g,dir:T},x,a(u).rootFile);for(let e of j)t.info(`Created ${e}`)}},{name:`project:config`,description:`Generate dbx.config.ts for existing projects that are missing one.`,options:[{flags:`--cwd <dir>`,description:`Root to scan (default: cwd).`},{flags:`--include <pattern...>`,description:`Only projects matching these patterns (glob or substring).`},{flags:`--exclude <pattern...>`,description:`Skip projects matching these patterns (glob or substring).`},{flags:`--type <type>`,description:`Force a project type for every config.`},{flags:`--force`,description:`Overwrite configs that already exist.`},{flags:`--dry-run`,description:`Report what would be written without writing.`},{flags:`--json`,description:`Print the result as JSON.`}],run:(n,r)=>{let i=n.cwd??r.cwd,a=m({root:i,...n.include?{include:n.include}:{},...n.exclude?{exclude:n.exclude}:{},...n.type?{type:n.type}:{},force:!!n.force,dryRun:!!n.dryRun});if(n.json){t.raw(JSON.stringify(a,null,4));return}let o=a.dryRun?`would create`:`created`;t.info(`${o} ${a.created.length} config(s), skipped ${a.skipped.length}.`);for(let n of a.configs)n.created&&(t.info(` + ${n.rel===`.`?`dbx.config.ts`:`${n.rel}/dbx.config.ts`} [${n.type}]`),n.vite&&t.info(n.vite.folded?` vite: folded ${e.basename(n.vite.path)} into toolchain.vite (run \`dbx sync\`)`:` vite: left ${e.basename(n.vite.path)} alone (${n.vite.error})`))}}]}export{T as projectCommands};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import __tsdown_shims_path from 'node:path';
|
|
2
2
|
import __tsdown_shims_url from 'node:url';
|
|
3
|
-
import { DEFAULT_PACKAGE_MANAGER_VERSIONS } from "../../shared/src/toolchain.js";
|
|
4
3
|
import { CATALOG_MARKER, CATALOG_PACKAGE_MANAGERS, Catalog, catalogFileFor, catalogsSyncTask, hasCatalog, renderPnpmWorkspace, renderYarnrc, supportsCatalogs } from "./catalogs.js";
|
|
5
4
|
import { projectCommands } from "./cli/index.js";
|
|
6
5
|
import { GENERATED_CONFIG_FILENAME, GenerateProjectConfigsOptions, GenerateProjectConfigsResult, GeneratedProjectConfig, generateProjectConfigs } from "./config.js";
|
|
7
6
|
import { projectSyncTask } from "./sync.js";
|
|
8
|
-
import { MonorepoRootContext, ProjectContext, RootOxcFiles, SCAFFOLD_CATALOG, WorkspaceContext, WriteGeneratedFilesOptions, createMonorepoRootFiles, createRootProjectFiles, createWorkspaceFiles, findRootOxcFiles, renderApplicationEntry, renderApplicationHtml, renderGitignore, renderSourceEntry, renderSourceTest, renderToolchainConfig, renderWorkspaceTsconfig, upsertWorkspaceTsconfig, writeGeneratedFiles } from "./typescript.js";
|
|
7
|
+
import { MonorepoRootContext, ProjectContext, RootOxcFiles, SCAFFOLD_CATALOG, WorkspaceContext, WriteGeneratedFilesOptions, createMonorepoRootFiles, createRootProjectFiles, createWorkspaceFiles, findRootOxcFiles, renderApplicationEntry, renderApplicationHtml, renderGitignore, renderSourceEntry, renderSourceTest, renderToolchainConfig, renderWorkspaceTsconfig, upsertWorkspaceTsconfig, workspaceDirForTsconfig, writeGeneratedFiles } from "./typescript.js";
|
|
8
|
+
import { DEFAULT_PACKAGE_MANAGER_VERSIONS } from "../../shared/src/toolchain.js";
|
|
9
9
|
declare namespace index_d_exports {
|
|
10
|
-
export { CATALOG_MARKER, CATALOG_PACKAGE_MANAGERS, Catalog, DEFAULT_PACKAGE_MANAGER_VERSIONS, GENERATED_CONFIG_FILENAME, GenerateProjectConfigsOptions, GenerateProjectConfigsResult, GeneratedProjectConfig, MonorepoRootContext, ProjectContext, RootOxcFiles, SCAFFOLD_CATALOG, WorkspaceContext, WriteGeneratedFilesOptions, catalogFileFor, catalogsSyncTask, createMonorepoRootFiles, createRootProjectFiles, createWorkspaceFiles, findRootOxcFiles, generateProjectConfigs, hasCatalog, projectCommands, projectSyncTask, renderApplicationEntry, renderApplicationHtml, renderGitignore, renderPnpmWorkspace, renderSourceEntry, renderSourceTest, renderToolchainConfig, renderWorkspaceTsconfig, renderYarnrc, supportsCatalogs, upsertWorkspaceTsconfig, writeGeneratedFiles };
|
|
10
|
+
export { CATALOG_MARKER, CATALOG_PACKAGE_MANAGERS, Catalog, DEFAULT_PACKAGE_MANAGER_VERSIONS, GENERATED_CONFIG_FILENAME, GenerateProjectConfigsOptions, GenerateProjectConfigsResult, GeneratedProjectConfig, MonorepoRootContext, ProjectContext, RootOxcFiles, SCAFFOLD_CATALOG, WorkspaceContext, WriteGeneratedFilesOptions, catalogFileFor, catalogsSyncTask, createMonorepoRootFiles, createRootProjectFiles, createWorkspaceFiles, findRootOxcFiles, generateProjectConfigs, hasCatalog, projectCommands, projectSyncTask, renderApplicationEntry, renderApplicationHtml, renderGitignore, renderPnpmWorkspace, renderSourceEntry, renderSourceTest, renderToolchainConfig, renderWorkspaceTsconfig, renderYarnrc, supportsCatalogs, upsertWorkspaceTsconfig, workspaceDirForTsconfig, writeGeneratedFiles };
|
|
11
11
|
}
|
|
12
12
|
//#endregion
|
|
13
|
-
export { CATALOG_MARKER, CATALOG_PACKAGE_MANAGERS, Catalog, DEFAULT_PACKAGE_MANAGER_VERSIONS, GENERATED_CONFIG_FILENAME, GenerateProjectConfigsOptions, GenerateProjectConfigsResult, GeneratedProjectConfig, MonorepoRootContext, ProjectContext, RootOxcFiles, SCAFFOLD_CATALOG, WorkspaceContext, WriteGeneratedFilesOptions, catalogFileFor, catalogsSyncTask, createMonorepoRootFiles, createRootProjectFiles, createWorkspaceFiles, findRootOxcFiles, generateProjectConfigs, hasCatalog, index_d_exports, projectCommands, projectSyncTask, renderApplicationEntry, renderApplicationHtml, renderGitignore, renderPnpmWorkspace, renderSourceEntry, renderSourceTest, renderToolchainConfig, renderWorkspaceTsconfig, renderYarnrc, supportsCatalogs, upsertWorkspaceTsconfig, writeGeneratedFiles };
|
|
13
|
+
export { CATALOG_MARKER, CATALOG_PACKAGE_MANAGERS, Catalog, DEFAULT_PACKAGE_MANAGER_VERSIONS, GENERATED_CONFIG_FILENAME, GenerateProjectConfigsOptions, GenerateProjectConfigsResult, GeneratedProjectConfig, MonorepoRootContext, ProjectContext, RootOxcFiles, SCAFFOLD_CATALOG, WorkspaceContext, WriteGeneratedFilesOptions, catalogFileFor, catalogsSyncTask, createMonorepoRootFiles, createRootProjectFiles, createWorkspaceFiles, findRootOxcFiles, generateProjectConfigs, hasCatalog, index_d_exports, projectCommands, projectSyncTask, renderApplicationEntry, renderApplicationHtml, renderGitignore, renderPnpmWorkspace, renderSourceEntry, renderSourceTest, renderToolchainConfig, renderWorkspaceTsconfig, renderYarnrc, supportsCatalogs, upsertWorkspaceTsconfig, workspaceDirForTsconfig, writeGeneratedFiles };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"node:path";import"node:url";import.meta.url;import{__exportAll as e}from"../../../_virtual/_rolldown/runtime.js";import{DEFAULT_PACKAGE_MANAGER_VERSIONS as t}from"../../shared/src/toolchain.js";import{CATALOG_MARKER as n,CATALOG_PACKAGE_MANAGERS as r,catalogFileFor as i,catalogsSyncTask as a,hasCatalog as o,renderPnpmWorkspace as s,renderYarnrc as c,supportsCatalogs as l}from"./catalogs.js";import{SCAFFOLD_CATALOG as u,createMonorepoRootFiles as d,createRootProjectFiles as f,createWorkspaceFiles as p,findRootOxcFiles as m,renderApplicationEntry as h,renderApplicationHtml as g,renderGitignore as _,renderSourceEntry as v,renderSourceTest as y,renderToolchainConfig as b,renderWorkspaceTsconfig as x,upsertWorkspaceTsconfig as S,writeGeneratedFiles as
|
|
1
|
+
import"node:path";import"node:url";import.meta.url;import{__exportAll as e}from"../../../_virtual/_rolldown/runtime.js";import{DEFAULT_PACKAGE_MANAGER_VERSIONS as t}from"../../shared/src/toolchain.js";import{CATALOG_MARKER as n,CATALOG_PACKAGE_MANAGERS as r,catalogFileFor as i,catalogsSyncTask as a,hasCatalog as o,renderPnpmWorkspace as s,renderYarnrc as c,supportsCatalogs as l}from"./catalogs.js";import{SCAFFOLD_CATALOG as u,createMonorepoRootFiles as d,createRootProjectFiles as f,createWorkspaceFiles as p,findRootOxcFiles as m,renderApplicationEntry as h,renderApplicationHtml as g,renderGitignore as _,renderSourceEntry as v,renderSourceTest as y,renderToolchainConfig as b,renderWorkspaceTsconfig as x,upsertWorkspaceTsconfig as S,workspaceDirForTsconfig as C,writeGeneratedFiles as w}from"./typescript.js";import{GENERATED_CONFIG_FILENAME as T,generateProjectConfigs as E}from"./config.js";import{projectCommands as D}from"./cli/index.js";import{projectSyncTask as O}from"./sync.js";var k=/* @__PURE__ */ e({CATALOG_MARKER:()=>n,CATALOG_PACKAGE_MANAGERS:()=>r,DEFAULT_PACKAGE_MANAGER_VERSIONS:()=>t,GENERATED_CONFIG_FILENAME:()=>T,SCAFFOLD_CATALOG:()=>u,catalogFileFor:()=>i,catalogsSyncTask:()=>a,createMonorepoRootFiles:()=>d,createRootProjectFiles:()=>f,createWorkspaceFiles:()=>p,findRootOxcFiles:()=>m,generateProjectConfigs:()=>E,hasCatalog:()=>o,projectCommands:()=>D,projectSyncTask:()=>O,renderApplicationEntry:()=>h,renderApplicationHtml:()=>g,renderGitignore:()=>_,renderPnpmWorkspace:()=>s,renderSourceEntry:()=>v,renderSourceTest:()=>y,renderToolchainConfig:()=>b,renderWorkspaceTsconfig:()=>x,renderYarnrc:()=>c,supportsCatalogs:()=>l,upsertWorkspaceTsconfig:()=>S,workspaceDirForTsconfig:()=>C,writeGeneratedFiles:()=>w});export{n as CATALOG_MARKER,r as CATALOG_PACKAGE_MANAGERS,t as DEFAULT_PACKAGE_MANAGER_VERSIONS,T as GENERATED_CONFIG_FILENAME,u as SCAFFOLD_CATALOG,i as catalogFileFor,a as catalogsSyncTask,d as createMonorepoRootFiles,f as createRootProjectFiles,p as createWorkspaceFiles,m as findRootOxcFiles,E as generateProjectConfigs,o as hasCatalog,D as projectCommands,O as projectSyncTask,h as renderApplicationEntry,g as renderApplicationHtml,_ as renderGitignore,s as renderPnpmWorkspace,v as renderSourceEntry,y as renderSourceTest,b as renderToolchainConfig,x as renderWorkspaceTsconfig,c as renderYarnrc,k as src_exports,l as supportsCatalogs,S as upsertWorkspaceTsconfig,C as workspaceDirForTsconfig,w as writeGeneratedFiles};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import __tsdown_shims_path from 'node:path';
|
|
2
2
|
import __tsdown_shims_url from 'node:url';
|
|
3
3
|
import { ProjectType } from "../../shared/src/config-types.js";
|
|
4
|
+
import { MonorepoWorkspace, TsconfigExtendsOptions } from "../../tsconfig/src/templates.js";
|
|
5
|
+
import "../../tsconfig/src/index.js";
|
|
4
6
|
import { DEFAULT_PACKAGE_MANAGER_VERSIONS } from "../../shared/src/toolchain.js";
|
|
5
7
|
import { GeneratedFile } from "../../shared/src/types.js";
|
|
6
8
|
import "../../shared/src/index.js";
|
|
7
|
-
import { MonorepoWorkspace, TsconfigExtendsOptions } from "../../tsconfig/src/templates.js";
|
|
8
|
-
import "../../tsconfig/src/index.js";
|
|
9
9
|
//#region packages/project/src/typescript.d.ts
|
|
10
10
|
/** The catalog a scaffolded root writes into its package-manager file. */
|
|
11
11
|
export declare const SCAFFOLD_CATALOG: Record<string, string>;
|
|
@@ -92,6 +92,8 @@ export interface MonorepoRootContext extends ProjectContext {
|
|
|
92
92
|
}
|
|
93
93
|
/** Files for a monorepo root (workspaces + monorepo tsconfig). */
|
|
94
94
|
export declare function createMonorepoRootFiles(ctx: MonorepoRootContext): GeneratedFile[];
|
|
95
|
+
/** Normalize + validate a workspace directory (relative, inside the root). */
|
|
96
|
+
export declare function workspaceDirForTsconfig(dir: string): string;
|
|
95
97
|
/**
|
|
96
98
|
* Add (or refresh) a workspace in a monorepo root's workspaces tsconfig.
|
|
97
99
|
* Keeps the existing file (including comments and formatting) and just upserts
|
|
@@ -11,7 +11,7 @@ ${[` project: {\n${o}\n },`,...s?[` fmt: { oxc: true },`]:[
|
|
|
11
11
|
`)}
|
|
12
12
|
},
|
|
13
13
|
});
|
|
14
|
-
`}function R(e=!1,t=`./tsconfig.default.json`){return D({...t===!1?{}:{extends:t},compilerOptions:{composite:e}})}function z(e){let t=e.kind===`application`,n=e.oxc!==!1&&e.includeConfig!==!1,a=n&&e.rootOxc?.fmt!==!0,o=n&&e.rootOxc?.lint!==!0,s={name:e.scope?`${e.scope}/${e.name}`:e.name,version:`0.1.0`,private:!0,type:`module`,...E(e),scripts:t?{dev:`vite`,build:`vite build`,preview:`vite preview`,format:`dbx fmt`,lint:`dbx lint --fix`,test:`vitest run`,typecheck:`tsc -p tsconfig.json --noEmit`}:{build:`tsdown`,format:`dbx fmt`,lint:`dbx lint --fix`,test:`vitest run`,typecheck:`tsc -p tsconfig.json --noEmit`},devDependencies:b(e.packageManager,x(e.packageManager,!1),t?[`tsdown`]:[]),...y(e.packageManager,e.packageManagerVersion??e.yarnVersion)?{packageManager:y(e.packageManager,e.packageManagerVersion??e.yarnVersion)}:{},engines:{node:e.nodeVersion?`>=${e.nodeVersion}`:`>=22`}};return[...e.includeConfig===!1?[]:[{path:`dbx.config.ts`,content:L({...e,type:e.type??`project`,fmtOxc:a,lintOxc:o})}],{path:`package.json`,content:D(s)},...t?[{path:`index.html`,content:F(e.name)},{path:`src/main.ts`,content:P()}]:[],{path:`src/index.ts`,content:N()},{path:`tests/index.test.ts`,content:I()},{path:`tsconfig.base.json`,content:u(T(e),e.tsconfigExtends?.base)},{path:`tsconfig.default.json`,content:f(T(e),e.tsconfigExtends?.default)},{path:`tsconfig.build.json`,content:d(T(e),e.tsconfigExtends?.build)},{path:`tsconfig.json`,content:R()},...a?[{path:`.oxfmtrc.json`,content:M(A,r)}]:[],...o?[{path:`.oxlintrc.json`,content:M(j,i)}]:[],{path:`.gitignore`,content:G()},{path:`README.md`,content:`# ${e.name}\n`},...S(e.packageManager,!1,t?[`tsdown`]:[])]}function B(e){let t=e.oxc!==!1&&e.includeConfig!==!1,n={name:e.name,version:`0.1.0`,private:!0,type:`module`,...E(e),scripts:{build:`dbx run --filter "./packages/*" build`,test:`dbx run --filter "./packages/*" test`,typecheck:`dbx run --filter "./packages/*" typecheck`,format:`dbx fmt`,lint:`dbx lint --fix`},workspaces:C(e.packageManager,e.workspaceGlobs??[`packages/*`]),devDependencies:b(e.packageManager,x(e.packageManager,!0)),...y(e.packageManager,e.packageManagerVersion??e.yarnVersion)?{packageManager:y(e.packageManager,e.packageManagerVersion??e.yarnVersion)}:{},engines:{node:e.nodeVersion?`>=${e.nodeVersion}`:`>=22`}};return[...e.includeConfig===!1?[]:[{path:`dbx.config.ts`,content:L({...e,type:e.type??`monorepo-root`,oxc:t})}],{path:`package.json`,content:D(n)},{path:`tsconfig.base.json`,content:u(T(e),e.tsconfigExtends?.base)},{path:`tsconfig.workspaces.json`,content:l({scope:e.scope??e.name,workspaces:e.workspaces})},{path:`tsconfig.json`,content:D({extends:`./tsconfig.workspaces.json`,compilerOptions:{composite:!1},files:[]})},...t?[{path:`.oxfmtrc.json`,content:M(A,r)},{path:`.oxlintrc.json`,content:M(j,i)}]:[],{path:`.gitignore`,content:G()},{path:`README.md`,content:`# ${e.name}\n`},...S(e.packageManager,!0)]}function V(t){let n=t.replace(/\\/g,`/`).replace(/^\.?\//,``).replace(/\/+$/,``);if(!n||e.isAbsolute(t)||/^[a-zA-Z]:/.test(t)||n.split(`/`).includes(`..`))throw Error(`invalid workspace directory "${t}" (must be relative to the root).`);return n}function H(e){let t=e.match(/^([ \t]+)\S/m)?.[1]??` `,n=!t.includes(` `);return{insertSpaces:n,tabSize:n?t.length:1}}function U(t,n,r,i=`tsconfig.workspaces.json`){let a=V(n.dir),o=e.resolve(t,i);if(!m.existsSync(o))return!1;let s=m.readFileSync(o,`utf-8`),l;try{l=c(s)}catch{return!1}let u=Array.isArray(l.references)?l.references:void 0,d=l.compilerOptions&&typeof l.compilerOptions==`object`?l.compilerOptions:{},f=/* @__PURE__ */ new Set,p=/* @__PURE__ */ new Map;if(r){let e=d.paths&&typeof d.paths==`object`?d.paths:{};for(let t of[`${r}/${n.alias}`,`${r}/${n.alias}/*`]){let n=e[t],r=Array.isArray(n)?n[0]:void 0,i=typeof r==`string`?r.match(/^\.\/(.+)\/src\/(?:index\.ts|\*)$/):void 0;i?.[1]&&f.add(i[1]);let o=[t.endsWith(`/*`)?`./${a}/src/*`:`./${a}/src/index.ts`];e[t]=o,p.set(t,o)}d.paths=e}l.compilerOptions=d;let _=`./${a}/tsconfig.json`,v=new Set([...f].filter(e=>e!==a).map(e=>`./${e}/tsconfig.json`)),y=(Array.isArray(l.references)?l.references:[]).filter(e=>!v.has(e.path));y.some(e=>e.path===_)||y.push({path:_}),l.references=y;try{let e=H(s),t=s;for(let[n,r]of p)t=h(t,g(t,[`compilerOptions`,`paths`,n],r,{formattingOptions:e}));let n=u??[],r=n.findIndex(e=>e.path===_),i=n.map((e,t)=>typeof e.path==`string`&&v.has(e.path)?t:-1).filter(e=>e>=0);if(i.length>0){r===-1&&(t=h(t,g(t,[`references`,i[0],`path`],_,{formattingOptions:e})));for(let n of i.filter((e,t)=>r!==-1||t>0).sort((e,t)=>t-e))t=h(t,g(t,[`references`,n],void 0,{formattingOptions:e}))}else r===-1&&(t=u===void 0?h(t,g(t,[`references`],[{path:_}],{formattingOptions:e})):h(t,g(t,[`references`,n.length],{path:_},{formattingOptions:e})));m.writeFileSync(o,t,`utf-8`)}catch{m.writeFileSync(o,`${JSON.stringify(l,null,4)}\n`,`utf-8`)}return!0}function W(e){let t=e.useCatalog===!0&&x(e.packageManager,!0)?b(e.packageManager,!0):{..._},n={name:e.scope?`${e.scope}/${e.wsName}`:e.wsName,version:`0.1.0`,type:`module`,...E(e),main:`./dist/index.js`,module:`./dist/index.js`,types:`./dist/index.d.ts`,exports:{".":{types:`./dist/index.d.ts`,import:`./dist/index.js`},"./package.json":`./package.json`},sideEffects:!1,files:[`dist`],scripts:{build:`tsdown`,format:`dbx fmt`,lint:`dbx lint --fix`,test:`vitest run`,typecheck:`tsc -p tsconfig.build.json --noEmit`},devDependencies:t,...e.nodeVersion?{engines:{node:`>=${e.nodeVersion}`}}:{},publishConfig:{access:`public`,provenance:!0}},r=e.wsDir.split(`/`).length;return[...e.includeConfig===!1?[]:[{path:`dbx.config.ts`,content:L({...e,name:e.wsName,type:e.type??`monorepo-workspace`})}],{path:`package.json`,content:D(n)},{path:`src/index.ts`,content:N()},{path:`tests/index.test.ts`,content:I()},{path:`tsconfig.default.json`,content:D({...e.tsconfigExtends?.default===!1?{}:{extends:e.tsconfigExtends?.default??`${`../`.repeat(r)}tsconfig.base.json`},compilerOptions:{module:`NodeNext`,moduleResolution:`NodeNext`,types:[`node`]},include:[`src`,`tests`,`tsdown.config.ts`,`vitest.config.ts`]})},{path:`tsconfig.build.json`,content:R(!1,e.tsconfigExtends?.build)},{path:`tsconfig.json`,content:R()},{path:`tsdown.config.ts`,content:`import { defineConfig } from 'tsdown';
|
|
14
|
+
`}function R(e=!1,t=`./tsconfig.default.json`){return D({...t===!1?{}:{extends:t},compilerOptions:{composite:e}})}function z(e){let t=e.kind===`application`,n=e.oxc!==!1&&e.includeConfig!==!1,a=n&&e.rootOxc?.fmt!==!0,o=n&&e.rootOxc?.lint!==!0,s={name:e.scope?`${e.scope}/${e.name}`:e.name,version:`0.1.0`,private:!0,type:`module`,...E(e),scripts:t?{dev:`vite`,build:`vite build`,preview:`vite preview`,format:`dbx fmt`,lint:`dbx lint --fix`,test:`vitest run`,typecheck:`tsc -p tsconfig.json --noEmit`}:{build:`tsdown`,format:`dbx fmt`,lint:`dbx lint --fix`,test:`vitest run`,typecheck:`tsc -p tsconfig.json --noEmit`},devDependencies:b(e.packageManager,x(e.packageManager,!1),t?[`tsdown`]:[]),...y(e.packageManager,e.packageManagerVersion??e.yarnVersion)?{packageManager:y(e.packageManager,e.packageManagerVersion??e.yarnVersion)}:{},engines:{node:e.nodeVersion?`>=${e.nodeVersion}`:`>=22`}};return[...e.includeConfig===!1?[]:[{path:`dbx.config.ts`,content:L({...e,type:e.type??`project`,fmtOxc:a,lintOxc:o})}],{path:`package.json`,content:D(s)},...t?[{path:`index.html`,content:F(e.name)},{path:`src/main.ts`,content:P()}]:[],{path:`src/index.ts`,content:N()},{path:`tests/index.test.ts`,content:I()},{path:`tsconfig.base.json`,content:u(T(e),e.tsconfigExtends?.base)},{path:`tsconfig.default.json`,content:f(T(e),e.tsconfigExtends?.default)},{path:`tsconfig.build.json`,content:d(T(e),e.tsconfigExtends?.build)},{path:`tsconfig.json`,content:R()},...a?[{path:`.oxfmtrc.json`,content:M(A,r)}]:[],...o?[{path:`.oxlintrc.json`,content:M(j,i)}]:[],{path:`.gitignore`,content:G()},{path:`README.md`,content:`# ${e.name}\n`},...S(e.packageManager,!1,t?[`tsdown`]:[])]}function B(e){let t=e.oxc!==!1&&e.includeConfig!==!1,n={name:e.name,version:`0.1.0`,private:!0,type:`module`,...E(e),scripts:{build:`dbx run --filter "./packages/*" build`,test:`dbx run --filter "./packages/*" test`,typecheck:`dbx run --filter "./packages/*" typecheck`,format:`dbx fmt`,lint:`dbx lint --fix`},workspaces:C(e.packageManager,e.workspaceGlobs??[`packages/*`]),devDependencies:b(e.packageManager,x(e.packageManager,!0)),...y(e.packageManager,e.packageManagerVersion??e.yarnVersion)?{packageManager:y(e.packageManager,e.packageManagerVersion??e.yarnVersion)}:{},engines:{node:e.nodeVersion?`>=${e.nodeVersion}`:`>=22`}};return[...e.includeConfig===!1?[]:[{path:`dbx.config.ts`,content:L({...e,type:e.type??`monorepo-root`,oxc:t})}],{path:`package.json`,content:D(n)},{path:`tsconfig.base.json`,content:u(T(e),e.tsconfigExtends?.base)},{path:`tsconfig.workspaces.json`,content:l({scope:e.scope??e.name,workspaces:e.workspaces})},{path:`tsconfig.json`,content:D({extends:`./tsconfig.workspaces.json`,compilerOptions:{composite:!1},files:[]})},...t?[{path:`.oxfmtrc.json`,content:M(A,r)},{path:`.oxlintrc.json`,content:M(j,i)}]:[],{path:`.gitignore`,content:G()},{path:`README.md`,content:`# ${e.name}\n`},...S(e.packageManager,!0)]}function V(t){let n=t.replace(/\\/g,`/`).replace(/^\.?\//,``).replace(/\/+$/,``);if(!n||n===`.`||e.isAbsolute(t)||/^[a-zA-Z]:/.test(t)||n.split(`/`).includes(`..`))throw Error(`invalid workspace directory "${t}" (must be relative to the root).`);return n}function H(e){let t=e.match(/^([ \t]+)\S/m)?.[1]??` `,n=!t.includes(` `);return{insertSpaces:n,tabSize:n?t.length:1}}function U(t,n,r,i=`tsconfig.workspaces.json`){let a=V(n.dir),o=e.resolve(t,i);if(!m.existsSync(o))return!1;let s=m.readFileSync(o,`utf-8`),l;try{l=c(s)}catch{return!1}let u=Array.isArray(l.references)?l.references:void 0,d=l.compilerOptions&&typeof l.compilerOptions==`object`?l.compilerOptions:{},f=/* @__PURE__ */ new Set,p=/* @__PURE__ */ new Map;if(r){let e=d.paths&&typeof d.paths==`object`?d.paths:{};for(let t of[`${r}/${n.alias}`,`${r}/${n.alias}/*`]){let n=e[t],r=Array.isArray(n)?n[0]:void 0,i=typeof r==`string`?r.match(/^\.\/(.+)\/src\/(?:index\.ts|\*)$/):void 0;i?.[1]&&f.add(i[1]);let o=[t.endsWith(`/*`)?`./${a}/src/*`:`./${a}/src/index.ts`];e[t]=o,p.set(t,o)}d.paths=e}l.compilerOptions=d;let _=`./${a}/tsconfig.json`,v=new Set([...f].filter(e=>e!==a).map(e=>`./${e}/tsconfig.json`)),y=(Array.isArray(l.references)?l.references:[]).filter(e=>!v.has(e.path));y.some(e=>e.path===_)||y.push({path:_}),l.references=y;try{let e=H(s),t=s;for(let[n,r]of p)t=h(t,g(t,[`compilerOptions`,`paths`,n],r,{formattingOptions:e}));let n=u??[],r=n.findIndex(e=>e.path===_),i=n.map((e,t)=>typeof e.path==`string`&&v.has(e.path)?t:-1).filter(e=>e>=0);if(i.length>0){r===-1&&(t=h(t,g(t,[`references`,i[0],`path`],_,{formattingOptions:e})));for(let n of i.filter((e,t)=>r!==-1||t>0).sort((e,t)=>t-e))t=h(t,g(t,[`references`,n],void 0,{formattingOptions:e}))}else r===-1&&(t=u===void 0?h(t,g(t,[`references`],[{path:_}],{formattingOptions:e})):h(t,g(t,[`references`,n.length],{path:_},{formattingOptions:e})));m.writeFileSync(o,t,`utf-8`)}catch{m.writeFileSync(o,`${JSON.stringify(l,null,4)}\n`,`utf-8`)}return!0}function W(e){let t=e.useCatalog===!0&&x(e.packageManager,!0)?b(e.packageManager,!0):{..._},n={name:e.scope?`${e.scope}/${e.wsName}`:e.wsName,version:`0.1.0`,type:`module`,...E(e),main:`./dist/index.js`,module:`./dist/index.js`,types:`./dist/index.d.ts`,exports:{".":{types:`./dist/index.d.ts`,import:`./dist/index.js`},"./package.json":`./package.json`},sideEffects:!1,files:[`dist`],scripts:{build:`tsdown`,format:`dbx fmt`,lint:`dbx lint --fix`,test:`vitest run`,typecheck:`tsc -p tsconfig.build.json --noEmit`},devDependencies:t,...e.nodeVersion?{engines:{node:`>=${e.nodeVersion}`}}:{},publishConfig:{access:`public`,provenance:!0}},r=e.wsDir.split(`/`).length;return[...e.includeConfig===!1?[]:[{path:`dbx.config.ts`,content:L({...e,name:e.wsName,type:e.type??`monorepo-workspace`})}],{path:`package.json`,content:D(n)},{path:`src/index.ts`,content:N()},{path:`tests/index.test.ts`,content:I()},{path:`tsconfig.default.json`,content:D({...e.tsconfigExtends?.default===!1?{}:{extends:e.tsconfigExtends?.default??`${`../`.repeat(r)}tsconfig.base.json`},compilerOptions:{module:`NodeNext`,moduleResolution:`NodeNext`,types:[`node`]},include:[`src`,`tests`,`tsdown.config.ts`,`vitest.config.ts`]})},{path:`tsconfig.build.json`,content:R(!1,e.tsconfigExtends?.build)},{path:`tsconfig.json`,content:R()},{path:`tsdown.config.ts`,content:`import { defineConfig } from 'tsdown';
|
|
15
15
|
|
|
16
16
|
import { baseTsdownConfig } from '@deltabox/toolchain/tsdown';
|
|
17
17
|
|
|
@@ -22,4 +22,4 @@ export default defineConfig({
|
|
|
22
22
|
exports: false,
|
|
23
23
|
});
|
|
24
24
|
`}]}function G(){return(/* @__PURE__ */ `node_modules/,dist/,coverage/,.vite/,*.tsbuildinfo,,.env,.env.*,!.env.example,!.env.example.*,,.DS_Store,,# Toolchain state; only the manifest is committed,.dbx/toolchain/*,!.dbx/toolchain/manifest.json,,# Yarn 4,.pnp.*,.yarn/*,!.yarn/patches,!.yarn/plugins,!.yarn/releases,!.yarn/sdks,!.yarn/versions,`.split(`,`)).join(`
|
|
25
|
-
`)}function K(t,n){let r=process.platform===`win32`?t.toLowerCase():t,i=process.platform===`win32`?n.toLowerCase():n;return i===r||i.startsWith(`${r}${e.sep}`)}function q(t,n=process.cwd(),r={}){let i=e.resolve(n),a=t.map(t=>e.resolve(i,t.path)),o=/* @__PURE__ */ new Map;for(let t of a){if(!K(i,t))throw Error(`refusing to write outside ${i}: ${t}`);let n=process.platform===`win32`?t.toLowerCase():t,r=o.get(n);if(r!==void 0)throw Error(`refusing to write duplicate file(s): ${r} and ${e.relative(i,t)}`);o.set(n,e.relative(i,t))}if(r.force!==!0){let t=a.filter(e=>m.existsSync(e));if(t.length>0)throw Error(`refusing to overwrite existing file(s): ${t.map(t=>e.relative(i,t)).join(`, `)} (use --force to overwrite).`)}let s=[];for(let[n,r]of a.entries())m.mkdirSync(e.dirname(r),{recursive:!0}),m.writeFileSync(r,t[n].content,`utf-8`),s.push(r);return s}export{n as DEFAULT_PACKAGE_MANAGER_VERSIONS,v as SCAFFOLD_CATALOG,B as createMonorepoRootFiles,z as createRootProjectFiles,W as createWorkspaceFiles,w as findRootOxcFiles,P as renderApplicationEntry,F as renderApplicationHtml,G as renderGitignore,N as renderSourceEntry,I as renderSourceTest,L as renderToolchainConfig,R as renderWorkspaceTsconfig,U as upsertWorkspaceTsconfig,q as writeGeneratedFiles};
|
|
25
|
+
`)}function K(t,n){let r=process.platform===`win32`?t.toLowerCase():t,i=process.platform===`win32`?n.toLowerCase():n;return i===r||i.startsWith(`${r}${e.sep}`)}function q(t,n=process.cwd(),r={}){let i=e.resolve(n),a=t.map(t=>e.resolve(i,t.path)),o=/* @__PURE__ */ new Map;for(let t of a){if(!K(i,t))throw Error(`refusing to write outside ${i}: ${t}`);let n=process.platform===`win32`?t.toLowerCase():t,r=o.get(n);if(r!==void 0)throw Error(`refusing to write duplicate file(s): ${r} and ${e.relative(i,t)}`);o.set(n,e.relative(i,t))}if(r.force!==!0){let t=a.filter(e=>m.existsSync(e));if(t.length>0)throw Error(`refusing to overwrite existing file(s): ${t.map(t=>e.relative(i,t)).join(`, `)} (use --force to overwrite).`)}let s=[];for(let[n,r]of a.entries())m.mkdirSync(e.dirname(r),{recursive:!0}),m.writeFileSync(r,t[n].content,`utf-8`),s.push(r);return s}export{n as DEFAULT_PACKAGE_MANAGER_VERSIONS,v as SCAFFOLD_CATALOG,B as createMonorepoRootFiles,z as createRootProjectFiles,W as createWorkspaceFiles,w as findRootOxcFiles,P as renderApplicationEntry,F as renderApplicationHtml,G as renderGitignore,N as renderSourceEntry,I as renderSourceTest,L as renderToolchainConfig,R as renderWorkspaceTsconfig,U as upsertWorkspaceTsconfig,V as workspaceDirForTsconfig,q as writeGeneratedFiles};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { ChangelogBreakingSetting } from "./changelog-breaking.js";
|
|
4
|
+
import { Logger } from "./logger.js";
|
|
5
|
+
//#region packages/shared/src/changelog-callbacks.d.ts
|
|
6
|
+
/** The subset of a commit exposed to changelog callbacks. */
|
|
7
|
+
export interface ChangelogCommitRecord {
|
|
8
|
+
hash: string;
|
|
9
|
+
subject: string;
|
|
10
|
+
body: string;
|
|
11
|
+
author: string;
|
|
12
|
+
authorEmail: string;
|
|
13
|
+
}
|
|
14
|
+
/** A resolved commit author. */
|
|
15
|
+
export interface ChangelogAuthorInfo {
|
|
16
|
+
name: string;
|
|
17
|
+
url?: string;
|
|
18
|
+
}
|
|
19
|
+
/** A resolved issue reference. */
|
|
20
|
+
export interface ChangelogIssueInfo {
|
|
21
|
+
number: number;
|
|
22
|
+
title?: string;
|
|
23
|
+
url?: string;
|
|
24
|
+
}
|
|
25
|
+
/** Options for rendering a commit bullet/credit line. */
|
|
26
|
+
export interface ChangelogCommitFormatOptions {
|
|
27
|
+
/** Include the `by <author>` credit (default true). */
|
|
28
|
+
author?: boolean;
|
|
29
|
+
/** Include the commit hash link (default true). */
|
|
30
|
+
commitSha?: boolean;
|
|
31
|
+
/** Include issue/fixes links (default true). */
|
|
32
|
+
issues?: boolean;
|
|
33
|
+
/** Prefix the author with their GitHub avatar (default false). */
|
|
34
|
+
authorAvatar?: boolean;
|
|
35
|
+
/** Fully custom commit line formatter (TS/JS configs only). */
|
|
36
|
+
format?: (ctx: ChangelogCommitFormatContext) => string;
|
|
37
|
+
}
|
|
38
|
+
/** The context handed to a custom commit line formatter. */
|
|
39
|
+
export interface ChangelogCommitFormatContext {
|
|
40
|
+
commit: ChangelogCommitRecord;
|
|
41
|
+
repo?: string;
|
|
42
|
+
author: ChangelogAuthorInfo;
|
|
43
|
+
issues: ChangelogIssueInfo[];
|
|
44
|
+
options: ChangelogCommitFormatOptions;
|
|
45
|
+
}
|
|
46
|
+
/** The context handed to a custom changelog provider. */
|
|
47
|
+
export interface ChangelogProviderContext {
|
|
48
|
+
cwd: string;
|
|
49
|
+
changelog?: unknown;
|
|
50
|
+
records: ChangelogCommitRecord[];
|
|
51
|
+
}
|
|
52
|
+
/** A custom changelog provider. */
|
|
53
|
+
export interface ChangelogProvider {
|
|
54
|
+
id: string;
|
|
55
|
+
run: (ctx: ChangelogProviderContext) => string | void;
|
|
56
|
+
}
|
|
57
|
+
/** A built-in provider id, a custom provider, or a provider callback. */
|
|
58
|
+
export type ChangelogProviderSetting = 'default' | 'changesets' | (string & {}) | ChangelogProvider | ((ctx: ChangelogProviderContext) => string | void);
|
|
59
|
+
/** The context handed to custom bump-rule callbacks. */
|
|
60
|
+
export interface ChangelogBumpRuleContext {
|
|
61
|
+
env: NodeJS.ProcessEnv;
|
|
62
|
+
logger: Logger;
|
|
63
|
+
packageJson?: Record<string, unknown>;
|
|
64
|
+
/** How breaking changes are detected (default: Conventional Commits). */
|
|
65
|
+
breaking?: ChangelogBreakingSetting;
|
|
66
|
+
}
|
|
67
|
+
/** The full context handed to a custom bump-rule callback. */
|
|
68
|
+
export interface ChangelogBumpRuleCallbackContext extends ChangelogBumpRuleContext {
|
|
69
|
+
commit: ChangelogCommitRecord;
|
|
70
|
+
level: 'major' | 'minor' | 'patch';
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
@@ -2,9 +2,16 @@ import __tsdown_shims_path from 'node:path';
|
|
|
2
2
|
import __tsdown_shims_url from 'node:url';
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
//#region packages/shared/src/config-schema/biome.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Biome's configuration options. The concrete type lives in the generated
|
|
7
|
+
* `biome-config.ts`, produced from Biome's official JSON schema
|
|
8
|
+
* (`schemas/biome.json`, vendored from
|
|
9
|
+
* `https://biomejs.dev/schemas/2.5.13/schema.json`).
|
|
10
|
+
*/
|
|
11
|
+
export declare const biomeConfigOptionsSchema: z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>;
|
|
5
12
|
/** Biome config generation (for consumers that still want a `biome.json`). */
|
|
6
13
|
export declare const biomeConfigSchema: z.ZodObject<{
|
|
7
14
|
vscode: z.ZodOptional<z.ZodBoolean>;
|
|
8
|
-
overrides: z.ZodOptional<z.
|
|
15
|
+
overrides: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
|
|
9
16
|
}, z.core.$strip>;
|
|
10
17
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"node:path";import"node:url";import.meta.url;import{
|
|
1
|
+
import"node:path";import"node:url";import.meta.url;import{externalConfigSchema as e}from"./external.js";import{withEnabled as t}from"./meta.js";import{z as n}from"zod";const r=e(`Biome configuration options.`,`BiomeConfig`),i=t(n.object({vscode:n.boolean().describe(`Write the Biome VS Code settings (default true).`).optional(),overrides:r.describe("Deep-merged over the generated `biome.json` (arrays union).").optional()})).describe("Biome config generation (for consumers that still want a `biome.json`).").meta({id:`ToolchainBiomeConfig`,deprecated:!0,deprecationMessage:"use `toolchain.fmt.biome` / `toolchain.lint.biome`. Still writes `biome.json`."});export{r as biomeConfigOptionsSchema,i as biomeConfigSchema};
|