@any-listen/extension-kit 0.1.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 +201 -0
- package/README.md +151 -0
- package/dist/bin.js +17 -0
- package/dist/bin.js.map +1 -0
- package/dist/build-CUKFiHZ-.js +142 -0
- package/dist/build-CUKFiHZ-.js.map +1 -0
- package/dist/publish-BUpufhVY.js +40 -0
- package/dist/publish-BUpufhVY.js.map +1 -0
- package/dist/utils-BN85b34y.js +92 -0
- package/dist/utils-BN85b34y.js.map +1 -0
- package/eslint/eslint.config.js +123 -0
- package/package.json +81 -0
- package/src/build.ts +17 -0
- package/src/constants.ts +8 -0
- package/src/cpResources.ts +16 -0
- package/src/index.ts +24 -0
- package/src/mainifest.ts +27 -0
- package/src/pack.ts +80 -0
- package/src/publish.ts +43 -0
- package/src/state.ts +10 -0
- package/src/types/build.d.ts +24 -0
- package/src/types/extension_config.d.ts +125 -0
- package/src/utils.ts +78 -0
- package/src/vite.config.ts +52 -0
- package/tsconfigs/tsconfig.app.json +9 -0
- package/tsconfigs/tsconfig.base.json +15 -0
- package/tsconfigs/tsconfig.isolate.json +18 -0
- package/tsconfigs/tsconfig.node.json +9 -0
- package/types/app/api.d.ts +1127 -0
- package/types/app/global.d.ts +10 -0
- package/types/app/index.d.ts +2 -0
- package/types/build.d.ts +1 -0
- package/types/isolate.d.ts +11 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# Any Listen Extension Kit
|
|
2
|
+
|
|
3
|
+
English | [简体中文](docs/README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
Any Listen extension kit for developing Any Listen extensions. It provides build tooling, type definitions, and shared configs to package extensions as `.alix` bundles.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Extension host API types
|
|
10
|
+
- Extension build and packaging (`.alix`)
|
|
11
|
+
- ESLint config preset
|
|
12
|
+
- TypeScript config presets
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add -D @any-listen/extension-kit
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
1) Project layout (example)
|
|
23
|
+
|
|
24
|
+
```text
|
|
25
|
+
your-extension/
|
|
26
|
+
src/
|
|
27
|
+
index.ts
|
|
28
|
+
resources/
|
|
29
|
+
i18n/
|
|
30
|
+
config.ts
|
|
31
|
+
.env
|
|
32
|
+
publish/
|
|
33
|
+
changeLog.md
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
2) Create `config.ts`
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import type { ExtensionConfig } from '@any-listen/extension-kit/config'
|
|
40
|
+
|
|
41
|
+
const config: ExtensionConfig = {
|
|
42
|
+
id: 'my_extension',
|
|
43
|
+
name: 'My Extension',
|
|
44
|
+
version: '1.0.0',
|
|
45
|
+
description: 'Example extension',
|
|
46
|
+
author: 'Your Name',
|
|
47
|
+
homepage: 'https://example.com',
|
|
48
|
+
license: 'MIT',
|
|
49
|
+
target_engine: 'any-listen',
|
|
50
|
+
categories: ['music'],
|
|
51
|
+
tags: ['example'],
|
|
52
|
+
grant: ['internet'],
|
|
53
|
+
contributes: {
|
|
54
|
+
resource: [
|
|
55
|
+
{
|
|
56
|
+
id: 'example',
|
|
57
|
+
name: 'Example Source',
|
|
58
|
+
resource: ['musicSearch', 'musicUrl'],
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
download_url_template: 'https://example.com/downloads/{version}',
|
|
63
|
+
buildConfig: {
|
|
64
|
+
srcDir: 'src',
|
|
65
|
+
distDir: 'dist',
|
|
66
|
+
outputDir: 'build',
|
|
67
|
+
i18nDir: 'i18n',
|
|
68
|
+
resourcesDir: 'resources',
|
|
69
|
+
isIsolateMode: false,
|
|
70
|
+
mainEntry: 'src/index.ts',
|
|
71
|
+
},
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export default config
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
3) Add `.env` for signing
|
|
78
|
+
|
|
79
|
+
```text
|
|
80
|
+
PRI_KEY=<base64-or-pem-single-line>
|
|
81
|
+
PUB_KEY=<base64-or-pem-single-line>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
4) Build
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
npx @any-listen/extension-kit --build
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The build produces:
|
|
91
|
+
|
|
92
|
+
- `dist/main.js`
|
|
93
|
+
- `dist/manifest.json`
|
|
94
|
+
- `dist/resources/*`
|
|
95
|
+
- `dist/i18n/*`
|
|
96
|
+
- `build/<id>_v<version>.alix`
|
|
97
|
+
|
|
98
|
+
## Publish Metadata
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
npx @any-listen/extension-kit --publish
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
This updates `publish/version.json` using `publish/changeLog.md` and `download_url_template`. It prevents publishing the same version twice.
|
|
105
|
+
|
|
106
|
+
## Build Config
|
|
107
|
+
|
|
108
|
+
`buildConfig` in `config.ts`:
|
|
109
|
+
|
|
110
|
+
- `srcDir`: Source directory (default `src`)
|
|
111
|
+
- `distDir`: Build output directory (default `dist`)
|
|
112
|
+
- `outputDir`: Package output directory (default `build`)
|
|
113
|
+
- `i18nDir`: i18n assets directory (default `i18n`)
|
|
114
|
+
- `resourcesDir`: Resource assets directory (default `resources`)
|
|
115
|
+
- `isIsolateMode`: Enable isolate preload build (default `false`)
|
|
116
|
+
- `mainEntry`: Main entry file (default `src/index.ts`)
|
|
117
|
+
- `isolatePreloadEntry`: Isolate preload entry (default `src/isolate-preload/index.ts`)
|
|
118
|
+
|
|
119
|
+
## Manifest Fields
|
|
120
|
+
|
|
121
|
+
The extension manifest is derived from `config.ts`. Key fields:
|
|
122
|
+
|
|
123
|
+
- `id`, `name`, `version`
|
|
124
|
+
- `description`, `icon`, `author`, `homepage`, `license`
|
|
125
|
+
- `target_engine`, `categories`, `tags`, `grant`
|
|
126
|
+
- `contributes.resource`, `contributes.listProviders`, `contributes.settings`, `contributes.commands`
|
|
127
|
+
- `download_url_template`
|
|
128
|
+
|
|
129
|
+
## Isolate Mode
|
|
130
|
+
|
|
131
|
+
When `isIsolateMode` is enabled, the build also outputs `resources/isolate-preload.js` from `isolatePreloadEntry`. Use `grant: ['isolate_context']` if your extension needs isolate context.
|
|
132
|
+
|
|
133
|
+
## TypeScript and ESLint
|
|
134
|
+
|
|
135
|
+
Use built-in presets:
|
|
136
|
+
|
|
137
|
+
```json
|
|
138
|
+
{
|
|
139
|
+
"extends": ["@any-listen/extension-kit/tsconfig.app.json"]
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
```js
|
|
144
|
+
import config from '@any-listen/extension-kit/eslint.config.js'
|
|
145
|
+
|
|
146
|
+
export default config
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## License
|
|
150
|
+
|
|
151
|
+
Apache License 2.0
|
package/dist/bin.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { argv } from "node:process";
|
|
3
|
+
import { parseArgs } from "node:util";
|
|
4
|
+
//#region src/index.ts
|
|
5
|
+
var { values } = parseArgs({
|
|
6
|
+
args: argv.slice(2),
|
|
7
|
+
options: {
|
|
8
|
+
build: { type: "boolean" },
|
|
9
|
+
publish: { type: "boolean" }
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
if (values.build) import("./build-CUKFiHZ-.js");
|
|
13
|
+
else if (values.publish) import("./publish-BUpufhVY.js");
|
|
14
|
+
else console.log("Please specify a command: build or publish");
|
|
15
|
+
//#endregion
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { argv } from 'node:process'\nimport { parseArgs } from 'node:util'\n\nconst { values } = parseArgs({\n args: argv.slice(2),\n options: {\n build: {\n type: 'boolean',\n },\n publish: {\n type: 'boolean',\n },\n },\n})\n\nif (values.build) {\n void import('./build')\n} else if (values.publish) {\n void import('./publish')\n} else {\n console.log('Please specify a command: build or publish')\n}\n"],"mappings":";;;;AAKA,IAAM,EAAE,WAAW,UAAU;CAC3B,MAAM,KAAK,MAAM,EAAE;CACnB,SAAS;EACP,OAAO,EACL,MAAM,WACP;EACD,SAAS,EACP,MAAM,WACP;EACF;CACF,CAAC;AAEF,IAAI,OAAO,MACJ,QAAO;SACH,OAAO,QACX,QAAO;IAEZ,SAAQ,IAAI,6CAA6C"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { a as loadEnvFile, i as getConfig, n as build$1, o as EXTENSION, r as buildPackageName, s as state } from "./utils-BN85b34y.js";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import crypto from "node:crypto";
|
|
5
|
+
import { defineConfig } from "vite";
|
|
6
|
+
//#region src/cpResources.ts
|
|
7
|
+
var cpResources = async () => {
|
|
8
|
+
const sourcePath = state.resourcesDir;
|
|
9
|
+
const targetPath = path.join(state.distDir, "resources");
|
|
10
|
+
const sourceI18nPath = state.i18nDir;
|
|
11
|
+
const targetI18nPath = path.join(state.distDir, "i18n");
|
|
12
|
+
await Promise.all([fs.promises.cp(sourcePath, targetPath, { recursive: true }), fs.promises.cp(sourceI18nPath, targetI18nPath, { recursive: true })]);
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/mainifest.ts
|
|
16
|
+
var createMainifest = async (config) => {
|
|
17
|
+
const mainifest = {
|
|
18
|
+
id: config.id,
|
|
19
|
+
name: config.name,
|
|
20
|
+
description: config.description,
|
|
21
|
+
icon: config.icon,
|
|
22
|
+
version: config.version,
|
|
23
|
+
target_engine: config.target_engine,
|
|
24
|
+
author: config.author,
|
|
25
|
+
homepage: config.homepage,
|
|
26
|
+
license: config.license,
|
|
27
|
+
categories: config.categories,
|
|
28
|
+
tags: config.tags,
|
|
29
|
+
grant: config.grant,
|
|
30
|
+
contributes: config.contributes,
|
|
31
|
+
main: EXTENSION.entryFileName
|
|
32
|
+
};
|
|
33
|
+
await fs.promises.writeFile(path.join(state.distDir, EXTENSION.mainifestName), JSON.stringify(mainifest, null, 2), "utf8");
|
|
34
|
+
};
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/pack.ts
|
|
37
|
+
var buildPublicKey = (publicKey) => {
|
|
38
|
+
if (!publicKey.includes("-----BEGIN PUBLIC KEY-----")) return `-----BEGIN PUBLIC KEY-----\n${publicKey}\n-----END PUBLIC KEY-----`;
|
|
39
|
+
return publicKey;
|
|
40
|
+
};
|
|
41
|
+
var signData = (data, privateKey) => {
|
|
42
|
+
const sign = crypto.createSign("SHA256");
|
|
43
|
+
sign.update(data);
|
|
44
|
+
sign.end();
|
|
45
|
+
return sign.sign(privateKey, "hex");
|
|
46
|
+
};
|
|
47
|
+
var verifySignature = (data, publicKey, signature) => {
|
|
48
|
+
const verify = crypto.createVerify("SHA256");
|
|
49
|
+
verify.update(data);
|
|
50
|
+
verify.end();
|
|
51
|
+
return verify.verify(publicKey, signature, "hex");
|
|
52
|
+
};
|
|
53
|
+
var packFile = async ({ gzip, cwd, files, dist }) => {
|
|
54
|
+
const { c } = await import("tar");
|
|
55
|
+
return new Promise((resolve, reject) => {
|
|
56
|
+
c({
|
|
57
|
+
gzip,
|
|
58
|
+
cwd
|
|
59
|
+
}, files).pipe(fs.createWriteStream(dist)).on("finish", () => {
|
|
60
|
+
resolve();
|
|
61
|
+
}).on("error", reject);
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
var pack = async (config) => {
|
|
65
|
+
var _process$env$PRI_KEY, _process$env$PUB_KEY;
|
|
66
|
+
let privateKey = (_process$env$PRI_KEY = process.env.PRI_KEY) === null || _process$env$PRI_KEY === void 0 ? void 0 : _process$env$PRI_KEY.trim();
|
|
67
|
+
let publicKey = (_process$env$PUB_KEY = process.env.PUB_KEY) === null || _process$env$PUB_KEY === void 0 ? void 0 : _process$env$PUB_KEY.trim();
|
|
68
|
+
if (!privateKey || !publicKey) throw new Error("Missing private key or public key");
|
|
69
|
+
if (!privateKey.includes("-----BEGIN PRIVATE KEY-----")) privateKey = `-----BEGIN PRIVATE KEY-----\n${privateKey}\n-----END PRIVATE KEY-----`;
|
|
70
|
+
const unpackedDir = path.join(state.outputDir, "unpacked");
|
|
71
|
+
await fs.promises.rm(unpackedDir, { recursive: true }).catch(() => {});
|
|
72
|
+
await fs.promises.mkdir(unpackedDir, { recursive: true }).catch(() => {});
|
|
73
|
+
const extBundleFilePath = path.join(unpackedDir, EXTENSION.extBundleFileName);
|
|
74
|
+
await packFile({
|
|
75
|
+
gzip: true,
|
|
76
|
+
cwd: state.distDir,
|
|
77
|
+
files: [
|
|
78
|
+
EXTENSION.entryFileName,
|
|
79
|
+
EXTENSION.mainifestName,
|
|
80
|
+
"resources",
|
|
81
|
+
"i18n"
|
|
82
|
+
],
|
|
83
|
+
dist: extBundleFilePath
|
|
84
|
+
});
|
|
85
|
+
const buf = await fs.promises.readFile(extBundleFilePath);
|
|
86
|
+
const signature = signData(buf, privateKey);
|
|
87
|
+
if (!verifySignature(buf, buildPublicKey(publicKey), signature)) throw new Error("Signature is valid, please check your public key");
|
|
88
|
+
await fs.promises.writeFile(path.join(unpackedDir, EXTENSION.signFileName), `${signature}\n${publicKey}`);
|
|
89
|
+
await packFile({
|
|
90
|
+
gzip: true,
|
|
91
|
+
cwd: unpackedDir,
|
|
92
|
+
files: [EXTENSION.extBundleFileName, EXTENSION.signFileName],
|
|
93
|
+
dist: path.join(state.outputDir, buildPackageName(config))
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/vite.config.ts
|
|
98
|
+
var isProd = process.env.NODE_ENV == "production";
|
|
99
|
+
var createBuildConfig = (name, filePath) => {
|
|
100
|
+
return defineConfig({
|
|
101
|
+
base: "./",
|
|
102
|
+
mode: process.env.NODE_ENV,
|
|
103
|
+
publicDir: false,
|
|
104
|
+
resolve: { alias: { "@": state.srcDir } },
|
|
105
|
+
build: {
|
|
106
|
+
target: "esnext",
|
|
107
|
+
emptyOutDir: true,
|
|
108
|
+
minify: false,
|
|
109
|
+
watch: isProd ? null : { buildDelay: 500 },
|
|
110
|
+
outDir: state.distDir,
|
|
111
|
+
rolldownOptions: {
|
|
112
|
+
external: ["any-listen"],
|
|
113
|
+
input: { [name]: filePath },
|
|
114
|
+
output: {
|
|
115
|
+
entryFileNames: "[name]",
|
|
116
|
+
format: "iife"
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
var vite_config_default = (isIsolateMode) => {
|
|
123
|
+
const inputs = isIsolateMode ? {
|
|
124
|
+
[EXTENSION.entryFileName]: state.mainEntry,
|
|
125
|
+
"resources/isolate-preload.js": state.isolatePreloadEntry
|
|
126
|
+
} : { [EXTENSION.entryFileName]: state.mainEntry };
|
|
127
|
+
return Object.entries(inputs).map(([name, filePath]) => createBuildConfig(name, filePath));
|
|
128
|
+
};
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region src/build.ts
|
|
131
|
+
var run = async () => {
|
|
132
|
+
await loadEnvFile();
|
|
133
|
+
const config = await getConfig();
|
|
134
|
+
const appConfigs = vite_config_default(state.isIsolateMode);
|
|
135
|
+
await Promise.all(appConfigs.map(async (appConfig) => build$1(appConfig)));
|
|
136
|
+
await Promise.all([cpResources(), createMainifest(config)]);
|
|
137
|
+
await pack(config);
|
|
138
|
+
};
|
|
139
|
+
run();
|
|
140
|
+
//#endregion
|
|
141
|
+
|
|
142
|
+
//# sourceMappingURL=build-CUKFiHZ-.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-CUKFiHZ-.js","names":[],"sources":["../src/cpResources.ts","../src/mainifest.ts","../src/pack.ts","../src/vite.config.ts","../src/build.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { state } from './state'\n\nexport const cpResources = async () => {\n const sourcePath = state.resourcesDir\n const targetPath = path.join(state.distDir, 'resources')\n const sourceI18nPath = state.i18nDir\n const targetI18nPath = path.join(state.distDir, 'i18n')\n\n await Promise.all([\n fs.promises.cp(sourcePath, targetPath, { recursive: true }),\n fs.promises.cp(sourceI18nPath, targetI18nPath, { recursive: true }),\n ])\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { EXTENSION } from './constants'\nimport { state } from './state'\nimport type { ExtensionConfig } from './types/build'\n\nexport const createMainifest = async (config: ExtensionConfig) => {\n const mainifest = {\n id: config.id,\n name: config.name,\n description: config.description,\n icon: config.icon,\n version: config.version,\n target_engine: config.target_engine,\n author: config.author,\n homepage: config.homepage,\n license: config.license,\n categories: config.categories,\n tags: config.tags,\n grant: config.grant,\n contributes: config.contributes,\n main: EXTENSION.entryFileName,\n }\n\n await fs.promises.writeFile(path.join(state.distDir, EXTENSION.mainifestName), JSON.stringify(mainifest, null, 2), 'utf8')\n}\n","import crypto from 'node:crypto'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { EXTENSION } from './constants'\nimport { state } from './state'\nimport type { ExtensionConfig } from './types/build'\nimport { buildPackageName } from './utils'\n\nconst buildPublicKey = (publicKey: string) => {\n if (!publicKey.includes('-----BEGIN PUBLIC KEY-----')) {\n return `-----BEGIN PUBLIC KEY-----\\n${publicKey}\\n-----END PUBLIC KEY-----`\n }\n return publicKey\n}\n\nconst signData = (data: Buffer, privateKey: string) => {\n const sign = crypto.createSign('SHA256')\n sign.update(data)\n sign.end()\n const signature = sign.sign(privateKey, 'hex')\n return signature\n}\nconst verifySignature = (data: Buffer, publicKey: string, signature: string) => {\n const verify = crypto.createVerify('SHA256')\n verify.update(data)\n verify.end()\n const isValid = verify.verify(publicKey, signature, 'hex')\n return isValid\n}\n\nconst packFile = async ({ gzip, cwd, files, dist }: { gzip: boolean; cwd: string; files: string[]; dist: string }) => {\n const { c } = await import('tar')\n return new Promise<void>((resolve, reject) => {\n c(\n {\n gzip,\n cwd,\n },\n files\n )\n .pipe(fs.createWriteStream(dist))\n .on('finish', () => {\n resolve()\n })\n .on('error', reject)\n })\n}\n\nexport const pack = async (config: ExtensionConfig) => {\n let privateKey = process.env.PRI_KEY?.trim()\n let publicKey = process.env.PUB_KEY?.trim()\n if (!privateKey || !publicKey) throw new Error('Missing private key or public key')\n if (!privateKey.includes('-----BEGIN PRIVATE KEY-----')) {\n privateKey = `-----BEGIN PRIVATE KEY-----\\n${privateKey}\\n-----END PRIVATE KEY-----`\n }\n\n const unpackedDir = path.join(state.outputDir, 'unpacked')\n await fs.promises.rm(unpackedDir, { recursive: true }).catch(() => {})\n await fs.promises.mkdir(unpackedDir, { recursive: true }).catch(() => {})\n const extBundleFilePath = path.join(unpackedDir, EXTENSION.extBundleFileName)\n await packFile({\n gzip: true,\n cwd: state.distDir,\n files: [EXTENSION.entryFileName, EXTENSION.mainifestName, 'resources', 'i18n'],\n dist: extBundleFilePath,\n })\n const buf = await fs.promises.readFile(extBundleFilePath)\n const signature = signData(buf, privateKey)\n if (!verifySignature(buf, buildPublicKey(publicKey), signature)) {\n throw new Error('Signature is valid, please check your public key')\n }\n await fs.promises.writeFile(path.join(unpackedDir, EXTENSION.signFileName), `${signature}\\n${publicKey}`)\n await packFile({\n gzip: true,\n cwd: unpackedDir,\n files: [EXTENSION.extBundleFileName, EXTENSION.signFileName],\n dist: path.join(state.outputDir, buildPackageName(config)),\n })\n}\n","import { defineConfig } from 'vite'\n\nimport { EXTENSION } from './constants'\nimport { state } from './state'\n\nconst isProd = process.env.NODE_ENV == 'production'\n\nconst createBuildConfig = (name: string, filePath: string) => {\n return defineConfig({\n base: './',\n mode: process.env.NODE_ENV,\n publicDir: false,\n resolve: {\n alias: {\n '@': state.srcDir,\n },\n },\n build: {\n target: 'esnext',\n emptyOutDir: true,\n minify: false,\n watch: isProd\n ? null\n : {\n buildDelay: 500,\n },\n outDir: state.distDir,\n rolldownOptions: {\n external: ['any-listen'],\n input: {\n [name]: filePath,\n },\n output: {\n entryFileNames: '[name]',\n format: 'iife',\n },\n },\n },\n })\n}\n\nexport default (isIsolateMode?: boolean) => {\n const inputs = isIsolateMode\n ? {\n [EXTENSION.entryFileName]: state.mainEntry,\n 'resources/isolate-preload.js': state.isolatePreloadEntry,\n }\n : {\n [EXTENSION.entryFileName]: state.mainEntry,\n }\n return Object.entries(inputs).map(([name, filePath]) => createBuildConfig(name, filePath))\n}\n","import { cpResources } from './cpResources'\nimport { createMainifest } from './mainifest'\nimport { pack } from './pack'\nimport { state } from './state'\nimport { build, getConfig, loadEnvFile } from './utils'\nimport createConfigs from './vite.config'\n\nconst run = async () => {\n await loadEnvFile()\n const config = await getConfig()\n const appConfigs = createConfigs(state.isIsolateMode)\n await Promise.all(appConfigs.map(async (appConfig) => build(appConfig)))\n await Promise.all([cpResources(), createMainifest(config)])\n await pack(config)\n}\n\nvoid run()\n"],"mappings":";;;;;;AAKA,IAAa,cAAc,YAAY;CACrC,MAAM,aAAa,MAAM;CACzB,MAAM,aAAa,KAAK,KAAK,MAAM,SAAS,YAAY;CACxD,MAAM,iBAAiB,MAAM;CAC7B,MAAM,iBAAiB,KAAK,KAAK,MAAM,SAAS,OAAO;AAEvD,OAAM,QAAQ,IAAI,CAChB,GAAG,SAAS,GAAG,YAAY,YAAY,EAAE,WAAW,MAAM,CAAC,EAC3D,GAAG,SAAS,GAAG,gBAAgB,gBAAgB,EAAE,WAAW,MAAM,CAAC,CACpE,CAAC;;;;ACPJ,IAAa,kBAAkB,OAAO,WAA4B;CAChE,MAAM,YAAY;EAChB,IAAI,OAAO;EACX,MAAM,OAAO;EACb,aAAa,OAAO;EACpB,MAAM,OAAO;EACb,SAAS,OAAO;EAChB,eAAe,OAAO;EACtB,QAAQ,OAAO;EACf,UAAU,OAAO;EACjB,SAAS,OAAO;EAChB,YAAY,OAAO;EACnB,MAAM,OAAO;EACb,OAAO,OAAO;EACd,aAAa,OAAO;EACpB,MAAM,UAAU;EACjB;AAED,OAAM,GAAG,SAAS,UAAU,KAAK,KAAK,MAAM,SAAS,UAAU,cAAc,EAAE,KAAK,UAAU,WAAW,MAAM,EAAE,EAAE,OAAO;;;;AChB5H,IAAM,kBAAkB,cAAsB;AAC5C,KAAI,CAAC,UAAU,SAAS,6BAA6B,CACnD,QAAO,+BAA+B,UAAU;AAElD,QAAO;;AAGT,IAAM,YAAY,MAAc,eAAuB;CACrD,MAAM,OAAO,OAAO,WAAW,SAAS;AACxC,MAAK,OAAO,KAAK;AACjB,MAAK,KAAK;AAEV,QADkB,KAAK,KAAK,YAAY,MAAM;;AAGhD,IAAM,mBAAmB,MAAc,WAAmB,cAAsB;CAC9E,MAAM,SAAS,OAAO,aAAa,SAAS;AAC5C,QAAO,OAAO,KAAK;AACnB,QAAO,KAAK;AAEZ,QADgB,OAAO,OAAO,WAAW,WAAW,MAAM;;AAI5D,IAAM,WAAW,OAAO,EAAE,MAAM,KAAK,OAAO,WAA0E;CACpH,MAAM,EAAE,MAAM,MAAM,OAAO;AAC3B,QAAO,IAAI,SAAe,SAAS,WAAW;AAC5C,IACE;GACE;GACA;GACD,EACD,MACD,CACE,KAAK,GAAG,kBAAkB,KAAK,CAAC,CAChC,GAAG,gBAAgB;AAClB,YAAS;IACT,CACD,GAAG,SAAS,OAAO;GACtB;;AAGJ,IAAa,OAAO,OAAO,WAA4B;;CACrD,IAAI,cAAA,uBAAa,QAAQ,IAAI,aAAA,QAAA,yBAAA,KAAA,IAAA,KAAA,IAAA,qBAAS,MAAM;CAC5C,IAAI,aAAA,uBAAY,QAAQ,IAAI,aAAA,QAAA,yBAAA,KAAA,IAAA,KAAA,IAAA,qBAAS,MAAM;AAC3C,KAAI,CAAC,cAAc,CAAC,UAAW,OAAM,IAAI,MAAM,oCAAoC;AACnF,KAAI,CAAC,WAAW,SAAS,8BAA8B,CACrD,cAAa,gCAAgC,WAAW;CAG1D,MAAM,cAAc,KAAK,KAAK,MAAM,WAAW,WAAW;AAC1D,OAAM,GAAG,SAAS,GAAG,aAAa,EAAE,WAAW,MAAM,CAAC,CAAC,YAAY,GAAG;AACtE,OAAM,GAAG,SAAS,MAAM,aAAa,EAAE,WAAW,MAAM,CAAC,CAAC,YAAY,GAAG;CACzE,MAAM,oBAAoB,KAAK,KAAK,aAAa,UAAU,kBAAkB;AAC7E,OAAM,SAAS;EACb,MAAM;EACN,KAAK,MAAM;EACX,OAAO;GAAC,UAAU;GAAe,UAAU;GAAe;GAAa;GAAO;EAC9E,MAAM;EACP,CAAC;CACF,MAAM,MAAM,MAAM,GAAG,SAAS,SAAS,kBAAkB;CACzD,MAAM,YAAY,SAAS,KAAK,WAAW;AAC3C,KAAI,CAAC,gBAAgB,KAAK,eAAe,UAAU,EAAE,UAAU,CAC7D,OAAM,IAAI,MAAM,mDAAmD;AAErE,OAAM,GAAG,SAAS,UAAU,KAAK,KAAK,aAAa,UAAU,aAAa,EAAE,GAAG,UAAU,IAAI,YAAY;AACzG,OAAM,SAAS;EACb,MAAM;EACN,KAAK;EACL,OAAO,CAAC,UAAU,mBAAmB,UAAU,aAAa;EAC5D,MAAM,KAAK,KAAK,MAAM,WAAW,iBAAiB,OAAO,CAAC;EAC3D,CAAC;;;;ACzEJ,IAAM,SAAA,QAAA,IAAA,YAAiC;AAEvC,IAAM,qBAAqB,MAAc,aAAqB;AAC5D,QAAO,aAAa;EAClB,MAAM;EACN,MAAA,QAAA,IAAA;EACA,WAAW;EACX,SAAS,EACP,OAAO,EACL,KAAK,MAAM,QACZ,EACF;EACD,OAAO;GACL,QAAQ;GACR,aAAa;GACb,QAAQ;GACR,OAAO,SACH,OACA,EACE,YAAY,KACb;GACL,QAAQ,MAAM;GACd,iBAAiB;IACf,UAAU,CAAC,aAAa;IACxB,OAAO,GACJ,OAAO,UACT;IACD,QAAQ;KACN,gBAAgB;KAChB,QAAQ;KACT;IACF;GACF;EACF,CAAC;;AAGJ,IAAA,uBAAgB,kBAA4B;CAC1C,MAAM,SAAS,gBACX;GACG,UAAU,gBAAgB,MAAM;EACjC,gCAAgC,MAAM;EACvC,GACD,GACG,UAAU,gBAAgB,MAAM,WAClC;AACL,QAAO,OAAO,QAAQ,OAAO,CAAC,KAAK,CAAC,MAAM,cAAc,kBAAkB,MAAM,SAAS,CAAC;;;;AC3C5F,IAAM,MAAM,YAAY;AACtB,OAAM,aAAa;CACnB,MAAM,SAAS,MAAM,WAAW;CAChC,MAAM,aAAa,oBAAc,MAAM,cAAc;AACrD,OAAM,QAAQ,IAAI,WAAW,IAAI,OAAO,cAAc,QAAM,UAAU,CAAC,CAAC;AACxE,OAAM,QAAQ,IAAI,CAAC,aAAa,EAAE,gBAAgB,OAAO,CAAC,CAAC;AAC3D,OAAM,KAAK,OAAO;;AAGf,KAAK"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { i as getConfig, r as buildPackageName, t as ROOT_DIR } from "./utils-BN85b34y.js";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
//#region src/publish.ts
|
|
5
|
+
var run = async () => {
|
|
6
|
+
const config = await getConfig();
|
|
7
|
+
const filePath = path.join(ROOT_DIR, "publish/version.json");
|
|
8
|
+
let versionInfo = await fs.promises.readFile(filePath, "utf-8").then((d) => JSON.parse(d)).catch(() => null);
|
|
9
|
+
if (versionInfo) {
|
|
10
|
+
if (versionInfo.version === config.version) {
|
|
11
|
+
console.warn(`Version (v${config.version}) already published`);
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
versionInfo.history ||= [];
|
|
15
|
+
versionInfo.history.push({
|
|
16
|
+
version: versionInfo.version,
|
|
17
|
+
download_url: versionInfo.download_url,
|
|
18
|
+
log: versionInfo.log,
|
|
19
|
+
date: versionInfo.date
|
|
20
|
+
});
|
|
21
|
+
} else versionInfo = {
|
|
22
|
+
version: "",
|
|
23
|
+
download_url: "",
|
|
24
|
+
log: "",
|
|
25
|
+
date: (/* @__PURE__ */ new Date()).toISOString()
|
|
26
|
+
};
|
|
27
|
+
versionInfo.version = config.version;
|
|
28
|
+
if (config.download_url_template) versionInfo.download_url = `${config.download_url_template.replaceAll("{version}", config.version)}/${buildPackageName(config)}`;
|
|
29
|
+
versionInfo.log = await fs.promises.readFile(path.join(ROOT_DIR, "publish/changeLog.md"), "utf-8").then((d) => d.toString().trim()).catch(() => "");
|
|
30
|
+
versionInfo.date = (/* @__PURE__ */ new Date()).toISOString();
|
|
31
|
+
await fs.promises.rm(filePath, {
|
|
32
|
+
recursive: true,
|
|
33
|
+
force: true
|
|
34
|
+
});
|
|
35
|
+
await fs.promises.writeFile(filePath, JSON.stringify(versionInfo));
|
|
36
|
+
};
|
|
37
|
+
run();
|
|
38
|
+
//#endregion
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=publish-BUpufhVY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish-BUpufhVY.js","names":[],"sources":["../src/publish.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\n\nimport type { VersionInfo } from './types/build'\nimport { buildPackageName, getConfig, ROOT_DIR } from './utils'\n\nexport const run = async () => {\n const config = await getConfig()\n const filePath = path.join(ROOT_DIR, 'publish/version.json')\n let versionInfo = await fs.promises\n .readFile(filePath, 'utf-8')\n .then((d) => JSON.parse(d) as VersionInfo)\n .catch(() => null)\n if (versionInfo) {\n if (versionInfo.version === config.version) {\n console.warn(`Version (v${config.version}) already published`)\n process.exit(1)\n }\n versionInfo.history ||= []\n versionInfo.history.push({\n version: versionInfo.version,\n download_url: versionInfo.download_url,\n log: versionInfo.log,\n date: versionInfo.date,\n })\n } else {\n versionInfo = { version: '', download_url: '', log: '', date: new Date().toISOString() }\n }\n versionInfo.version = config.version\n if (config.download_url_template) {\n versionInfo.download_url = `${config.download_url_template.replaceAll('{version}', config.version)}/${buildPackageName(config)}`\n }\n versionInfo.log = await fs.promises\n .readFile(path.join(ROOT_DIR, 'publish/changeLog.md'), 'utf-8')\n .then((d) => d.toString().trim())\n .catch(() => '')\n versionInfo.date = new Date().toISOString()\n\n await fs.promises.rm(filePath, { recursive: true, force: true })\n await fs.promises.writeFile(filePath, JSON.stringify(versionInfo))\n}\n\nvoid run()\n"],"mappings":";;;;AAMA,IAAa,MAAM,YAAY;CAC7B,MAAM,SAAS,MAAM,WAAW;CAChC,MAAM,WAAW,KAAK,KAAK,UAAU,uBAAuB;CAC5D,IAAI,cAAc,MAAM,GAAG,SACxB,SAAS,UAAU,QAAQ,CAC3B,MAAM,MAAM,KAAK,MAAM,EAAE,CAAgB,CACzC,YAAY,KAAK;AACpB,KAAI,aAAa;AACf,MAAI,YAAY,YAAY,OAAO,SAAS;AAC1C,WAAQ,KAAK,aAAa,OAAO,QAAQ,qBAAqB;AAC9D,WAAQ,KAAK,EAAE;;AAEjB,cAAY,YAAY,EAAE;AAC1B,cAAY,QAAQ,KAAK;GACvB,SAAS,YAAY;GACrB,cAAc,YAAY;GAC1B,KAAK,YAAY;GACjB,MAAM,YAAY;GACnB,CAAC;OAEF,eAAc;EAAE,SAAS;EAAI,cAAc;EAAI,KAAK;EAAI,uBAAM,IAAI,MAAM,EAAC,aAAa;EAAE;AAE1F,aAAY,UAAU,OAAO;AAC7B,KAAI,OAAO,sBACT,aAAY,eAAe,GAAG,OAAO,sBAAsB,WAAW,aAAa,OAAO,QAAQ,CAAC,GAAG,iBAAiB,OAAO;AAEhI,aAAY,MAAM,MAAM,GAAG,SACxB,SAAS,KAAK,KAAK,UAAU,uBAAuB,EAAE,QAAQ,CAC9D,MAAM,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,CAChC,YAAY,GAAG;AAClB,aAAY,wBAAO,IAAI,MAAM,EAAC,aAAa;AAE3C,OAAM,GAAG,SAAS,GAAG,UAAU;EAAE,WAAW;EAAM,OAAO;EAAM,CAAC;AAChE,OAAM,GAAG,SAAS,UAAU,UAAU,KAAK,UAAU,YAAY,CAAC;;AAG/D,KAAK"}
|