@nano191225/scriptup 1.0.0 → 1.2.0
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/LICENSE +21 -0
- package/README.ja.md +182 -0
- package/README.md +182 -0
- package/dist/index.js +241 -39
- package/package.json +48 -46
- package/dist/commands/lts.d.ts +0 -1
- package/dist/commands/lts.js +0 -59
- package/dist/commands/lts.js.map +0 -1
- package/dist/commands/manual.d.ts +0 -1
- package/dist/commands/manual.js +0 -28
- package/dist/commands/manual.js.map +0 -1
- package/dist/commands/preview.d.ts +0 -1
- package/dist/commands/preview.js +0 -51
- package/dist/commands/preview.js.map +0 -1
- package/dist/commands/stable.d.ts +0 -1
- package/dist/commands/stable.js +0 -51
- package/dist/commands/stable.js.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js.map +0 -1
- package/dist/utils/logger.d.ts +0 -5
- package/dist/utils/logger.js +0 -17
- package/dist/utils/logger.js.map +0 -1
- package/dist/utils/manifest.d.ts +0 -28
- package/dist/utils/manifest.js +0 -18
- package/dist/utils/manifest.js.map +0 -1
- package/dist/utils/package-manager.d.ts +0 -3
- package/dist/utils/package-manager.js +0 -81
- package/dist/utils/package-manager.js.map +0 -1
- package/dist/utils/packageManager.d.ts +0 -3
- package/dist/utils/packageManager.js +0 -81
- package/dist/utils/packageManager.js.map +0 -1
- package/dist/utils/versions.d.ts +0 -6
- package/dist/utils/versions.js +0 -44
- package/dist/utils/versions.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,40 +1,242 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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.2.0`;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/
|
|
3
|
+
scripts
|
|
4
|
+
dist
|
|
5
|
+
*.mcpack
|
|
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)+`
|
|
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
|
|
14
|
+
on:
|
|
15
|
+
release:
|
|
16
|
+
types: [published]
|
|
17
|
+
|
|
18
|
+
permissions:
|
|
19
|
+
contents: write
|
|
20
|
+
|
|
21
|
+
jobs:
|
|
22
|
+
build:
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v4
|
|
26
|
+
|
|
27
|
+
##############################
|
|
28
|
+
|
|
29
|
+
### When selected package manager, uncomment below.
|
|
30
|
+
|
|
31
|
+
- name: You have to select a package manager.
|
|
32
|
+
run: exit 1
|
|
33
|
+
|
|
34
|
+
### pnpm ###
|
|
35
|
+
|
|
36
|
+
# - name: Install pnpm
|
|
37
|
+
# uses: pnpm/action-setup@v4
|
|
38
|
+
# with:
|
|
39
|
+
# version: 10
|
|
40
|
+
|
|
41
|
+
# - name: Use Node.js 24
|
|
42
|
+
# uses: actions/setup-node@v4
|
|
43
|
+
# with:
|
|
44
|
+
# node-version: "24"
|
|
45
|
+
# cache: "pnpm"
|
|
46
|
+
|
|
47
|
+
# - name: Install dependencies
|
|
48
|
+
# run: |
|
|
49
|
+
# pnpm i --frozen-lockfile
|
|
50
|
+
|
|
51
|
+
# - name: Build
|
|
52
|
+
# run: pnpm run build
|
|
53
|
+
|
|
54
|
+
### npm ###
|
|
55
|
+
|
|
56
|
+
# - name: Use Node.js 24
|
|
57
|
+
# uses: actions/setup-node@v4
|
|
58
|
+
# with:
|
|
59
|
+
# node-version: "24"
|
|
60
|
+
# cache: "npm"
|
|
61
|
+
|
|
62
|
+
# - name: Install dependencies
|
|
63
|
+
# run: |
|
|
64
|
+
# npm ci
|
|
65
|
+
|
|
66
|
+
# - name: Build
|
|
67
|
+
# run: |
|
|
68
|
+
# npm run build
|
|
69
|
+
|
|
70
|
+
### bun ###
|
|
71
|
+
|
|
72
|
+
# - name: Use Node.js 24
|
|
73
|
+
# uses: actions/setup-node@v4
|
|
74
|
+
# with:
|
|
75
|
+
# node-version: "24"
|
|
76
|
+
|
|
77
|
+
# - name: Install Bun
|
|
78
|
+
# uses: oven-sh/setup-bun@v2
|
|
79
|
+
|
|
80
|
+
# - name: Install dependencies
|
|
81
|
+
# run: |
|
|
82
|
+
# bun i --frozen-lockfile
|
|
83
|
+
|
|
84
|
+
# - name: Build
|
|
85
|
+
# run: |
|
|
86
|
+
# bun run build
|
|
87
|
+
|
|
88
|
+
### yarn ###
|
|
89
|
+
|
|
90
|
+
# - name: Use Node.js 24
|
|
91
|
+
# uses: actions/setup-node@v4
|
|
92
|
+
# with:
|
|
93
|
+
# node-version: "24"
|
|
94
|
+
# cache: "yarn"
|
|
95
|
+
|
|
96
|
+
# - name: Install dependencies
|
|
97
|
+
# uses: borales/actions-yarn@v4
|
|
98
|
+
# with:
|
|
99
|
+
# cmd: install
|
|
100
|
+
|
|
101
|
+
# - name: Build
|
|
102
|
+
# uses: borales/actions-yarn@v4
|
|
103
|
+
# with:
|
|
104
|
+
# cmd: build
|
|
105
|
+
|
|
106
|
+
##############################
|
|
107
|
+
|
|
108
|
+
- name: Get Pack Name
|
|
109
|
+
id: get-name
|
|
110
|
+
run: |
|
|
111
|
+
name=$(jq -r '.header.name' manifest.json | tr -d '"' | tr ' ' '_')
|
|
112
|
+
tag="$GITHUB_REF_NAME"
|
|
113
|
+
echo "fileName=$name-$tag" >> $GITHUB_OUTPUT
|
|
114
|
+
|
|
115
|
+
- name: Make Archive
|
|
116
|
+
run: |
|
|
117
|
+
echo "Creating archive: \${{ steps.get-name.outputs.fileName }}"
|
|
118
|
+
files="manifest.json scripts $(jq -r '.files[] | select(. != "manifest.json" and . != "scripts")' package.json | tr '\\n' ' ')"
|
|
119
|
+
zip -r "\${{ steps.get-name.outputs.fileName }}.mcpack" $files
|
|
120
|
+
cp "\${{ steps.get-name.outputs.fileName }}.mcpack" "\${{ steps.get-name.outputs.fileName }}.zip"
|
|
121
|
+
|
|
122
|
+
- name: Upload Release Asset
|
|
123
|
+
run: gh release upload "$GITHUB_REF_NAME" "\${{ steps.get-name.outputs.fileName }}.mcpack" "\${{ steps.get-name.outputs.fileName }}.zip" --clobber
|
|
124
|
+
env:
|
|
125
|
+
GITHUB_TOKEN: \${{ github.token }}`}function J(){return`name: Publish library
|
|
126
|
+
# Triggered when a GitHub release is published.
|
|
127
|
+
# Uses npm Trusted Publishers (OIDC) — no NPM_TOKEN secret required.
|
|
128
|
+
# See: https://docs.npmjs.com/trusted-publishers#configuring-trusted-publishing
|
|
129
|
+
|
|
130
|
+
on:
|
|
131
|
+
release:
|
|
132
|
+
types: [published]
|
|
133
|
+
|
|
134
|
+
permissions:
|
|
135
|
+
contents: read
|
|
136
|
+
id-token: write # required for OIDC trusted publishing and provenance
|
|
137
|
+
|
|
138
|
+
jobs:
|
|
139
|
+
publish:
|
|
140
|
+
runs-on: ubuntu-latest
|
|
141
|
+
timeout-minutes: 10
|
|
142
|
+
|
|
143
|
+
steps:
|
|
144
|
+
- name: Checkout
|
|
145
|
+
uses: actions/checkout@v4
|
|
146
|
+
|
|
147
|
+
- name: Install pnpm
|
|
148
|
+
uses: pnpm/action-setup@v4
|
|
149
|
+
with:
|
|
150
|
+
version: 10
|
|
151
|
+
|
|
152
|
+
- name: Use Node.js 24
|
|
153
|
+
uses: actions/setup-node@v4
|
|
154
|
+
with:
|
|
155
|
+
node-version: "24"
|
|
156
|
+
cache: "pnpm"
|
|
157
|
+
registry-url: "https://registry.npmjs.org"
|
|
158
|
+
|
|
159
|
+
- name: Install dependencies
|
|
160
|
+
run: pnpm i --frozen-lockfile
|
|
161
|
+
|
|
162
|
+
- name: Build
|
|
163
|
+
run: pnpm run build
|
|
164
|
+
|
|
165
|
+
- name: Ensure export footer in d.ts
|
|
166
|
+
run: node .github/workflows/ensure-dts-export.js
|
|
167
|
+
|
|
168
|
+
- name: Publish package
|
|
169
|
+
run: pnpm publish --no-git-checks`}function Y(){return`name: Discord release webhook
|
|
170
|
+
|
|
171
|
+
on:
|
|
172
|
+
release:
|
|
173
|
+
types: [published]
|
|
174
|
+
|
|
175
|
+
permissions:
|
|
176
|
+
contents: read
|
|
177
|
+
|
|
178
|
+
jobs:
|
|
179
|
+
notify:
|
|
180
|
+
runs-on: ubuntu-latest
|
|
181
|
+
timeout-minutes: 5
|
|
182
|
+
|
|
183
|
+
steps:
|
|
184
|
+
- name: Post release message to Discord
|
|
185
|
+
env:
|
|
186
|
+
WEBHOOK_URL: \${{ secrets.WEBHOOK_URL }}
|
|
187
|
+
RELEASE_NAME: \${{ github.event.release.name }}
|
|
188
|
+
RELEASE_BODY: \${{ github.event.release.body }}
|
|
189
|
+
RELEASE_URL: \${{ github.event.release.html_url }}
|
|
190
|
+
run: |
|
|
191
|
+
payload=$(jq -n --arg name "$RELEASE_NAME" --arg body "$RELEASE_BODY" --arg url "$RELEASE_URL" '{content: ("## " + $name + "\\n" + $body + "\\n\\n" + $url)}')
|
|
192
|
+
curl -sS -X POST \\
|
|
193
|
+
-H "Content-Type: application/json" \\
|
|
194
|
+
-d "$payload" \\
|
|
195
|
+
"$WEBHOOK_URL"
|
|
196
|
+
`}function X(){return`import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
197
|
+
|
|
198
|
+
const filePath = "dist/main.d.ts";
|
|
199
|
+
|
|
200
|
+
if (!existsSync(filePath)) {
|
|
201
|
+
throw new Error(\`Missing file: \${filePath}\`);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
let content = readFileSync(filePath, "utf8");
|
|
205
|
+
const hasFooter = /\\bexport\\s*\\{\\s*\\};?\\s*$/.test(content);
|
|
206
|
+
|
|
207
|
+
if (!hasFooter) {
|
|
208
|
+
if (!content.endsWith("\\n")) content += "\\n";
|
|
209
|
+
content += "export {};\\n";
|
|
210
|
+
writeFileSync(filePath, content);
|
|
211
|
+
console.log("Appended export {} to dist/main.d.ts");
|
|
212
|
+
} else {
|
|
213
|
+
console.log("dist/main.d.ts already ends with export {}");
|
|
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(`
|
|
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
|
|
221
|
+
|
|
222
|
+
Copyright (c) ${e} ${t}
|
|
223
|
+
|
|
224
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
225
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
226
|
+
in the Software without restriction, including without limitation the rights
|
|
227
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
228
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
229
|
+
furnished to do so, subject to the following conditions:
|
|
230
|
+
|
|
231
|
+
The above copyright notice and this permission notice shall be included in all
|
|
232
|
+
copies or substantial portions of the Software.
|
|
233
|
+
|
|
234
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
235
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
236
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
237
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
238
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
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,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(`--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{};
|
package/package.json
CHANGED
|
@@ -1,46 +1,48 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"
|
|
46
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@nano191225/scriptup",
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "ScriptAPI version updater for Minecraft Bedrock",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Nano191225",
|
|
7
|
+
"homepage": "https://github.com/Nano191225/scriptup#readme",
|
|
8
|
+
"repository": "https://github.com/Nano191225/scriptup.git",
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/Nano191225/scriptup/issues"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"minecraft",
|
|
14
|
+
"minecraft-bedrock",
|
|
15
|
+
"minecraft-script-api",
|
|
16
|
+
"scriptapi"
|
|
17
|
+
],
|
|
18
|
+
"type": "module",
|
|
19
|
+
"main": "dist/index.js",
|
|
20
|
+
"bin": {
|
|
21
|
+
"scriptup": "dist/index.js",
|
|
22
|
+
"sup": "dist/index.js"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=18.0.0"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public",
|
|
32
|
+
"registry": "https://registry.npmjs.org"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"chalk": "^5.4.1",
|
|
36
|
+
"commander": "^13.1.0",
|
|
37
|
+
"ora": "^8.2.0",
|
|
38
|
+
"tsdown": "^0.21.2"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/node": "^22.13.0",
|
|
42
|
+
"typescript": "^5.7.0"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsdown",
|
|
46
|
+
"dev": "tsdown --watch"
|
|
47
|
+
}
|
|
48
|
+
}
|
package/dist/commands/lts.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function lts(): Promise<void>;
|
package/dist/commands/lts.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import ora from "ora";
|
|
2
|
-
import { getManifest, updateManifest } from "../utils/manifest.js";
|
|
3
|
-
import { getVersions, extractMcVersion } from "../utils/versions.js";
|
|
4
|
-
import { detectPackageManager, installPackage } from "../utils/package-manager.js";
|
|
5
|
-
import * as logger from "../utils/logger.js";
|
|
6
|
-
export async function lts() {
|
|
7
|
-
const spinner = ora("Fetching Minecraft version...").start();
|
|
8
|
-
const mcVersion = await getStableMinecraftVersion();
|
|
9
|
-
spinner.succeed(`Install modules for Minecraft version: ${mcVersion}`);
|
|
10
|
-
const manifest = getManifest();
|
|
11
|
-
logger.log("Manifest loaded. Fetching new module versions...");
|
|
12
|
-
const pm = detectPackageManager();
|
|
13
|
-
const modules = [];
|
|
14
|
-
for (const dependency of manifest.dependencies) {
|
|
15
|
-
const versions = await getVersions(dependency.module_name);
|
|
16
|
-
// LTS: non-stable, non-preview, non-internal, non-beta, non-0.x
|
|
17
|
-
let matched = versions.find((v) => !v.includes("stable") && !v.includes("preview") && !v.includes("internal") && !v.includes("beta") && !v.startsWith("0."));
|
|
18
|
-
if (matched) {
|
|
19
|
-
dependency.version = matched;
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
logger.warn(`No LTS versions found for ${dependency.module_name}. Falling back to stable.`);
|
|
23
|
-
matched = versions.find((v) => v.includes(mcVersion));
|
|
24
|
-
if (!matched) {
|
|
25
|
-
logger.error(`No version found for ${dependency.module_name}`);
|
|
26
|
-
process.exit(1);
|
|
27
|
-
}
|
|
28
|
-
dependency.version = extractMcVersion(matched);
|
|
29
|
-
}
|
|
30
|
-
logger.log(`${dependency.module_name}: ${matched}`);
|
|
31
|
-
modules.push({ name: dependency.module_name, version: matched });
|
|
32
|
-
}
|
|
33
|
-
updateManifest(manifest);
|
|
34
|
-
logger.log("Module versions fetched and manifest updated.");
|
|
35
|
-
const installSpinner = ora("Installing modules...").start();
|
|
36
|
-
for (let i = 0; i < modules.length; i++) {
|
|
37
|
-
const mod = modules[i];
|
|
38
|
-
installSpinner.text = `Installing modules... (${i + 1}/${modules.length}) ${mod.name}`;
|
|
39
|
-
try {
|
|
40
|
-
installPackage(pm, `${mod.name}@${mod.version}`);
|
|
41
|
-
}
|
|
42
|
-
catch (e) {
|
|
43
|
-
installSpinner.fail(`Failed to install ${mod.name}`);
|
|
44
|
-
logger.error(e instanceof Error ? e.message : String(e));
|
|
45
|
-
process.exit(1);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
installSpinner.succeed("All modules installed successfully.");
|
|
49
|
-
}
|
|
50
|
-
async function getStableMinecraftVersion() {
|
|
51
|
-
const versions = await getVersions("@minecraft/server");
|
|
52
|
-
const version = versions.find((v) => v.includes("-stable"));
|
|
53
|
-
if (!version) {
|
|
54
|
-
logger.error("No stable versions found.");
|
|
55
|
-
process.exit(1);
|
|
56
|
-
}
|
|
57
|
-
return extractMcVersion(version);
|
|
58
|
-
}
|
|
59
|
-
//# sourceMappingURL=lts.js.map
|
package/dist/commands/lts.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lts.js","sourceRoot":"","sources":["../../src/commands/lts.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AACnF,OAAO,KAAK,MAAM,MAAM,oBAAoB,CAAC;AAE7C,MAAM,CAAC,KAAK,UAAU,GAAG;IACrB,MAAM,OAAO,GAAG,GAAG,CAAC,+BAA+B,CAAC,CAAC,KAAK,EAAE,CAAC;IAE7D,MAAM,SAAS,GAAG,MAAM,yBAAyB,EAAE,CAAC;IACpD,OAAO,CAAC,OAAO,CAAC,0CAA0C,SAAS,EAAE,CAAC,CAAC;IAEvE,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAC/B,MAAM,CAAC,GAAG,CAAC,kDAAkD,CAAC,CAAC;IAE/D,MAAM,EAAE,GAAG,oBAAoB,EAAE,CAAC;IAMlC,MAAM,OAAO,GAAiB,EAAE,CAAC;IAEjC,KAAK,MAAM,UAAU,IAAI,QAAQ,CAAC,YAAY,EAAE,CAAC;QAC7C,MAAM,QAAQ,GAAG,MAAM,WAAW,C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CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function manual(version: string): Promise<void>;
|
package/dist/commands/manual.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { getVersions, extractMcVersion } from "../utils/versions.js";
|
|
2
|
-
import * as logger from "../utils/logger.js";
|
|
3
|
-
export async function manual(version) {
|
|
4
|
-
const versions = await getVersions("@minecraft/server");
|
|
5
|
-
// Exact match
|
|
6
|
-
const exact = versions.find((v) => v === version);
|
|
7
|
-
if (exact) {
|
|
8
|
-
logger.info(`Found exact version: ${exact}`);
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
// Partial match
|
|
12
|
-
const partial = versions.find((v) => v.includes(version));
|
|
13
|
-
if (!partial) {
|
|
14
|
-
logger.error(`Version not found: ${version}`);
|
|
15
|
-
process.exit(1);
|
|
16
|
-
}
|
|
17
|
-
const mcVersion = extractMcVersion(partial);
|
|
18
|
-
logger.info(`Found version: ${mcVersion}`);
|
|
19
|
-
const serverVersions = await getVersions("@minecraft/server");
|
|
20
|
-
const server = serverVersions.find((v) => v.includes(mcVersion));
|
|
21
|
-
const serverUiVersions = await getVersions("@minecraft/server-ui");
|
|
22
|
-
const serverUi = serverUiVersions.find((v) => v.includes(mcVersion));
|
|
23
|
-
if (server)
|
|
24
|
-
logger.info(`Server version: ${server}`);
|
|
25
|
-
if (serverUi)
|
|
26
|
-
logger.info(`Server UI version: ${serverUi}`);
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=manual.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"manual.js","sourceRoot":"","sources":["../../src/commands/manual.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,KAAK,MAAM,MAAM,oBAAoB,CAAC;AAE7C,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAe;IACxC,MAAM,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AsB,QAAQ,EAAE,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function preview(): Promise<void>;
|
package/dist/commands/preview.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import ora from "ora";
|
|
2
|
-
import { getManifest, updateManifest } from "../utils/manifest.js";
|
|
3
|
-
import { getVersions, extractMcVersion, extractModuleVersion } from "../utils/versions.js";
|
|
4
|
-
import { detectPackageManager, installPackage } from "../utils/package-manager.js";
|
|
5
|
-
import * as logger from "../utils/logger.js";
|
|
6
|
-
export async function preview() {
|
|
7
|
-
const spinner = ora("Fetching Minecraft version...").start();
|
|
8
|
-
const mcVersion = await getPreviewMinecraftVersion();
|
|
9
|
-
spinner.succeed(`Install modules for Minecraft version: ${mcVersion}`);
|
|
10
|
-
const manifest = getManifest();
|
|
11
|
-
logger.log("Manifest loaded. Fetching new module versions...");
|
|
12
|
-
const pm = detectPackageManager();
|
|
13
|
-
const modules = [];
|
|
14
|
-
for (const dependency of manifest.dependencies) {
|
|
15
|
-
const versions = await getVersions(dependency.module_name);
|
|
16
|
-
const matched = versions.find((v) => v.includes(mcVersion));
|
|
17
|
-
if (!matched) {
|
|
18
|
-
logger.error(`No version found for ${dependency.module_name} matching MC ${mcVersion}`);
|
|
19
|
-
process.exit(1);
|
|
20
|
-
}
|
|
21
|
-
dependency.version = extractModuleVersion(matched);
|
|
22
|
-
logger.log(`${dependency.module_name}: ${matched}`);
|
|
23
|
-
modules.push({ name: dependency.module_name, version: matched });
|
|
24
|
-
}
|
|
25
|
-
updateManifest(manifest);
|
|
26
|
-
logger.log("Module versions fetched and manifest updated.");
|
|
27
|
-
const installSpinner = ora("Installing modules...").start();
|
|
28
|
-
for (let i = 0; i < modules.length; i++) {
|
|
29
|
-
const mod = modules[i];
|
|
30
|
-
installSpinner.text = `Installing modules... (${i + 1}/${modules.length}) ${mod.name}`;
|
|
31
|
-
try {
|
|
32
|
-
installPackage(pm, `${mod.name}@${mod.version}`);
|
|
33
|
-
}
|
|
34
|
-
catch (e) {
|
|
35
|
-
installSpinner.fail(`Failed to install ${mod.name}`);
|
|
36
|
-
logger.error(e instanceof Error ? e.message : String(e));
|
|
37
|
-
process.exit(1);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
installSpinner.succeed("All modules installed successfully.");
|
|
41
|
-
}
|
|
42
|
-
async function getPreviewMinecraftVersion() {
|
|
43
|
-
const versions = await getVersions("@minecraft/server");
|
|
44
|
-
const version = versions.find((v) => v.includes("-preview"));
|
|
45
|
-
if (!version) {
|
|
46
|
-
logger.error("No preview versions found.");
|
|
47
|
-
process.exit(1);
|
|
48
|
-
}
|
|
49
|
-
return extractMcVersion(version);
|
|
50
|
-
}
|
|
51
|
-
//# sourceMappingURL=preview.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"preview.js","sourceRoot":"","sources":["../../src/commands/preview.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC3F,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AACnF,OAAO,KAAK,MAAM,MAAM,oBAAoB,CAAC;AAE7C,MAAM,CAAC,KAAK,UAAU,OAAO;IACzB,MAAM,OAAO,GAAG,GAAG,CAAC,+BAA+B,CAAC,CAAC,KAAK,EAAE,CAAC;IAE7D,MAAM,SAAS,GAAG,MAAM,0BAA0B,EAAE,CAAC;IACrD,OAAO,CAAC,OAAO,CAAC,0CAA0C,SAAS,EAAE,CAAC,CAAC;IAEvE,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAC/B,MAAM,CAAC,GAAG,CAAC,kDAAkD,CAAC,CAAC;IAE/D,MAAM,EAAE,GAAG,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C;YACD,cAAc,CAAC,EAAE,EAAE,GAAG,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QACrD,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACT,cAAc,CAAC,IAAI,CAAC,qBAAqB,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;YACrD,MAAM,CAAC,KAAK,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YACzD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC;IACL,CAAC;IAED,cAAc,CAAC,OAAO,CAAC,qCAAqC,CAAC,CAAC;AAClE,CAAC;AAED,KAAK,UAAU,0BAA0B;IACrC,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,mBAAmB,CAAC,CAAC;IACxD,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;IAE7D,IAAI,CAAC,OAAO,EAAE,CAAC;QACX,MAAM,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAC3C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAED,OAAO,gBAAgB,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function stable(): Promise<void>;
|
package/dist/commands/stable.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import ora from "ora";
|
|
2
|
-
import { getManifest, updateManifest } from "../utils/manifest.js";
|
|
3
|
-
import { getVersions, extractMcVersion, extractModuleVersion } from "../utils/versions.js";
|
|
4
|
-
import { detectPackageManager, installPackage } from "../utils/package-manager.js";
|
|
5
|
-
import * as logger from "../utils/logger.js";
|
|
6
|
-
export async function stable() {
|
|
7
|
-
const spinner = ora("Fetching Minecraft version...").start();
|
|
8
|
-
const mcVersion = await getStableMinecraftVersion();
|
|
9
|
-
spinner.succeed(`Install modules for Minecraft version: ${mcVersion}`);
|
|
10
|
-
const manifest = getManifest();
|
|
11
|
-
logger.log("Manifest loaded. Fetching new module versions...");
|
|
12
|
-
const pm = detectPackageManager();
|
|
13
|
-
const modules = [];
|
|
14
|
-
for (const dependency of manifest.dependencies) {
|
|
15
|
-
const versions = await getVersions(dependency.module_name);
|
|
16
|
-
const matched = versions.find((v) => v.includes(mcVersion));
|
|
17
|
-
if (!matched) {
|
|
18
|
-
logger.error(`No version found for ${dependency.module_name} matching MC ${mcVersion}`);
|
|
19
|
-
process.exit(1);
|
|
20
|
-
}
|
|
21
|
-
dependency.version = extractModuleVersion(matched);
|
|
22
|
-
logger.log(`${dependency.module_name}: ${matched}`);
|
|
23
|
-
modules.push({ name: dependency.module_name, version: matched });
|
|
24
|
-
}
|
|
25
|
-
updateManifest(manifest);
|
|
26
|
-
logger.log("Module versions fetched and manifest updated.");
|
|
27
|
-
const installSpinner = ora("Installing modules...").start();
|
|
28
|
-
for (let i = 0; i < modules.length; i++) {
|
|
29
|
-
const mod = modules[i];
|
|
30
|
-
installSpinner.text = `Installing modules... (${i + 1}/${modules.length}) ${mod.name}`;
|
|
31
|
-
try {
|
|
32
|
-
installPackage(pm, `${mod.name}@${mod.version}`);
|
|
33
|
-
}
|
|
34
|
-
catch (e) {
|
|
35
|
-
installSpinner.fail(`Failed to install ${mod.name}`);
|
|
36
|
-
logger.error(e instanceof Error ? e.message : String(e));
|
|
37
|
-
process.exit(1);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
installSpinner.succeed("All modules installed successfully.");
|
|
41
|
-
}
|
|
42
|
-
async function getStableMinecraftVersion() {
|
|
43
|
-
const versions = await getVersions("@minecraft/server");
|
|
44
|
-
const version = versions.find((v) => v.includes("-stable"));
|
|
45
|
-
if (!version) {
|
|
46
|
-
logger.error("No stable versions found.");
|
|
47
|
-
process.exit(1);
|
|
48
|
-
}
|
|
49
|
-
return extractMcVersion(version);
|
|
50
|
-
}
|
|
51
|
-
//# sourceMappingURL=stable.js.map
|