@nano191225/scriptup 1.3.1 → 1.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.
Files changed (2) hide show
  1. package/dist/index.js +19 -19
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
1
  #!/usr/bin/env node
2
- import{Command as e,Option as t}from"commander";import n from"ora";import*as r from"node:fs";import*as i from"node:path";import a from"chalk";import{execSync as o,spawnSync as s}from"node:child_process";import{randomUUID as c}from"node:crypto";import*as l from"node:os";import{build as u,mergeConfig as d}from"tsdown";import{pathToFileURL as f}from"node:url";function p(e){console.log(`${a.blue(`[INFO]`)} ${e}`)}function m(e){console.log(`${a.gray(`[LOG]`)} ${e}`)}function h(e){console.log(`${a.yellow(`[WARN]`)} ${e}`)}function g(e){console.error(`${a.red(`[ERROR]`)} ${e}`)}function _(e){console.log(`${a.green(`[DONE]`)} ${e}`)}function v(e){return e.type===`script`}function y(e){return`module_name`in e}function b(){let e=i.resolve(`manifest.json`);r.existsSync(e)||(g(`manifest.json not found.`),process.exit(1));let t=r.readFileSync(e,`utf-8`);return JSON.parse(t)}function x(e){let t=i.resolve(`manifest.json`),n=JSON.stringify(e,null,` `);r.writeFileSync(t,n,`utf-8`)}async function S(e){let t=`https://registry.npmjs.org/${e}`,n=await fetch(t);if(!n.ok)throw Error(`Failed to fetch versions for ${e}: ${n.statusText}`);let r=await n.json(),i=Object.keys(r.versions).reverse();return i.sort((e,t)=>{let n=e=>e.includes(`stable`)?0:e.includes(`preview`)?1:2;return n(e)-n(t)}),i}function C(e){let t=e.indexOf(`-`);if(t===-1)return e;let n=e.substring(t).indexOf(`.`);if(n===-1)return e;let r=t+n+1,i=e.substring(r),a=i.indexOf(`-`);return a===-1?i:i.substring(0,a)}function w(e){let t=e.indexOf(`-`);if(t===-1)return e;let n=e.substring(t).indexOf(`.`);return n===-1?e:e.substring(0,t+n)}function T(){let e=process.cwd(),t=i.resolve(e,`package.json`);if(r.existsSync(t)){let e=JSON.parse(r.readFileSync(t,`utf-8`));if(e.packageManager){let t=e.packageManager.split(`@`)[0];if(E(t))return m(`Detected package manager from package.json: ${t}`),t}}return r.existsSync(i.resolve(e,`bun.lockb`))||r.existsSync(i.resolve(e,`bun.lock`))?(m(`Detected package manager from lock file: bun`),`bun`):r.existsSync(i.resolve(e,`pnpm-lock.yaml`))?(m(`Detected package manager from lock file: pnpm`),`pnpm`):r.existsSync(i.resolve(e,`yarn.lock`))?(m(`Detected package manager from lock file: yarn`),`yarn`):r.existsSync(i.resolve(e,`package-lock.json`))?(m(`Detected package manager from lock file: npm`),`npm`):(m(`No lock file found. Defaulting to npm.`),`npm`)}function E(e){return[`npm`,`pnpm`,`yarn`,`bun`].includes(e)}function ee(e){return e===`yarn`?`add`:`install`}function te(e){switch(e){case`npm`:return`--save-exact`;case`pnpm`:return`--save-exact`;case`yarn`:return`--exact`;case`bun`:return`--exact`}}function D(e){switch(e){case`npm`:return`--force`;case`pnpm`:return`--force`;case`yarn`:return;case`bun`:return`--force`}}function O(e,t){let n=ee(e),r=te(e),i=D(e),a=[e,n,t,e===`yarn`?`--dev`:`--save-dev`,r];i&&a.push(i),o(a.join(` `),{stdio:`pipe`,cwd:process.cwd()})}async function k(){let e=n(`Fetching Minecraft version...`).start(),t=await A();e.succeed(`Install modules for Minecraft version: ${t}`);let r=b();m(`Manifest loaded. Fetching new module versions...`);let i=T(),a=[],o=r.dependencies?.filter(y)??[];for(let e of o){let n=(await S(e.module_name)).find(e=>e.includes(t));n||(g(`No version found for ${e.module_name} matching MC ${t}`),process.exit(1)),e.version=w(n),m(`${e.module_name}: ${n}`),a.push({name:e.module_name,version:n})}x(r),m(`Module versions fetched and manifest updated.`);let s=n(`Installing modules...`).start();for(let e=0;e<a.length;e++){let t=a[e];s.text=`Installing modules... (${e+1}/${a.length}) ${t.name}`;try{O(i,`${t.name}@${t.version}`)}catch(e){s.fail(`Failed to install ${t.name}`),g(e instanceof Error?e.message:String(e)),process.exit(1)}}s.succeed(`All modules installed successfully.`)}async function A(){let e=(await S(`@minecraft/server`)).find(e=>e.includes(`-stable`));return e||(g(`No stable versions found.`),process.exit(1)),C(e)}async function j(){let e=n(`Fetching Minecraft version...`).start(),t=await M();e.succeed(`Install modules for Minecraft version: ${t}`);let r=b();m(`Manifest loaded. Fetching new module versions...`);let i=T(),a=[],o=r.dependencies?.filter(y)??[];for(let e of o){let n=(await S(e.module_name)).find(e=>e.includes(t));n||(g(`No version found for ${e.module_name} matching MC ${t}`),process.exit(1)),e.version=w(n),m(`${e.module_name}: ${n}`),a.push({name:e.module_name,version:n})}x(r),m(`Module versions fetched and manifest updated.`);let s=n(`Installing modules...`).start();for(let e=0;e<a.length;e++){let t=a[e];s.text=`Installing modules... (${e+1}/${a.length}) ${t.name}`;try{O(i,`${t.name}@${t.version}`)}catch(e){s.fail(`Failed to install ${t.name}`),g(e instanceof Error?e.message:String(e)),process.exit(1)}}s.succeed(`All modules installed successfully.`)}async function M(){let e=(await S(`@minecraft/server`)).find(e=>e.includes(`-preview`));return e||(g(`No preview versions found.`),process.exit(1)),C(e)}async function N(){let e=n(`Fetching Minecraft version...`).start(),t=await P();e.succeed(`Install modules for Minecraft version: ${t}`);let r=b();m(`Manifest loaded. Fetching new module versions...`);let i=T(),a=[],o=r.dependencies?.filter(y)??[];for(let e of o){let n=await S(e.module_name),r=n.find(e=>!e.includes(`stable`)&&!e.includes(`preview`)&&!e.includes(`internal`)&&!e.includes(`beta`)&&!e.startsWith(`0.`));r?e.version=r:(h(`No LTS versions found for ${e.module_name}. Falling back to stable.`),r=n.find(e=>e.includes(t)),r||(g(`No version found for ${e.module_name}`),process.exit(1)),e.version=C(r)),m(`${e.module_name}: ${r}`),a.push({name:e.module_name,version:r})}x(r),m(`Module versions fetched and manifest updated.`);let s=n(`Installing modules...`).start();for(let e=0;e<a.length;e++){let t=a[e];s.text=`Installing modules... (${e+1}/${a.length}) ${t.name}`;try{O(i,`${t.name}@${t.version}`)}catch(e){s.fail(`Failed to install ${t.name}`),g(e instanceof Error?e.message:String(e)),process.exit(1)}}s.succeed(`All modules installed successfully.`)}async function P(){let e=(await S(`@minecraft/server`)).find(e=>e.includes(`-stable`));return e||(g(`No stable versions found.`),process.exit(1)),C(e)}async function F(e){let t=await S(`@minecraft/server`),n=t.find(t=>t===e);if(n){p(`Found exact version: ${n}`);return}let r=t.find(t=>t.includes(e));r||(g(`Version not found: ${e}`),process.exit(1));let i=C(r);p(`Found version: ${i}`);let a=(await S(`@minecraft/server`)).find(e=>e.includes(i)),o=(await S(`@minecraft/server-ui`)).find(e=>e.includes(i));a&&p(`Server version: ${a}`),o&&p(`Server UI version: ${o}`)}const I=`1.3.1`;async function L(e){let t=i.resolve(e.targetDir),n=e.projectName?.trim()||i.basename(t),a=e.lib===!0,o=e.workflow!==!1;r.mkdirSync(t,{recursive:!0});let s=V(n,await B(),o,a),c=0;for(let[e,n]of Object.entries(s)){let a=i.join(t,e);if(r.existsSync(a)){h(`Skipped existing file: ${e}`);continue}r.mkdirSync(i.dirname(a),{recursive:!0}),r.writeFileSync(a,n,`utf-8`),m(`Created ${e}`),c+=1}if(c===0){h(`No files were created.`);return}_(`Project initialized in ${t}`)}function R(e){r.existsSync(e)&&r.readdirSync(e).length>0&&(g(`Target directory is not empty: ${e}`),process.exit(1))}function z(e,t){let n=s(t,[`.`],{cwd:e,shell:!0,stdio:`inherit`});if(n.error)throw n.error;if(n.status!==0)throw Error(`${t} exited with code ${n.status??`unknown`}`)}async function B(){try{let e=(await S(`@minecraft/server`)).find(e=>e.includes(`-stable`));if(!e)throw Error(`No stable @minecraft/server version found.`);let t=C(e),n=t,r=[],i={};for(let e of[`@minecraft/server`,`@minecraft/server-ui`]){let n=(await S(e)).find(e=>e.includes(t));if(!n){h(`Skipped ${e}: no version found for Minecraft ${t}`);continue}let a=w(n);r.push({module_name:e,version:a}),i[e]=n}return{engineVersion:n,dependencies:r,packageDependencies:i}}catch(e){return h(`Failed to resolve latest ScriptAPI dependencies: ${e instanceof Error?e.message:String(e)}`),h(`Creating the project without npm dependencies. You can run scriptup stable later.`),{engineVersion:`1.20.0`,dependencies:[],packageDependencies:{}}}}function V(e,t,n,r){let i=r?ae(e):null,a=H(e,t.engineVersion,t.dependencies,r),o=U(e,t.packageDependencies,r,i),s={".gitignore":`node_modules/
2
+ import{Command as e,Option as t}from"commander";import n from"ora";import*as r from"node:fs";import*as i from"node:path";import a from"chalk";import{execSync as o,spawnSync as s}from"node:child_process";import{randomUUID as c}from"node:crypto";import*as l from"node:os";import{build as u,mergeConfig as d}from"tsdown";import{pathToFileURL as f}from"node:url";function p(e){console.log(`${a.blue(`[INFO]`)} ${e}`)}function m(e){console.log(`${a.gray(`[LOG]`)} ${e}`)}function h(e){console.log(`${a.yellow(`[WARN]`)} ${e}`)}function g(e){console.error(`${a.red(`[ERROR]`)} ${e}`)}function _(e){console.log(`${a.green(`[DONE]`)} ${e}`)}function ee(e){return e.type===`script`}function v(e){return`module_name`in e}function y(){let e=i.resolve(`manifest.json`);r.existsSync(e)||(g(`manifest.json not found.`),process.exit(1));let t=r.readFileSync(e,`utf-8`);return JSON.parse(t)}function b(e){let t=i.resolve(`manifest.json`),n=JSON.stringify(e,null,` `);r.writeFileSync(t,n,`utf-8`)}async function x(e){let t=`https://registry.npmjs.org/${e}`,n=await fetch(t);if(!n.ok)throw Error(`Failed to fetch versions for ${e}: ${n.statusText}`);let r=await n.json(),i=Object.keys(r.versions).reverse();return i.sort((e,t)=>{let n=e=>e.includes(`stable`)?0:e.includes(`preview`)?1:2;return n(e)-n(t)}),i}function S(e){let t=e.indexOf(`-`);if(t===-1)return e;let n=e.substring(t).indexOf(`.`);if(n===-1)return e;let r=t+n+1,i=e.substring(r),a=i.indexOf(`-`);return a===-1?i:i.substring(0,a)}function C(e){let t=e.indexOf(`-`);if(t===-1)return e;let n=e.substring(t).indexOf(`.`);return n===-1?e:e.substring(0,t+n)}function w(){let e=process.cwd(),t=i.resolve(e,`package.json`);if(r.existsSync(t)){let e=JSON.parse(r.readFileSync(t,`utf-8`));if(e.packageManager){let t=e.packageManager.split(`@`)[0];if(T(t))return m(`Detected package manager from package.json: ${t}`),t}}return r.existsSync(i.resolve(e,`bun.lockb`))||r.existsSync(i.resolve(e,`bun.lock`))?(m(`Detected package manager from lock file: bun`),`bun`):r.existsSync(i.resolve(e,`pnpm-lock.yaml`))?(m(`Detected package manager from lock file: pnpm`),`pnpm`):r.existsSync(i.resolve(e,`yarn.lock`))?(m(`Detected package manager from lock file: yarn`),`yarn`):r.existsSync(i.resolve(e,`package-lock.json`))?(m(`Detected package manager from lock file: npm`),`npm`):(m(`No lock file found. Defaulting to npm.`),`npm`)}function T(e){return[`npm`,`pnpm`,`yarn`,`bun`].includes(e)}function E(e){return e===`yarn`?`add`:`install`}function te(e){switch(e){case`npm`:return`--save-exact`;case`pnpm`:return`--save-exact`;case`yarn`:return`--exact`;case`bun`:return`--exact`}}function ne(e){switch(e){case`npm`:return`--force`;case`pnpm`:return`--force`;case`yarn`:return;case`bun`:return`--force`}}function D(e,t){let n=E(e),r=te(e),i=ne(e),a=[e,n,t,e===`yarn`?`--dev`:`--save-dev`,r];i&&a.push(i),o(a.join(` `),{stdio:`pipe`,cwd:process.cwd()})}async function re(){let e=n(`Fetching Minecraft version...`).start(),t=await O();e.succeed(`Install modules for Minecraft version: ${t}`);let r=y();m(`Manifest loaded. Fetching new module versions...`);let i=w(),a=[],o=r.dependencies?.filter(v)??[];for(let e of o){let n=(await x(e.module_name)).find(e=>e.includes(t));n||(g(`No version found for ${e.module_name} matching MC ${t}`),process.exit(1)),e.version=C(n),m(`${e.module_name}: ${n}`),a.push({name:e.module_name,version:n})}b(r),m(`Module versions fetched and manifest updated.`);let s=n(`Installing modules...`).start();for(let e=0;e<a.length;e++){let t=a[e];s.text=`Installing modules... (${e+1}/${a.length}) ${t.name}`;try{D(i,`${t.name}@${t.version}`)}catch(e){s.fail(`Failed to install ${t.name}`),g(e instanceof Error?e.message:String(e)),process.exit(1)}}s.succeed(`All modules installed successfully.`)}async function O(){let e=(await x(`@minecraft/server`)).find(e=>e.includes(`-stable`));return e||(g(`No stable versions found.`),process.exit(1)),S(e)}async function k(){let e=n(`Fetching Minecraft version...`).start(),t=await A();e.succeed(`Install modules for Minecraft version: ${t}`);let r=y();m(`Manifest loaded. Fetching new module versions...`);let i=w(),a=[],o=r.dependencies?.filter(v)??[];for(let e of o){let n=(await x(e.module_name)).find(e=>e.includes(t));n||(g(`No version found for ${e.module_name} matching MC ${t}`),process.exit(1)),e.version=C(n),m(`${e.module_name}: ${n}`),a.push({name:e.module_name,version:n})}b(r),m(`Module versions fetched and manifest updated.`);let s=n(`Installing modules...`).start();for(let e=0;e<a.length;e++){let t=a[e];s.text=`Installing modules... (${e+1}/${a.length}) ${t.name}`;try{D(i,`${t.name}@${t.version}`)}catch(e){s.fail(`Failed to install ${t.name}`),g(e instanceof Error?e.message:String(e)),process.exit(1)}}s.succeed(`All modules installed successfully.`)}async function A(){let e=(await x(`@minecraft/server`)).find(e=>e.includes(`-preview`));return e||(g(`No preview versions found.`),process.exit(1)),S(e)}async function j(){let e=n(`Fetching Minecraft version...`).start(),t=await M();e.succeed(`Install modules for Minecraft version: ${t}`);let r=y();m(`Manifest loaded. Fetching new module versions...`);let i=w(),a=[],o=r.dependencies?.filter(v)??[];for(let e of o){let n=await x(e.module_name),r=n.find(e=>!e.includes(`stable`)&&!e.includes(`preview`)&&!e.includes(`internal`)&&!e.includes(`beta`)&&!e.startsWith(`0.`));r?e.version=r:(h(`No LTS versions found for ${e.module_name}. Falling back to stable.`),r=n.find(e=>e.includes(t)),r||(g(`No version found for ${e.module_name}`),process.exit(1)),e.version=S(r)),m(`${e.module_name}: ${r}`),a.push({name:e.module_name,version:r})}b(r),m(`Module versions fetched and manifest updated.`);let s=n(`Installing modules...`).start();for(let e=0;e<a.length;e++){let t=a[e];s.text=`Installing modules... (${e+1}/${a.length}) ${t.name}`;try{D(i,`${t.name}@${t.version}`)}catch(e){s.fail(`Failed to install ${t.name}`),g(e instanceof Error?e.message:String(e)),process.exit(1)}}s.succeed(`All modules installed successfully.`)}async function M(){let e=(await x(`@minecraft/server`)).find(e=>e.includes(`-stable`));return e||(g(`No stable versions found.`),process.exit(1)),S(e)}async function N(e){let t=await x(`@minecraft/server`),n=t.find(t=>t===e);if(n){p(`Found exact version: ${n}`);return}let r=t.find(t=>t.includes(e));r||(g(`Version not found: ${e}`),process.exit(1));let i=S(r);p(`Found version: ${i}`);let a=(await x(`@minecraft/server`)).find(e=>e.includes(i)),o=(await x(`@minecraft/server-ui`)).find(e=>e.includes(i));a&&p(`Server version: ${a}`),o&&p(`Server UI version: ${o}`)}const P=`1.3.2`;function F(){try{let e=s(`git`,[`config`,`user.name`],{encoding:`utf-8`,shell:!0});if(e.status===0){let t=e.stdout.trim();if(t)return t}}catch{}}async function I(e){let t=i.resolve(e.targetDir),n=e.projectName?.trim()||i.basename(t),a=e.directoryName?.trim()||n,o=e.lib===!0,s=e.workflow!==!1;r.mkdirSync(t,{recursive:!0});let c=B(n,a,await z(),s,o),l=0;for(let[e,n]of Object.entries(c)){let a=i.join(t,e);if(r.existsSync(a)){h(`Skipped existing file: ${e}`);continue}r.mkdirSync(i.dirname(a),{recursive:!0}),r.writeFileSync(a,n,`utf-8`),m(`Created ${e}`),l+=1}if(l===0){h(`No files were created.`);return}_(`Project initialized in ${t}`)}function L(e){r.existsSync(e)&&r.readdirSync(e).length>0&&(g(`Target directory is not empty: ${e}`),process.exit(1))}function R(e,t){let n=s(t,[`.`],{cwd:e,shell:!0,stdio:`inherit`});if(n.error)throw n.error;if(n.status!==0)throw Error(`${t} exited with code ${n.status??`unknown`}`)}async function z(){try{let e=(await x(`@minecraft/server`)).find(e=>e.includes(`-stable`));if(!e)throw Error(`No stable @minecraft/server version found.`);let t=S(e),n=t,r=[],i={};for(let e of[`@minecraft/server`,`@minecraft/server-ui`]){let n=(await x(e)).find(e=>e.includes(t));if(!n){h(`Skipped ${e}: no version found for Minecraft ${t}`);continue}let a=C(n);r.push({module_name:e,version:a}),i[e]=n}return{engineVersion:n,dependencies:r,packageDependencies:i}}catch(e){return h(`Failed to resolve latest ScriptAPI dependencies: ${e instanceof Error?e.message:String(e)}`),h(`Creating the project without npm dependencies. You can run scriptup stable later.`),{engineVersion:`1.20.0`,dependencies:[],packageDependencies:{}}}}function B(e,t,n,r,i){let a=i?se(e):null,o=V(e,n.engineVersion,n.dependencies,i),s=H(e,t,n.packageDependencies,i,a),c={".gitignore":`node_modules/
3
3
  scripts
4
4
  dist
5
5
  *.mcpack
6
6
  *.mcaddon
7
- `,".vscode/settings.json":JSON.stringify(G(),null,2)+`
8
- `,".vscode/launch.json":JSON.stringify(K(a),null,2)+`
9
- `,"README.md":ne(e,r,i),LICENSE:oe(),"manifest.json":JSON.stringify(a,null,` `)+`
10
- `,"package.json":JSON.stringify(o,null,2)+`
11
- `,"tsconfig.json":JSON.stringify(W(r,i),null,2)+`
7
+ `,".vscode/settings.json":JSON.stringify(W(),null,2)+`
8
+ `,".vscode/launch.json":JSON.stringify(G(o),null,2)+`
9
+ `,"README.md":X(e,i,a),LICENSE:ce(),"manifest.json":JSON.stringify(o,null,` `)+`
10
+ `,"package.json":JSON.stringify(s,null,2)+`
11
+ `,"tsconfig.json":JSON.stringify(U(i,a),null,2)+`
12
12
  `,"tsdown.config.ts":[`import { defineConfig } from "tsdown";`,``,`export default defineConfig({});`,``].join(`
13
- `),"src/main.ts":r?re(i??`@scope/sample`):Z()};return r&&(s[`package/main.ts`]=ie()),n&&(s[`.github/workflows/mcpack.yml`]=q(),s[`.github/workflows/webhook.yml`]=Y(),r&&(s[`.github/workflows/publish.yml`]=J(),s[`.github/workflows/ensure-dts-export.js`]=X())),s}function H(e,t,n,r){let i=r?`-lib`:`-beh`;return{format_version:3,header:{name:`${e}${i}`,description:`${e}${i}`,uuid:c(),version:`0.1.0`,min_engine_version:t},metadata:{authors:[`YOUR NAME HERE`],url:`https://example.com/your-project`,generated_with:{"nano191225-scriptup":[I]}},modules:[{type:`data`,uuid:c(),version:`0.1.0`},{type:`script`,uuid:c(),version:`0.1.0`,language:`javascript`,entry:`scripts/main.js`}],dependencies:n}}function U(e,t,n,r){let i={"@nano191225/scriptup":`^1.0.0`,"@bedrock-apis/env-types":`^1.0.0-beta.6`,typescript:`^5.9.3`,tsdown:`^0.21.2`};for(let[e,n]of Object.entries(t))i[e]=n;let a=n?[`dist`,`LICENSE`,`README.md`]:[`manifest.json`,`scripts`,`LICENSE`,`README.md`];return{name:se(e),version:`0.1.0`,type:`module`,...n?{exports:{".":{types:`./dist/main.d.ts`,default:`./dist/main.js`}},main:`./dist/main.js`,types:`./dist/main.d.ts`,prepublishOnly:`scriptup build --release && node .github/workflows/ensure-dts-export.js`}:{},scripts:{build:`scriptup build --release`,watch:`scriptup build --watch`},dependencies:{},devDependencies:i,keywords:[`minecraft`,`minecraft-bedrock`,`minecraft-script-api`,`scriptapi`],files:a}}function W(e,t){let n={strict:!0,noLib:!0,types:[`@bedrock-apis/env-types`],noEmit:!0};return e&&t&&(n.baseUrl=`.`,n.paths={[t]:[`package/main.ts`]}),{include:e?[`src`,`package`]:[`src`],compilerOptions:n}}function G(){return{"json.schemas":[{url:`https://raw.githubusercontent.com/Blockception/Minecraft-bedrock-json-schemas/refs/heads/main/general/manifest.json`,fileMatch:[`manifest.json`]}]}}function K(e){let t=e.modules?.find(e=>e.type===`script`)?.uuid;return t||h(`No script module UUID found in manifest. VSCode launch configuration will not include targetModuleUuid.`),{version:`0.2.0`,configurations:[{type:`minecraft-js`,request:`attach`,name:`Attach to Minecraft`,mode:`listen`,localRoot:"${workspaceFolder}/src",sourceMapRoot:"${workspaceFolder}/scripts",...t?{targetModuleUuid:t}:{},host:`localhost`,port:19144}]}}function q(){return`name: Upload mcpack
13
+ `),"src/main.ts":i?ae(a??`@scope/sample`):ie()};return i&&(c[`package/main.ts`]=oe()),r&&(c[`.github/workflows/mcpack.yml`]=K(),c[`.github/workflows/webhook.yml`]=J(),i&&(c[`.github/workflows/publish.yml`]=q(),c[`.github/workflows/ensure-dts-export.js`]=Y())),c}function V(e,t,n,r){let i=r?`-lib`:`-beh`;return{format_version:3,header:{name:`${e}${i}`,description:`${e}${i}`,uuid:c(),version:`0.1.0`,min_engine_version:t},metadata:{authors:[`YOUR NAME HERE`],url:`https://example.com/your-project`,generated_with:{"nano191225-scriptup":[P]}},modules:[{type:`data`,uuid:c(),version:`0.1.0`},{type:`script`,uuid:c(),version:`0.1.0`,language:`javascript`,entry:`scripts/main.js`}],dependencies:n}}function H(e,t,n,r,i){let a={"@nano191225/scriptup":`^1.0.0`,"@bedrock-apis/env-types":`^1.0.0-beta.6`,typescript:`^5.9.3`,tsdown:`^0.21.2`};for(let[e,t]of Object.entries(n))a[e]=t;let o=r?[`dist`,`LICENSE`,`README.md`]:[`manifest.json`,`scripts`,`LICENSE`,`README.md`];return{name:le(e),version:`0.1.0`,type:`module`,...r?{exports:{".":{types:`./dist/main.d.ts`,default:`./dist/main.js`}},main:`./dist/main.js`,types:`./dist/main.d.ts`,prepublishOnly:`scriptup build --release && node .github/workflows/ensure-dts-export.js`,repository:`https://github.com/${F()??`{{your-username}}`}/${t}.git`}:{},scripts:{build:`scriptup build --release`,watch:`scriptup build --watch`},dependencies:{},devDependencies:a,keywords:[`minecraft`,`minecraft-bedrock`,`minecraft-script-api`,`scriptapi`],files:o}}function U(e,t){let n={strict:!0,noLib:!0,types:[`@bedrock-apis/env-types`],noEmit:!0};return e&&t&&(n.baseUrl=`.`,n.paths={[t]:[`package/main.ts`]}),{include:e?[`src`,`package`]:[`src`],compilerOptions:n}}function W(){return{"json.schemas":[{url:`https://raw.githubusercontent.com/Blockception/Minecraft-bedrock-json-schemas/refs/heads/main/general/manifest.json`,fileMatch:[`manifest.json`]}]}}function G(e){let t=e.modules?.find(e=>e.type===`script`)?.uuid;return t||h(`No script module UUID found in manifest. VSCode launch configuration will not include targetModuleUuid.`),{version:`0.2.0`,configurations:[{type:`minecraft-js`,request:`attach`,name:`Attach to Minecraft`,mode:`listen`,localRoot:"${workspaceFolder}/src",sourceMapRoot:"${workspaceFolder}/scripts",...t?{targetModuleUuid:t}:{},host:`localhost`,port:19144}]}}function K(){return`name: Upload mcpack
14
14
  on:
15
15
  release:
16
16
  types: [published]
@@ -122,7 +122,7 @@ jobs:
122
122
  - name: Upload Release Asset
123
123
  run: gh release upload "$GITHUB_REF_NAME" "\${{ steps.get-name.outputs.fileName }}.mcpack" "\${{ steps.get-name.outputs.fileName }}.zip" --clobber
124
124
  env:
125
- GITHUB_TOKEN: \${{ github.token }}`}function J(){return`name: Publish library
125
+ GITHUB_TOKEN: \${{ github.token }}`}function q(){return`name: Publish library
126
126
  # Triggered when a GitHub release is published.
127
127
  # Uses npm Trusted Publishers (OIDC) — no NPM_TOKEN secret required.
128
128
  # See: https://docs.npmjs.com/trusted-publishers#configuring-trusted-publishing
@@ -166,7 +166,7 @@ jobs:
166
166
  run: node .github/workflows/ensure-dts-export.js
167
167
 
168
168
  - name: Publish package
169
- run: pnpm publish --no-git-checks`}function Y(){return`name: Discord release webhook
169
+ run: pnpm publish --no-git-checks`}function J(){return`name: Discord release webhook
170
170
 
171
171
  on:
172
172
  release:
@@ -193,7 +193,7 @@ jobs:
193
193
  -H "Content-Type: application/json" \\
194
194
  -d "$payload" \\
195
195
  "$WEBHOOK_URL"
196
- `}function X(){return`import { existsSync, readFileSync, writeFileSync } from "node:fs";
196
+ `}function Y(){return`import { existsSync, readFileSync, writeFileSync } from "node:fs";
197
197
 
198
198
  const filePath = "dist/main.d.ts";
199
199
 
@@ -212,14 +212,14 @@ if (!hasFooter) {
212
212
  } else {
213
213
  console.log("dist/main.d.ts already ends with export {}");
214
214
  }
215
- `}function ne(e,t,n){return t?[`# ${e}`,``,`ScriptAPI addon template generated by scriptup.`,``,`## Local library structure`,``,`- package/main.ts: local package source`,`- src/main.ts: sample usage that imports from ${n??`@scope/sample`}`,``,`## Setup`,``,"```bash",`npm install`,"```",``,`## Publish`,``,`### First publish (manual)`,``,`1. Update \`name\` and \`version\` in package.json (current import alias: \`${n??`@scope/sample`}\`).`,`2. Build and publish:`,``,"```bash",`npm run build`,`npm publish --access public`,"```",``,`### Subsequent publishes (automated via GitHub Actions)`,``,`> [!TIP]`,"> Using [npm Trusted Publishers](https://docs.npmjs.com/trusted-publishers#configuring-trusted-publishing) removes the need to manage `NPM_TOKEN` in GitHub secrets.",``,`1. On [npmjs.com](https://www.npmjs.com), open your package → **Settings** → **Trusted Publishers**.`,`2. Add a trusted publisher:`,` - **GitHub Actions** as the provider`,` - Organization or user: Enter your GitHub username or organization name`,` - Repository: Enter the repository name where the package is located`," - Workflow filename: `publish.yml`",` - Environment name: Keep empty`,``,"3. Once configured, **delete** the `NPM_TOKEN` secret from GitHub repository settings (not needed anymore).",``,"4. Bump `version` in package.json, then create a GitHub release → **.github/workflows/publish.yml** runs automatically.",``].join(`
215
+ `}function X(e,t,n){return t?[`# ${e}`,``,`ScriptAPI addon template generated by scriptup.`,``,`## Local library structure`,``,`- package/main.ts: local package source`,`- src/main.ts: sample usage that imports from ${n??`@scope/sample`}`,``,`## Setup`,``,"```bash",`npm install`,"```",``,`## Publish`,``,`### First publish (manual)`,``,`1. Update \`name\` and \`version\` in package.json (current import alias: \`${n??`@scope/sample`}\`).`,`2. Build and publish:`,``,"```bash",`npm run build`,`npm publish --access public`,"```",``,`### Subsequent publishes (automated via GitHub Actions)`,``,`> [!TIP]`,"> Using [npm Trusted Publishers](https://docs.npmjs.com/trusted-publishers#configuring-trusted-publishing) removes the need to manage `NPM_TOKEN` in GitHub secrets.",``,`1. On [npmjs.com](https://www.npmjs.com), open your package → **Settings** → **Trusted Publishers**.`,`2. Add a trusted publisher:`,` - **GitHub Actions** as the provider`,` - Organization or user: Enter your GitHub username or organization name`,` - Repository: Enter the repository name where the package is located`," - Workflow filename: `publish.yml`",` - Environment name: Keep empty`,``,"3. Once configured, **delete** the `NPM_TOKEN` secret from GitHub repository settings (not needed anymore).",``,"4. Bump `version` in package.json, then create a GitHub release → **.github/workflows/publish.yml** runs automatically.",``].join(`
216
216
  `):[`# ${e}`,``,`ScriptAPI addon template generated by scriptup.`,``,`## Setup`,``,"```bash",`npm install`,"```",``].join(`
217
- `)}function Z(){return[`import { world } from "@minecraft/server";`,``,`world.afterEvents.worldLoad.subscribe(() => {`,` console.log("Hello world!");`,`});`,``].join(`
218
- `)}function re(e){return[`import { world } from "@minecraft/server";`,`import { sum } from "${e}";`,``,`world.afterEvents.worldLoad.subscribe(() => {`,` const result = sum(1, 2);`," console.log(`sum(1, 2) = ${result}`);",`});`,``].join(`
219
- `)}function ie(){return[`export function sum(a: number, b: number): number {`,` return a + b;`,`}`,``].join(`
220
- `)}function ae(e){let t=e.trim();return t.length>0?t:`@scope/sample`}function oe(){let e=new Date().getFullYear(),t=`{{author}}`;try{let e=s(`git`,[`config`,`user.name`],{encoding:`utf-8`,shell:!0});if(e.status===0){let n=e.stdout.trim();n&&(t=n)}}catch(e){h(`Failed to get git user.name: ${e instanceof Error?e.message:String(e)}`),h(`Using placeholder author name in LICENSE.`)}return`MIT License
217
+ `)}function ie(){return[`import { world } from "@minecraft/server";`,``,`world.afterEvents.worldLoad.subscribe(() => {`,` console.log("Hello world!");`,`});`,``].join(`
218
+ `)}function ae(e){return[`import { world } from "@minecraft/server";`,`import { sum } from "${e}";`,``,`world.afterEvents.worldLoad.subscribe(() => {`,` const result = sum(1, 2);`," console.log(`sum(1, 2) = ${result}`);",`});`,``].join(`
219
+ `)}function oe(){return[`export function sum(a: number, b: number): number {`,` return a + b;`,`}`,``].join(`
220
+ `)}function se(e){let t=e.trim();return t.length>0?t:`@scope/sample`}function ce(){return`MIT License
221
221
 
222
- Copyright (c) ${e} ${t}
222
+ Copyright (c) ${new Date().getFullYear()} ${F()||`{{author}}`}
223
223
 
224
224
  Permission is hereby granted, free of charge, to any person obtaining a copy
225
225
  of this software and associated documentation files (the "Software"), to deal
@@ -237,6 +237,6 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
237
237
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
238
238
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
239
239
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
240
- SOFTWARE.`}function se(e){return e.trim().toLowerCase().replace(/[^a-z0-9-_\s]/g,``).replace(/\s+/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``)||`scriptapi-addon`}async function ce(e=process.cwd(),t={}){let n=i.resolve(e);await L({targetDir:n,lib:t.lib,workflow:t.workflow}),le(n),ue(n),de(n),p(`Initialization complete.`)}function le(e){let t=i.join(e,`tsdown.config.ts`);if(!r.existsSync(t)){let e=[`import { defineConfig } from "tsdown";`,``,`export default defineConfig(/* */);`,``].join(`
241
- `);r.writeFileSync(t,e,`utf-8`),m(`Created tsdown.config.ts`);return}let n=r.readFileSync(t,`utf-8`),a=n.replace(/defineConfig\({([^;]*)}\);/s,(e,t)=>{let n=t.trim();return n.length===0?`defineConfig({ /* */ });`:`defineConfig({\n /* ${n} */\n});`});if(a===n){h(`Could not find defineConfig(...) in tsdown.config.ts. File was left unchanged.`);return}r.writeFileSync(t,a,`utf-8`),m(`Updated tsdown.config.ts`)}function ue(e){let t=i.join(e,`package.json`),n=JSON.parse(r.readFileSync(t,`utf-8`));n.scripts??={},n.scripts.build=`scriptup build --release`,n.scripts.watch=`scriptup build --watch`,r.writeFileSync(t,JSON.stringify(n,null,2)+`
242
- `,`utf-8`),m(`Updated package.json scripts: build, watch`)}function de(e){let t=process.cwd();try{process.chdir(e),o(fe(T(),[`@nano191225/scriptup`,`tsdown`,`typescript`,`@bedrock-apis/env-types`]),{stdio:`inherit`,cwd:e}),m(`Installed required dev dependencies`)}catch(e){g(`Failed to install dependencies: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}finally{process.chdir(t)}}function fe(e,t){let n=t.join(` `);switch(e){case`npm`:return`npm install --save-dev ${n}`;case`pnpm`:return`pnpm add --save-dev ${n}`;case`yarn`:return`yarn add --dev ${n}`;case`bun`:return`bun add --save-dev ${n}`}}const pe=[`code`,`code-insiders`];async function me(e,t){let n=ge(t.preview),r=he(e),a=Q(r,t,n);if(R(a),await L({targetDir:a,projectName:e,lib:t.lib,workflow:t.workflow}),t.dir&&t.link!==!1&&_e(a,i.join(n,r)),t.open){if(!pe.includes(t.open))return g(`Unsupported editor: ${t.open}`);p(`Opening project with ${t.open}...`);try{z(a,t.open)}catch(e){g(`Failed to open project: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}}}function Q(e,t,n){return t.dir?i.resolve(t.dir,e):i.join(n,e)}function he(e){let t=e.trim().replace(/[\\/]+/g,`$`).replace(/[^A-Za-z0-9@$-_.]/g,``);return t.length===0&&(g(`Project name is empty after sanitizing. Use at least one of A-Z, a-z, 0-9, @, $, -, _, or .`),process.exit(1)),t}function ge(e=!1){if(process.platform===`win32`){let t=process.env.APPDATA;t||(g(`APPDATA is not available. Use --dir to specify the destination manually.`),process.exit(1));let n=e?`Minecraft Bedrock Preview`:`Minecraft Bedrock`;return i.join(t,n,`Users`,`Shared`,`games`,`com.mojang`,`development_behavior_packs`)}let t=process.env.XDG_DATA_HOME??i.join(l.homedir(),`.local`,`share`);return i.join(t,`mcpelauncher`,`games`,`com.mojang`,`development_behavior_packs`)}function _e(e,t){let n=i.resolve(e),a=i.resolve(t);if(n===a)return;if(r.mkdirSync(i.dirname(a),{recursive:!0}),r.existsSync(a)){h(`Link path already exists, skipping link creation: ${a}`);return}let o=process.platform===`win32`?`junction`:`dir`;r.symlinkSync(n,a,o),m(`Linked behavior pack: ${a} -> ${n}`)}async function ve(e={}){let t=b().modules?.filter(v).find(e=>typeof e.entry==`string`&&e.entry.length>0);t?.entry||(g(`No script module entry found in manifest.json.`),process.exit(1));let n=await Se(i.resolve(`tsdown.config.ts`)),r=be(n);r||(g(`Source entry not found. Expected src/main.ts, src/index.ts, or tsdown.config.ts entry.`),process.exit(1));let a=i.resolve(t.entry),o=i.dirname(a),s=e.bundle===!0,c=e.watch===!0,l=e.release===!0,f=d({config:!1,entry:i.relative(process.cwd(),r),outDir:i.relative(process.cwd(),o),format:`esm`,target:`es2024`,platform:`neutral`,sourcemap:!l,clean:!c,tsconfig:i.relative(process.cwd(),i.resolve(`tsconfig.json`)),outExtensions:()=>({js:`.js`}),deps:{neverBundle:/^@minecraft\/(?!math(?:\/|$)|vanilla-data(?:\/|$))/,alwaysBundle:`**/*`,onlyBundle:!1},unbundle:!l&&!s,watch:c,minify:l},n);p(`Bundling addon scripts with tsdown...`);try{await u(f),l&&await Ce()}catch(e){g(e instanceof Error?e.message:String(e)),process.exit(1)}c||ye(a),_(`Build complete: ${i.relative(process.cwd(),a)}`)}function ye(e){r.existsSync(e)||(g(`Expected build output was not found: ${e}`),process.exit(1))}function be(e){let t=i.resolve(`src/main.ts`);if(r.existsSync(t))return t;let n=i.resolve(`src/index.ts`);if(r.existsSync(n))return n;let a=xe(e.entry);if(!a)return null;let o=i.resolve(a);return r.existsSync(o)?o:null}function xe(e){return typeof e==`string`?e:Array.isArray(e)&&typeof e[0]==`string`?e[0]:null}async function Se(e){if(!r.existsSync(e))return{};let t=r.readFileSync(e,`utf-8`);if(!t.includes(`export default`)||!t.includes(`defineConfig`))return h(`tsdown.config.ts was found but could not be parsed. Using internal build defaults.`),{};try{let t=(await import(f(e).href)).default;return!t||typeof t!=`object`||Array.isArray(t)?(h(`tsdown.config.ts should export a single config object. Using internal build defaults.`),{}):t}catch(e){return h(`Failed to import tsdown.config.ts: ${e instanceof Error?e.message:String(e)}`),h(`Using internal build defaults.`),{}}}async function Ce(){let e=we(i.resolve(`package`));e.length!==0&&(p(`Building local package sources into dist/... `),await u({config:!1,entry:e.map(e=>i.relative(process.cwd(),e)),outDir:i.relative(process.cwd(),i.resolve(`dist`)),format:`esm`,target:`es2024`,platform:`neutral`,clean:!0,tsconfig:i.relative(process.cwd(),i.resolve(`tsconfig.json`)),outExtensions:()=>({js:`.js`}),unbundle:!0,dts:!0,deps:{neverBundle:/^@minecraft\/(?!math(?:\/|$)|vanilla-data(?:\/|$))/}}))}function we(e){if(!r.existsSync(e))return[];let t=[],n=[e];for(;n.length>0;){let e=n.pop();if(!e)continue;let a=r.readdirSync(e,{withFileTypes:!0});for(let r of a){if(r.name===`node_modules`||r.name.startsWith(`.`))continue;let a=i.join(e,r.name);if(r.isDirectory()){n.push(a);continue}r.isFile()&&a.endsWith(`.ts`)&&!a.endsWith(`.d.ts`)&&t.push(a)}}return t.sort()}const $=new e;$.name(`scriptup`).description(`ScriptAPI version updater for Minecraft Bedrock`).version(I).argument(`[version]`,`Manually specify a version to look up`),$.command(`stable`).description(`Install the latest stable version modules`).action(async()=>{await k()}),$.command(`preview`).description(`Install the latest preview version modules`).action(async()=>{await j()}),$.command(`lts`).description(`Install the latest LTS version modules`).action(async()=>{await N()}),$.command(`build`).description(`Bundle the current ScriptAPI project with tsdown`).option(`-b, --bundle`,`Bundle the output into a single file`).option(`-w, --watch`,`Build in watch mode`).option(`-r, --release`,`Build for release (minified, sourcemap off)`).action(async e=>{await ve(e)}),$.command(`init`).description(`Initialize a ScriptAPI project in the current directory`).option(`--lib`,`Include local library scaffolding under package/`).option(`--no-workflow`,`Do not create the GitHub Actions workflow files`).action(async e=>{await ce(void 0,e)}),$.command(`new`).description(`Create a new ScriptAPI project`).argument(`<project-name>`,`Directory name for the new project`).addOption(new t(`-o, --open [command]`,`Open the project after creation`).preset(`code`)).option(`-p, --preview`,`Create the project in the Minecraft Bedrock Preview behavior packs directory`).option(`-d, --dir <path>`,`Create the project under a specific directory`).option(`--lib`,`Include local library scaffolding under package/`).option(`--no-link`,`Do not create a link in the behavior packs directory when --dir is used`).option(`--no-workflow`,`Do not create the GitHub Actions workflow files`).action(async(e,t)=>{await me(e,t)}),$.action(async e=>{e?await F(e):$.help()}),$.parse();export{};
240
+ SOFTWARE.`}function le(e){return e.trim().toLowerCase().replace(/[^a-z0-9-@\/_\s]/g,``).replace(/\s+/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``)||`scriptapi-addon`}async function ue(e=process.cwd(),t={}){let n=i.resolve(e);await I({targetDir:n,lib:t.lib,workflow:t.workflow}),de(n),fe(n),pe(n),p(`Initialization complete.`)}function de(e){let t=i.join(e,`tsdown.config.ts`);if(!r.existsSync(t)){let e=[`import { defineConfig } from "tsdown";`,``,`export default defineConfig(/* */);`,``].join(`
241
+ `);r.writeFileSync(t,e,`utf-8`),m(`Created tsdown.config.ts`);return}let n=r.readFileSync(t,`utf-8`),a=n.replace(/defineConfig\({([^;]*)}\);/s,(e,t)=>{let n=t.trim();return n.length===0?`defineConfig({ /* */ });`:`defineConfig({\n /* ${n} */\n});`});if(a===n){h(`Could not find defineConfig(...) in tsdown.config.ts. File was left unchanged.`);return}r.writeFileSync(t,a,`utf-8`),m(`Updated tsdown.config.ts`)}function fe(e){let t=i.join(e,`package.json`),n=JSON.parse(r.readFileSync(t,`utf-8`));n.scripts??={},n.scripts.build=`scriptup build --release`,n.scripts.watch=`scriptup build --watch`,r.writeFileSync(t,JSON.stringify(n,null,2)+`
242
+ `,`utf-8`),m(`Updated package.json scripts: build, watch`)}function pe(e){let t=process.cwd();try{process.chdir(e),o(me(w(),[`@nano191225/scriptup`,`tsdown`,`typescript`,`@bedrock-apis/env-types`]),{stdio:`inherit`,cwd:e}),m(`Installed required dev dependencies`)}catch(e){g(`Failed to install dependencies: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}finally{process.chdir(t)}}function me(e,t){let n=t.join(` `);switch(e){case`npm`:return`npm install --save-dev ${n}`;case`pnpm`:return`pnpm add --save-dev ${n}`;case`yarn`:return`yarn add --dev ${n}`;case`bun`:return`bun add --save-dev ${n}`}}const he=[`code`,`code-insiders`];async function Z(e,t){let n=ve(t.preview),r=_e(e),a=ge(r,t,n);if(L(a),await I({targetDir:a,projectName:e,directoryName:r,lib:t.lib,workflow:t.workflow}),t.dir&&t.link!==!1&&ye(a,i.join(n,r)),t.open){if(!he.includes(t.open))return g(`Unsupported editor: ${t.open}`);p(`Opening project with ${t.open}...`);try{R(a,t.open)}catch(e){g(`Failed to open project: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}}}function ge(e,t,n){return t.dir?i.resolve(t.dir,e):i.join(n,e)}function _e(e){let t=e.trim().replace(/[\\/]+/g,`-`).replace(/[^A-Za-z0-9-_]/g,``);return t.length===0&&(g(`Project name is empty after sanitizing. Use at least one of A-Z, a-z, 0-9, -, or _.`),process.exit(1)),t}function ve(e=!1){if(process.platform===`win32`){let t=process.env.APPDATA;t||(g(`APPDATA is not available. Use --dir to specify the destination manually.`),process.exit(1));let n=e?`Minecraft Bedrock Preview`:`Minecraft Bedrock`;return i.join(t,n,`Users`,`Shared`,`games`,`com.mojang`,`development_behavior_packs`)}let t=process.env.XDG_DATA_HOME??i.join(l.homedir(),`.local`,`share`);return i.join(t,`mcpelauncher`,`games`,`com.mojang`,`development_behavior_packs`)}function ye(e,t){let n=i.resolve(e),a=i.resolve(t);if(n===a)return;if(r.mkdirSync(i.dirname(a),{recursive:!0}),r.existsSync(a)){h(`Link path already exists, skipping link creation: ${a}`);return}let o=process.platform===`win32`?`junction`:`dir`;r.symlinkSync(n,a,o),m(`Linked behavior pack: ${a} -> ${n}`)}async function be(e={}){let t=y().modules?.filter(ee).find(e=>typeof e.entry==`string`&&e.entry.length>0);t?.entry||(g(`No script module entry found in manifest.json.`),process.exit(1));let n=await Ce(i.resolve(`tsdown.config.ts`)),r=Q(`src`,n);r||(g(`Source entry not found. Expected src/main.ts, src/index.ts, or tsdown.config.ts entry.`),process.exit(1));let a=i.resolve(t.entry),o=i.dirname(a),s=e.bundle===!0,c=e.watch===!0,l=e.release===!0,f=d({config:!1,entry:i.relative(process.cwd(),r),outDir:i.relative(process.cwd(),o),format:`esm`,target:`es2024`,platform:`neutral`,sourcemap:!l,clean:!c,tsconfig:i.relative(process.cwd(),i.resolve(`tsconfig.json`)),outExtensions:()=>({js:`.js`}),deps:{neverBundle:/^@minecraft\/(?!math(?:\/|$)|vanilla-data(?:\/|$))/,alwaysBundle:`**/*`,onlyBundle:!1},unbundle:!l&&!s,watch:c,minify:l},n);p(`Bundling addon scripts with tsdown...`);try{await u(f),l&&await we()}catch(e){g(e instanceof Error?e.message:String(e)),process.exit(1)}c||xe(a),_(`Build complete: ${i.relative(process.cwd(),a)}`)}function xe(e){r.existsSync(e)||(g(`Expected build output was not found: ${e}`),process.exit(1))}function Q(e,t){let n=i.resolve(e,`main.ts`);if(r.existsSync(n))return n;let a=i.resolve(e,`index.ts`);if(r.existsSync(a))return a;if(!t)return null;let o=Se(t.entry);if(!o)return null;let s=i.resolve(o);return r.existsSync(s)?s:null}function Se(e){return typeof e==`string`?e:Array.isArray(e)&&typeof e[0]==`string`?e[0]:null}async function Ce(e){if(!r.existsSync(e))return{};let t=r.readFileSync(e,`utf-8`);if(!t.includes(`export default`)||!t.includes(`defineConfig`))return h(`tsdown.config.ts was found but could not be parsed. Using internal build defaults.`),{};try{let t=(await import(f(e).href)).default;return!t||typeof t!=`object`||Array.isArray(t)?(h(`tsdown.config.ts should export a single config object. Using internal build defaults.`),{}):t}catch(e){return h(`Failed to import tsdown.config.ts: ${e instanceof Error?e.message:String(e)}`),h(`Using internal build defaults.`),{}}}async function we(){let e=Q(`package`);e&&(p(`Building local package sources into dist/... `),await u({config:!1,entry:i.relative(process.cwd(),e),outDir:i.relative(process.cwd(),i.resolve(`dist`)),format:`esm`,target:`es2024`,platform:`neutral`,clean:!0,tsconfig:i.relative(process.cwd(),i.resolve(`tsconfig.json`)),outExtensions:()=>({js:`.js`}),dts:!0,unbundle:!1,deps:{}}))}const $=new e;$.name(`scriptup`).description(`ScriptAPI version updater for Minecraft Bedrock`).version(P).argument(`[version]`,`Manually specify a version to look up`),$.command(`stable`).description(`Install the latest stable version modules`).action(async()=>{await re()}),$.command(`preview`).description(`Install the latest preview version modules`).action(async()=>{await k()}),$.command(`lts`).description(`Install the latest LTS version modules`).action(async()=>{await j()}),$.command(`build`).description(`Bundle the current ScriptAPI project with tsdown`).option(`-b, --bundle`,`Bundle the output into a single file`).option(`-w, --watch`,`Build in watch mode`).option(`-r, --release`,`Build for release (minified, sourcemap off)`).action(async e=>{await be(e)}),$.command(`init`).description(`Initialize a ScriptAPI project in the current directory`).option(`--lib`,`Include local library scaffolding under package/`).option(`--no-workflow`,`Do not create the GitHub Actions workflow files`).action(async e=>{await ue(void 0,e)}),$.command(`new`).description(`Create a new ScriptAPI project`).argument(`<project-name>`,`Directory name for the new project`).addOption(new t(`-o, --open [command]`,`Open the project after creation`).preset(`code`)).option(`-p, --preview`,`Create the project in the Minecraft Bedrock Preview behavior packs directory`).option(`-d, --dir <path>`,`Create the project under a specific directory`).option(`--lib`,`Include local library scaffolding under package/`).option(`--no-link`,`Do not create a link in the behavior packs directory when --dir is used`).option(`--no-workflow`,`Do not create the GitHub Actions workflow files`).action(async(e,t)=>{await Z(e,t)}),$.action(async e=>{e?await N(e):$.help()}),$.parse();export{};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nano191225/scriptup",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "ScriptAPI version updater for Minecraft Bedrock",
5
5
  "license": "MIT",
6
6
  "author": "Nano191225",