create-atom.io 0.0.6 → 0.0.7
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/{create-atom-C0gh5ath.js → create-atom-Bs3iurKr.js} +7 -4
- package/dist/create-atom-Bs3iurKr.js.map +1 -0
- package/dist/create-atom.d.ts.map +1 -1
- package/dist/create-atom.js +1 -1
- package/dist/create-atom.x.js +1 -1
- package/package.json +5 -4
- package/src/create-atom.ts +6 -9
- package/dist/create-atom-C0gh5ath.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, promises } from "node:fs";
|
|
2
|
-
import {
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
2
|
+
import { resolve } from "node:path";
|
|
4
3
|
import * as prompts from "@clack/prompts";
|
|
4
|
+
import { getPackageInfo } from "local-pkg";
|
|
5
5
|
import picocolors from "picocolors";
|
|
6
6
|
import { x } from "tinyexec";
|
|
7
7
|
|
|
@@ -59,7 +59,10 @@ async function useSpinner(startMessage, fn, finishMessage) {
|
|
|
59
59
|
}
|
|
60
60
|
async function scaffold(to, opts) {
|
|
61
61
|
await promises.mkdir(to, { recursive: true });
|
|
62
|
-
await
|
|
62
|
+
const templateInfo = await getPackageInfo(`@atom.io/template-${opts.templateName}`);
|
|
63
|
+
if (!templateInfo) throw new Error(`Could not find template package`);
|
|
64
|
+
const { rootPath } = templateInfo;
|
|
65
|
+
await templateDir(rootPath, to, opts);
|
|
63
66
|
}
|
|
64
67
|
/**
|
|
65
68
|
* Recursive fs copy, swiped from `create-wmr`:
|
|
@@ -115,4 +118,4 @@ function getPkgManager() {
|
|
|
115
118
|
|
|
116
119
|
//#endregion
|
|
117
120
|
export { createAtom as t };
|
|
118
|
-
//# sourceMappingURL=create-atom-
|
|
121
|
+
//# sourceMappingURL=create-atom-Bs3iurKr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-atom-Bs3iurKr.js","names":["pico: Colors","opts: CreateAtomOptions","fs","dependencies: string[]","devDependencies: string[]"],"sources":["../src/create-atom.ts"],"sourcesContent":["import { existsSync, promises as fs } from \"node:fs\"\nimport { dirname, resolve } from \"node:path\"\nimport { fileURLToPath } from \"node:url\"\n\nimport * as prompts from \"@clack/prompts\"\nimport { getPackageInfo } from \"local-pkg\"\nimport picocolors from \"picocolors\"\nimport type { Colors } from \"picocolors/types\"\nimport { x } from \"tinyexec\"\n\nconst pico: Colors = picocolors.createColors(true)\n\nconst s = prompts.spinner()\n\nexport type PackageManager = `bun` | `npm` | `pnpm` | `yarn`\nexport type TemplateName = `preact-svg-editor` | `react-node-backend`\n\nexport type CreateAtomOptions = {\n\tpackageManager: PackageManager\n\ttemplateName: TemplateName\n}\n\nexport type CreateAtomOptionsPreloaded = {\n\t[K in keyof CreateAtomOptions]?: CreateAtomOptions[K] | undefined\n} & { skipHints?: boolean | undefined }\n\nexport async function createAtom(\n\targDir: string | undefined,\n\toptions: CreateAtomOptionsPreloaded,\n): Promise<void> {\n\tconst skipHint = options.skipHints ?? false\n\tconst packageManager = options.packageManager ?? getPkgManager()\n\n\tprompts.intro(pico.greenBright(`atom.io - Data Components for TypeScript`))\n\n\tconst { dir, templateName } = await prompts.group(\n\t\t{\n\t\t\ttemplateName: () =>\n\t\t\t\tprompts.select<TemplateName>({\n\t\t\t\t\tmessage: `Template:`,\n\t\t\t\t\tinitialValue: `preact-svg-editor`,\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: `Preact SVG Editor`,\n\t\t\t\t\t\t\tvalue: `preact-svg-editor`,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: `React Node Backend`,\n\t\t\t\t\t\t\tvalue: `react-node-backend`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\tdir: () =>\n\t\t\t\targDir\n\t\t\t\t\t? Promise.resolve(argDir)\n\t\t\t\t\t: prompts.text({\n\t\t\t\t\t\t\tmessage: `Project directory:`,\n\t\t\t\t\t\t\tplaceholder: `my-app`,\n\t\t\t\t\t\t\tvalidate(value) {\n\t\t\t\t\t\t\t\tif (value.length === 0) {\n\t\t\t\t\t\t\t\t\treturn `Directory name is required!`\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (existsSync(value)) {\n\t\t\t\t\t\t\t\t\treturn `Refusing to overwrite existing directory or file! Please provide a non-clashing name.`\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}),\n\t\t},\n\t\t{\n\t\t\tonCancel: () => {\n\t\t\t\tprompts.cancel(pico.yellow(`Cancelled`))\n\t\t\t\tprocess.exit(0)\n\t\t\t},\n\t\t},\n\t)\n\tconst targetDir = resolve(process.cwd(), dir)\n\tconst opts: CreateAtomOptions = { packageManager, templateName }\n\n\tawait useSpinner(\n\t\t`Setting up your project directory...`,\n\t\t() => scaffold(targetDir, opts),\n\t\t`Set up project directory`,\n\t)\n\n\tawait useSpinner(\n\t\t`Installing project dependencies...`,\n\t\t() => installDeps(targetDir, opts),\n\t\t`Installed project dependencies`,\n\t)\n\n\tif (skipHint === false) {\n\t\tconst gettingStarted = `\n\t\t\t${pico.dim(`$`)} ${pico.blueBright(`cd ${dir}`)}\n\t\t\t${pico.dim(`$`)} ${pico.blueBright(\n\t\t\t\t`${\n\t\t\t\t\tpackageManager === `npm`\n\t\t\t\t\t\t? `npm run`\n\t\t\t\t\t\t: packageManager === `bun`\n\t\t\t\t\t\t\t? `bun run`\n\t\t\t\t\t\t\t: packageManager\n\t\t\t\t} dev`,\n\t\t\t)}\n\t\t`\n\t\tprompts.note(\n\t\t\tgettingStarted.trim().replace(/^\\t\\t\\t/gm, ``),\n\t\t\t`Getting Started`,\n\t\t)\n\t}\n\n\tprompts.outro(pico.green(`You're all set!`))\n}\n\nasync function useSpinner(\n\tstartMessage: string,\n\tfn: () => Promise<void>,\n\tfinishMessage: string,\n): Promise<void> {\n\ts.start(startMessage)\n\tawait fn()\n\ts.stop(pico.green(finishMessage))\n}\n\nasync function scaffold(to: string, opts: CreateAtomOptions): Promise<void> {\n\tawait fs.mkdir(to, { recursive: true })\n\n\tconst templateInfo = await getPackageInfo(\n\t\t`@atom.io/template-${opts.templateName}`,\n\t)\n\tif (!templateInfo) throw new Error(`Could not find template package`)\n\tconst { rootPath } = templateInfo\n\tawait templateDir(rootPath, to, opts)\n}\n\n/**\n * Recursive fs copy, swiped from `create-wmr`:\n * https://github.com/preactjs/wmr/blob/3c5672ecd2f958c8eaf372d33c084dc69228ae3f/packages/create-wmr/src/index.js#L108-L124\n */\nasync function templateDir(\n\tfrom: string,\n\tto: string,\n\topts: CreateAtomOptions,\n): Promise<void[]> {\n\tconst files = await fs.readdir(from)\n\tconst results = await Promise.all(\n\t\tfiles.map(async (f) => {\n\t\t\tif (f === `.` || f === `..`) return\n\t\t\tconst filename = resolve(from, f)\n\t\t\tif ((await fs.stat(filename)).isDirectory()) {\n\t\t\t\tawait fs.mkdir(resolve(to, f), { recursive: true })\n\t\t\t\treturn templateDir(filename, resolve(to, f), opts)\n\t\t\t}\n\t\t\tif (opts.packageManager !== `npm` && f === `README.md`) {\n\t\t\t\tawait fs.writeFile(\n\t\t\t\t\tresolve(to, f),\n\t\t\t\t\t(await fs.readFile(filename, `utf-8`)).replace(\n\t\t\t\t\t\t/npm run/g,\n\t\t\t\t\t\topts.packageManager === `bun` ? `bun run` : opts.packageManager,\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t\treturn\n\t\t\t}\n\t\t\t// Publishing to npm renames the .gitignore to .npmignore\n\t\t\t// https://github.com/npm/npm/issues/7252#issuecomment-253339460\n\t\t\tif (f === `_gitignore`) f = `.gitignore`\n\t\t\tawait fs.copyFile(filename, resolve(to, f))\n\t\t}),\n\t)\n\treturn results.flat(99)\n}\n\nasync function installDeps(to: string, opts: CreateAtomOptions) {\n\tconst dependencies: string[] = []\n\tconst devDependencies: string[] = []\n\n\tconst installOpts = {\n\t\tpackageManager: opts.packageManager,\n\t\tto,\n\t}\n\n\tawait installPackages(dependencies, { ...installOpts })\n\tdevDependencies.length &&\n\t\t(await installPackages(devDependencies, { ...installOpts, dev: true }))\n}\n\ntype InstallOptions = {\n\tpackageManager: `bun` | `npm` | `pnpm` | `yarn`\n\tto: string\n\tdev?: boolean\n}\n\nfunction installPackages(pkgs: string[], opts: InstallOptions) {\n\treturn x(\n\t\topts.packageManager,\n\t\t[\n\t\t\t// `yarn add` will fail if nothing is provided\n\t\t\topts.packageManager === `yarn` ? (pkgs.length ? `add` : ``) : `install`,\n\t\t\topts.dev ? `-D` : ``,\n\t\t\t...pkgs,\n\t\t].filter(Boolean),\n\t\t{\n\t\t\tnodeOptions: {\n\t\t\t\tstdio: `ignore`,\n\t\t\t\tcwd: opts.to,\n\t\t\t},\n\t\t},\n\t)\n}\n\nfunction getPkgManager(): `bun` | `npm` | `pnpm` | `yarn` {\n\tconst userAgent = process.env[`npm_config_user_agent`] ?? ``\n\tif (userAgent.startsWith(`yarn`)) return `yarn`\n\tif (userAgent.startsWith(`pnpm`)) return `pnpm`\n\tif (userAgent.startsWith(`bun`)) return `bun`\n\treturn `npm`\n}\n"],"mappings":";;;;;;;;AAUA,MAAMA,OAAe,WAAW,aAAa,KAAK;AAElD,MAAM,IAAI,QAAQ,SAAS;AAc3B,eAAsB,WACrB,QACA,SACgB;CAChB,MAAM,WAAW,QAAQ,aAAa;CACtC,MAAM,iBAAiB,QAAQ,kBAAkB,eAAe;AAEhE,SAAQ,MAAM,KAAK,YAAY,2CAA2C,CAAC;CAE3E,MAAM,EAAE,KAAK,iBAAiB,MAAM,QAAQ,MAC3C;EACC,oBACC,QAAQ,OAAqB;GAC5B,SAAS;GACT,cAAc;GACd,SAAS,CACR;IACC,OAAO;IACP,OAAO;IACP,EACD;IACC,OAAO;IACP,OAAO;IACP,CACD;GACD,CAAC;EACH,WACC,SACG,QAAQ,QAAQ,OAAO,GACvB,QAAQ,KA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zC,KAAI,UAAU,WAAW,OAAO,CAAE,QAAO;AACzC,KAAI,UAAU,WAAW,MAAM,CAAE,QAAO;AACxC,QAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-atom.d.ts","names":[],"sources":["../src/create-atom.ts"],"sourcesContent":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"create-atom.d.ts","names":[],"sources":["../src/create-atom.ts"],"sourcesContent":[],"mappings":";KAcY,cAAA;AAAA,KACA,YAAA,GADA,mBAAA,GAAA,oBAAA;AACA,KAEA,iBAAA,GAFA;EAEZ,cAAY,EACK,cADL;EAKZ,YAAY,EAHG,YAGH;CACC;AAAqB,KADtB,0BAAA,GACsB,QAAA,MAArB,iBAAqB,IAAA,iBAAA,CAAkB,CAAlB,CAAA,GAAA,SAAA,EAAA,GAAA;EAAkB,SAAA,CAAA,EAAA,OAAA,GAAA,SAAA;CAAA;AAG9B,iBAAA,UAAA,CAEZ,MAAA,EAAA,MAAA,GAAA,SACP,EAAA,OAAA,EADO,0BACP,CAAA,EAAA,OAAA,CAAA,IAAA,CAAA"}
|
package/dist/create-atom.js
CHANGED
package/dist/create-atom.x.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-atom.io",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Jeremy Banka",
|
|
@@ -27,15 +27,16 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@clack/prompts": "0.11.0",
|
|
29
29
|
"arktype": "2.1.25",
|
|
30
|
+
"local-pkg": "1.1.2",
|
|
30
31
|
"picocolors": "1.1.1",
|
|
31
32
|
"tinyexec": "1.0.2",
|
|
32
33
|
"@atom.io/template-preact-svg-editor": "0.0.2",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
34
|
+
"comline": "0.4.2",
|
|
35
|
+
"@atom.io/template-react-node-backend": "0.0.3"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
|
-
"@types/node": "24.10.0",
|
|
38
38
|
"@types/bun": "npm:bun-types@1.3.1",
|
|
39
|
+
"@types/node": "24.10.0",
|
|
39
40
|
"@types/tmp": "0.2.6",
|
|
40
41
|
"@typescript/native-preview": "7.0.0-dev.20251105.1",
|
|
41
42
|
"concurrently": "9.2.1",
|
package/src/create-atom.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { dirname, resolve } from "node:path"
|
|
|
3
3
|
import { fileURLToPath } from "node:url"
|
|
4
4
|
|
|
5
5
|
import * as prompts from "@clack/prompts"
|
|
6
|
+
import { getPackageInfo } from "local-pkg"
|
|
6
7
|
import picocolors from "picocolors"
|
|
7
8
|
import type { Colors } from "picocolors/types"
|
|
8
9
|
import { x } from "tinyexec"
|
|
@@ -122,16 +123,12 @@ async function useSpinner(
|
|
|
122
123
|
async function scaffold(to: string, opts: CreateAtomOptions): Promise<void> {
|
|
123
124
|
await fs.mkdir(to, { recursive: true })
|
|
124
125
|
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
resolve(
|
|
128
|
-
__dirname,
|
|
129
|
-
`../node_modules/@atom.io`,
|
|
130
|
-
`template-${opts.templateName}`,
|
|
131
|
-
),
|
|
132
|
-
to,
|
|
133
|
-
opts,
|
|
126
|
+
const templateInfo = await getPackageInfo(
|
|
127
|
+
`@atom.io/template-${opts.templateName}`,
|
|
134
128
|
)
|
|
129
|
+
if (!templateInfo) throw new Error(`Could not find template package`)
|
|
130
|
+
const { rootPath } = templateInfo
|
|
131
|
+
await templateDir(rootPath, to, opts)
|
|
135
132
|
}
|
|
136
133
|
|
|
137
134
|
/**
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-atom-C0gh5ath.js","names":["pico: Colors","opts: CreateAtomOptions","fs","dependencies: string[]","devDependencies: string[]"],"sources":["../src/create-atom.ts"],"sourcesContent":["import { existsSync, promises as fs } from \"node:fs\"\nimport { dirname, resolve } from \"node:path\"\nimport { fileURLToPath } from \"node:url\"\n\nimport * as prompts from \"@clack/prompts\"\nimport picocolors from \"picocolors\"\nimport type { Colors } from \"picocolors/types\"\nimport { x } from \"tinyexec\"\n\nconst pico: Colors = picocolors.createColors(true)\n\nconst s = prompts.spinner()\n\nexport type PackageManager = `bun` | `npm` | `pnpm` | `yarn`\nexport type TemplateName = `preact-svg-editor` | `react-node-backend`\n\nexport type CreateAtomOptions = {\n\tpackageManager: PackageManager\n\ttemplateName: TemplateName\n}\n\nexport type CreateAtomOptionsPreloaded = {\n\t[K in keyof CreateAtomOptions]?: CreateAtomOptions[K] | undefined\n} & { skipHints?: boolean | undefined }\n\nexport async function createAtom(\n\targDir: string | undefined,\n\toptions: CreateAtomOptionsPreloaded,\n): Promise<void> {\n\tconst skipHint = options.skipHints ?? false\n\tconst packageManager = options.packageManager ?? getPkgManager()\n\n\tprompts.intro(pico.greenBright(`atom.io - Data Components for TypeScript`))\n\n\tconst { dir, templateName } = await prompts.group(\n\t\t{\n\t\t\ttemplateName: () =>\n\t\t\t\tprompts.select<TemplateName>({\n\t\t\t\t\tmessage: `Template:`,\n\t\t\t\t\tinitialValue: `preact-svg-editor`,\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: `Preact SVG Editor`,\n\t\t\t\t\t\t\tvalue: `preact-svg-editor`,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: `React Node Backend`,\n\t\t\t\t\t\t\tvalue: `react-node-backend`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\tdir: () =>\n\t\t\t\targDir\n\t\t\t\t\t? Promise.resolve(argDir)\n\t\t\t\t\t: prompts.text({\n\t\t\t\t\t\t\tmessage: `Project directory:`,\n\t\t\t\t\t\t\tplaceholder: `my-app`,\n\t\t\t\t\t\t\tvalidate(value) {\n\t\t\t\t\t\t\t\tif (value.length === 0) {\n\t\t\t\t\t\t\t\t\treturn `Directory name is required!`\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (existsSync(value)) {\n\t\t\t\t\t\t\t\t\treturn `Refusing to overwrite existing directory or file! Please provide a non-clashing name.`\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}),\n\t\t},\n\t\t{\n\t\t\tonCancel: () => {\n\t\t\t\tprompts.cancel(pico.yellow(`Cancelled`))\n\t\t\t\tprocess.exit(0)\n\t\t\t},\n\t\t},\n\t)\n\tconst targetDir = resolve(process.cwd(), dir)\n\tconst opts: CreateAtomOptions = { packageManager, templateName }\n\n\tawait useSpinner(\n\t\t`Setting up your project directory...`,\n\t\t() => scaffold(targetDir, opts),\n\t\t`Set up project directory`,\n\t)\n\n\tawait useSpinner(\n\t\t`Installing project dependencies...`,\n\t\t() => installDeps(targetDir, opts),\n\t\t`Installed project dependencies`,\n\t)\n\n\tif (skipHint === false) {\n\t\tconst gettingStarted = `\n\t\t\t${pico.dim(`$`)} ${pico.blueBright(`cd ${dir}`)}\n\t\t\t${pico.dim(`$`)} ${pico.blueBright(\n\t\t\t\t`${\n\t\t\t\t\tpackageManager === `npm`\n\t\t\t\t\t\t? `npm run`\n\t\t\t\t\t\t: packageManager === `bun`\n\t\t\t\t\t\t\t? `bun run`\n\t\t\t\t\t\t\t: packageManager\n\t\t\t\t} dev`,\n\t\t\t)}\n\t\t`\n\t\tprompts.note(\n\t\t\tgettingStarted.trim().replace(/^\\t\\t\\t/gm, ``),\n\t\t\t`Getting Started`,\n\t\t)\n\t}\n\n\tprompts.outro(pico.green(`You're all set!`))\n}\n\nasync function useSpinner(\n\tstartMessage: string,\n\tfn: () => Promise<void>,\n\tfinishMessage: string,\n): Promise<void> {\n\ts.start(startMessage)\n\tawait fn()\n\ts.stop(pico.green(finishMessage))\n}\n\nasync function scaffold(to: string, opts: CreateAtomOptions): Promise<void> {\n\tawait fs.mkdir(to, { recursive: true })\n\n\tconst __dirname = dirname(fileURLToPath(import.meta.url))\n\tawait templateDir(\n\t\tresolve(\n\t\t\t__dirname,\n\t\t\t`../node_modules/@atom.io`,\n\t\t\t`template-${opts.templateName}`,\n\t\t),\n\t\tto,\n\t\topts,\n\t)\n}\n\n/**\n * Recursive fs copy, swiped from `create-wmr`:\n * https://github.com/preactjs/wmr/blob/3c5672ecd2f958c8eaf372d33c084dc69228ae3f/packages/create-wmr/src/index.js#L108-L124\n */\nasync function templateDir(\n\tfrom: string,\n\tto: string,\n\topts: CreateAtomOptions,\n): Promise<void[]> {\n\tconst files = await fs.readdir(from)\n\tconst results = await Promise.all(\n\t\tfiles.map(async (f) => {\n\t\t\tif (f === `.` || f === `..`) return\n\t\t\tconst filename = resolve(from, f)\n\t\t\tif ((await fs.stat(filename)).isDirectory()) {\n\t\t\t\tawait fs.mkdir(resolve(to, f), { recursive: true })\n\t\t\t\treturn templateDir(filename, resolve(to, f), opts)\n\t\t\t}\n\t\t\tif (opts.packageManager !== `npm` && f === `README.md`) {\n\t\t\t\tawait fs.writeFile(\n\t\t\t\t\tresolve(to, f),\n\t\t\t\t\t(await fs.readFile(filename, `utf-8`)).replace(\n\t\t\t\t\t\t/npm run/g,\n\t\t\t\t\t\topts.packageManager === `bun` ? `bun run` : opts.packageManager,\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t\treturn\n\t\t\t}\n\t\t\t// Publishing to npm renames the .gitignore to .npmignore\n\t\t\t// https://github.com/npm/npm/issues/7252#issuecomment-253339460\n\t\t\tif (f === `_gitignore`) f = `.gitignore`\n\t\t\tawait fs.copyFile(filename, resolve(to, f))\n\t\t}),\n\t)\n\treturn results.flat(99)\n}\n\nasync function installDeps(to: string, opts: CreateAtomOptions) {\n\tconst dependencies: string[] = []\n\tconst devDependencies: string[] = []\n\n\tconst installOpts = {\n\t\tpackageManager: opts.packageManager,\n\t\tto,\n\t}\n\n\tawait installPackages(dependencies, { ...installOpts })\n\tdevDependencies.length &&\n\t\t(await installPackages(devDependencies, { ...installOpts, dev: true }))\n}\n\ntype InstallOptions = {\n\tpackageManager: `bun` | `npm` | `pnpm` | `yarn`\n\tto: string\n\tdev?: boolean\n}\n\nfunction installPackages(pkgs: string[], opts: InstallOptions) {\n\treturn x(\n\t\topts.packageManager,\n\t\t[\n\t\t\t// `yarn add` will fail if nothing is provided\n\t\t\topts.packageManager === `yarn` ? (pkgs.length ? `add` : ``) : `install`,\n\t\t\topts.dev ? `-D` : ``,\n\t\t\t...pkgs,\n\t\t].filter(Boolean),\n\t\t{\n\t\t\tnodeOptions: {\n\t\t\t\tstdio: `ignore`,\n\t\t\t\tcwd: opts.to,\n\t\t\t},\n\t\t},\n\t)\n}\n\nfunction getPkgManager(): `bun` | `npm` | `pnpm` | `yarn` {\n\tconst userAgent = process.env[`npm_config_user_agent`] ?? ``\n\tif (userAgent.startsWith(`yarn`)) return `yarn`\n\tif (userAgent.startsWith(`pnpm`)) return `pnpm`\n\tif (userAgent.startsWith(`bun`)) return `bun`\n\treturn `npm`\n}\n"],"mappings":";;;;;;;;AASA,MAAMA,OAAe,WAAW,aAAa,KAAK;AAElD,MAAM,IAAI,QAAQ,SAAS;AAc3B,eAAsB,WACrB,QACA,SACgB;CAChB,MAAM,WAAW,QAAQ,aAAa;CACtC,MAAM,iBAAiB,QAAQ,kBAAkB,eAAe;AAEhE,SAAQ,MAAM,KAAK,YAAY,2CAA2C,CAAC;CAE3E,MAAM,EAAE,KAAK,iBAAiB,MAAM,QAAQ,MAC3C;EACC,oBACC,QAAQ,OAAqB;GAC5B,SAAS;GACT,cAAc;GACd,SAAS,CACR;IACC,OAAO;IACP,OAAO;IACP,EACD;IACC,OAAO;IACP,OAAO;IACP,CACD;GACD,CAAC;EACH,WACC,SACG,QAAQ,QAAQ,OAAO,GACvB,QAAQ,KAAK;GACb,SAAS;GACT,aAAa;GACb,SAAS,OAAO;AACf,QAAI,MAAM,WAAW,EACpB,QAAO;AAER,QAAI,WAAW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