@git.zone/tspublish 1.9.0 → 1.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist_ts/00_commitinfo_data.js +2 -2
- package/dist_ts/classes.giteaassets.js +25 -19
- package/dist_ts/classes.publishmodule.js +13 -6
- package/dist_ts/classes.tspublish.js +13 -8
- package/dist_ts/index.js +3 -2
- package/dist_ts/logging.d.ts +13 -0
- package/dist_ts/logging.js +83 -1
- package/dist_ts/plugins.d.ts +2 -1
- package/dist_ts/plugins.js +3 -2
- package/package.json +11 -11
- package/readme.md +299 -117
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/classes.giteaassets.ts +29 -24
- package/ts/classes.publishmodule.ts +13 -7
- package/ts/classes.tspublish.ts +12 -10
- package/ts/index.ts +2 -1
- package/ts/logging.ts +99 -0
- package/ts/plugins.ts +2 -1
package/readme.md
CHANGED
|
@@ -1,193 +1,375 @@
|
|
|
1
|
-
# @git.zone/tspublish
|
|
1
|
+
# @git.zone/tspublish 🚀
|
|
2
2
|
|
|
3
|
-
publish multiple
|
|
3
|
+
> **Effortlessly publish multiple TypeScript packages from your monorepo**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/@git.zone/tspublish)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
## 🌟 What is tspublish?
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
`@git.zone/tspublish` is your Swiss Army knife for managing and publishing multiple TypeScript packages from a monorepo. It automates the tedious parts of package publishing while giving you full control over the process. Whether you're maintaining a suite of microservices, a component library, or any collection of related packages, tspublish makes your life easier.
|
|
11
|
+
|
|
12
|
+
### ✨ Key Features
|
|
13
|
+
|
|
14
|
+
- 📦 **Automatic Package Discovery** - Scans your monorepo for publishable packages
|
|
15
|
+
- 🎨 **Beautiful CLI Output** - Color-coded logging with progress indicators
|
|
16
|
+
- 🔍 **Version Collision Detection** - Prevents accidental overwrites
|
|
17
|
+
- 🏗️ **Build Integration** - Automatically builds TypeScript before publishing
|
|
18
|
+
- 🎯 **Smart Dependency Management** - Inherits dependencies from your monorepo
|
|
19
|
+
- 🌐 **Multi-Registry Support** - Publish to npm, GitHub packages, or private registries
|
|
20
|
+
- ⚡ **Zero Config** - Works out of the box with sensible defaults
|
|
12
21
|
|
|
13
|
-
|
|
22
|
+
## 📥 Installation
|
|
23
|
+
|
|
24
|
+
### As a Development Dependency (Recommended)
|
|
14
25
|
|
|
15
26
|
```bash
|
|
16
|
-
|
|
17
|
-
|
|
27
|
+
# Using pnpm (recommended)
|
|
28
|
+
pnpm add -D @git.zone/tspublish
|
|
29
|
+
|
|
30
|
+
# Using npm
|
|
31
|
+
npm install --save-dev @git.zone/tspublish
|
|
18
32
|
|
|
19
|
-
|
|
33
|
+
# Using yarn
|
|
34
|
+
yarn add -D @git.zone/tspublish
|
|
35
|
+
```
|
|
20
36
|
|
|
21
|
-
|
|
37
|
+
### Global Installation
|
|
22
38
|
|
|
23
|
-
|
|
39
|
+
```bash
|
|
40
|
+
npm install -g @git.zone/tspublish
|
|
41
|
+
```
|
|
24
42
|
|
|
25
|
-
|
|
43
|
+
## 🚀 Quick Start
|
|
26
44
|
|
|
27
|
-
|
|
45
|
+
### 1️⃣ Structure Your Monorepo
|
|
28
46
|
|
|
29
|
-
|
|
47
|
+
Organize your packages with the `ts` prefix convention:
|
|
30
48
|
|
|
31
49
|
```
|
|
32
|
-
my-monorepo/
|
|
33
|
-
├──
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
├── ts
|
|
37
|
-
│ ├──
|
|
38
|
-
│
|
|
50
|
+
my-awesome-monorepo/
|
|
51
|
+
├── package.json # Main monorepo package.json
|
|
52
|
+
├── tsconfig.json # Shared TypeScript config
|
|
53
|
+
├── ts-core/ # Core package
|
|
54
|
+
│ ├── ts/ # TypeScript source files
|
|
55
|
+
│ ├── readme.md # Package documentation
|
|
56
|
+
│ └── tspublish.json # Publishing configuration
|
|
57
|
+
├── ts-utils/ # Utilities package
|
|
58
|
+
│ ├── ts/
|
|
59
|
+
│ ├── readme.md
|
|
60
|
+
│ └── tspublish.json
|
|
61
|
+
└── ts-cli/ # CLI package
|
|
62
|
+
├── ts/
|
|
63
|
+
├── readme.md
|
|
64
|
+
└── tspublish.json
|
|
39
65
|
```
|
|
40
66
|
|
|
41
|
-
###
|
|
67
|
+
### 2️⃣ Configure Each Package
|
|
42
68
|
|
|
43
|
-
|
|
69
|
+
Create a `tspublish.json` in each package directory:
|
|
44
70
|
|
|
45
71
|
```json
|
|
46
72
|
{
|
|
47
|
-
"name": "@myorg/
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
73
|
+
"name": "@myorg/core",
|
|
74
|
+
"order": 1,
|
|
75
|
+
"dependencies": [
|
|
76
|
+
"@push.rocks/smartpromise",
|
|
77
|
+
"@push.rocks/smartfile"
|
|
78
|
+
],
|
|
79
|
+
"registries": [
|
|
80
|
+
"registry.npmjs.org:public",
|
|
81
|
+
"npm.pkg.github.com:private"
|
|
82
|
+
],
|
|
83
|
+
"bin": ["my-cli"]
|
|
51
84
|
}
|
|
52
85
|
```
|
|
53
86
|
|
|
54
|
-
|
|
87
|
+
#### Configuration Options
|
|
55
88
|
|
|
56
|
-
|
|
89
|
+
| Field | Type | Description |
|
|
90
|
+
|-------|------|-------------|
|
|
91
|
+
| `name` | string | Package name (required) |
|
|
92
|
+
| `order` | number | Build order for interdependent packages |
|
|
93
|
+
| `dependencies` | string[] | Dependencies from the monorepo to include |
|
|
94
|
+
| `registries` | string[] | Target registries with access level |
|
|
95
|
+
| `bin` | string[] | CLI executable names |
|
|
57
96
|
|
|
58
|
-
|
|
59
|
-
import { runCli } from '@git.zone/tspublish';
|
|
97
|
+
### 3️⃣ Run the Publisher
|
|
60
98
|
|
|
61
|
-
|
|
99
|
+
#### Command Line
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# From your monorepo root
|
|
103
|
+
npx tspublish
|
|
62
104
|
```
|
|
63
105
|
|
|
64
|
-
|
|
106
|
+
#### Programmatic Usage
|
|
65
107
|
|
|
66
|
-
|
|
108
|
+
```typescript
|
|
109
|
+
import { TsPublish } from '@git.zone/tspublish';
|
|
67
110
|
|
|
68
|
-
|
|
111
|
+
const publisher = new TsPublish();
|
|
112
|
+
await publisher.publish(process.cwd());
|
|
113
|
+
```
|
|
69
114
|
|
|
70
|
-
|
|
115
|
+
## 🎯 Advanced Usage
|
|
71
116
|
|
|
72
|
-
|
|
73
|
-
- **Identifies directories** that start with `ts` and validates the presence of `tspublish.json`.
|
|
74
|
-
- **Logs** information about found packages for user awareness and debugging.
|
|
75
|
-
- **Checks for collisions** with existing versions on the npm registry to prevent overriding published versions.
|
|
117
|
+
### Custom Publishing Pipeline
|
|
76
118
|
|
|
77
119
|
```typescript
|
|
78
|
-
import { TsPublish } from '@git.zone/tspublish';
|
|
120
|
+
import { TsPublish, PublishModule } from '@git.zone/tspublish';
|
|
121
|
+
|
|
122
|
+
// Initialize the publisher
|
|
123
|
+
const publisher = new TsPublish();
|
|
79
124
|
|
|
80
|
-
|
|
81
|
-
await
|
|
125
|
+
// Get all publishable modules
|
|
126
|
+
const modules = await publisher.getModuleSubDirs('./my-monorepo');
|
|
127
|
+
|
|
128
|
+
// Custom processing for each module
|
|
129
|
+
for (const [name, config] of Object.entries(modules)) {
|
|
130
|
+
const module = new PublishModule(publisher, {
|
|
131
|
+
monoRepoDir: './my-monorepo',
|
|
132
|
+
packageSubFolder: name
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// Initialize module
|
|
136
|
+
await module.init();
|
|
137
|
+
|
|
138
|
+
// Create publish directory
|
|
139
|
+
await module.createPublishModuleDir();
|
|
140
|
+
|
|
141
|
+
// Custom build step
|
|
142
|
+
console.log(`Building ${config.name}...`);
|
|
143
|
+
await module.build();
|
|
144
|
+
|
|
145
|
+
// Publish to registries
|
|
146
|
+
await module.publish();
|
|
147
|
+
}
|
|
82
148
|
```
|
|
83
149
|
|
|
84
|
-
|
|
150
|
+
### Registry Configuration
|
|
85
151
|
|
|
86
|
-
|
|
152
|
+
TSPublish supports multiple registries with different access levels:
|
|
87
153
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
154
|
+
```json
|
|
155
|
+
{
|
|
156
|
+
"registries": [
|
|
157
|
+
"registry.npmjs.org:public", // Public npm package
|
|
158
|
+
"npm.pkg.github.com:private", // Private GitHub package
|
|
159
|
+
"my-company.jfrog.io/npm:restricted" // Corporate registry
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
```
|
|
91
163
|
|
|
92
|
-
|
|
93
|
-
|
|
164
|
+
### Build Order Management
|
|
165
|
+
|
|
166
|
+
When packages depend on each other, use the `order` field to ensure correct build sequence:
|
|
94
167
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
168
|
+
```json
|
|
169
|
+
// ts-core/tspublish.json
|
|
170
|
+
{
|
|
171
|
+
"name": "@myorg/core",
|
|
172
|
+
"order": 1,
|
|
173
|
+
"dependencies": []
|
|
174
|
+
}
|
|
99
175
|
|
|
100
|
-
|
|
176
|
+
// ts-utils/tspublish.json
|
|
177
|
+
{
|
|
178
|
+
"name": "@myorg/utils",
|
|
179
|
+
"order": 2,
|
|
180
|
+
"dependencies": ["@myorg/core"]
|
|
181
|
+
}
|
|
101
182
|
```
|
|
102
183
|
|
|
103
|
-
|
|
184
|
+
### CLI Binary Configuration
|
|
104
185
|
|
|
105
|
-
|
|
186
|
+
For packages that include CLI tools:
|
|
106
187
|
|
|
107
|
-
```
|
|
108
|
-
|
|
188
|
+
```json
|
|
189
|
+
{
|
|
190
|
+
"name": "@myorg/cli",
|
|
191
|
+
"bin": ["my-cli", "my-tool"],
|
|
192
|
+
"dependencies": ["commander", "chalk"]
|
|
193
|
+
}
|
|
109
194
|
```
|
|
110
195
|
|
|
111
|
-
This
|
|
196
|
+
This automatically generates the necessary `cli.js` wrapper and configures the package.json `bin` field.
|
|
197
|
+
|
|
198
|
+
## 🎨 Beautiful Output
|
|
199
|
+
|
|
200
|
+
TSPublish provides rich, colored console output with:
|
|
201
|
+
|
|
202
|
+
- 📊 Progress bars for multi-package operations
|
|
203
|
+
- 🎯 Clear status indicators (ℹ info, ✓ success, ⚠ warning, ✖ error)
|
|
204
|
+
- 📦 Package-specific icons and formatting
|
|
205
|
+
- 🚀 Visual separators between operation phases
|
|
206
|
+
|
|
207
|
+
## 🔧 How It Works
|
|
208
|
+
|
|
209
|
+
1. **Discovery Phase** 🔍
|
|
210
|
+
- Scans for directories starting with `ts`
|
|
211
|
+
- Validates `tspublish.json` presence
|
|
212
|
+
- Orders packages by dependency
|
|
213
|
+
|
|
214
|
+
2. **Preparation Phase** 📋
|
|
215
|
+
- Creates temporary `dist_publish_*` directories
|
|
216
|
+
- Generates package.json from tspublish.json
|
|
217
|
+
- Copies source files and assets
|
|
218
|
+
- Sets up TypeScript configuration
|
|
219
|
+
|
|
220
|
+
3. **Build Phase** 🔨
|
|
221
|
+
- Runs TypeScript compilation
|
|
222
|
+
- Generates declaration files
|
|
223
|
+
- Prepares distribution bundle
|
|
224
|
+
|
|
225
|
+
4. **Validation Phase** ✅
|
|
226
|
+
- Checks npm registry for existing versions
|
|
227
|
+
- Prevents accidental overwrites
|
|
228
|
+
- Validates package metadata
|
|
229
|
+
|
|
230
|
+
5. **Publishing Phase** 🚀
|
|
231
|
+
- Publishes to configured registries
|
|
232
|
+
- Handles authentication
|
|
233
|
+
- Reports success/failure
|
|
234
|
+
|
|
235
|
+
## 🤝 Integration with CI/CD
|
|
236
|
+
|
|
237
|
+
### GitHub Actions
|
|
238
|
+
|
|
239
|
+
```yaml
|
|
240
|
+
name: Publish Packages
|
|
241
|
+
|
|
242
|
+
on:
|
|
243
|
+
push:
|
|
244
|
+
tags:
|
|
245
|
+
- 'v*'
|
|
246
|
+
|
|
247
|
+
jobs:
|
|
248
|
+
publish:
|
|
249
|
+
runs-on: ubuntu-latest
|
|
250
|
+
steps:
|
|
251
|
+
- uses: actions/checkout@v3
|
|
252
|
+
|
|
253
|
+
- uses: pnpm/action-setup@v2
|
|
254
|
+
with:
|
|
255
|
+
version: 8
|
|
256
|
+
|
|
257
|
+
- uses: actions/setup-node@v3
|
|
258
|
+
with:
|
|
259
|
+
node-version: '20'
|
|
260
|
+
cache: 'pnpm'
|
|
261
|
+
|
|
262
|
+
- run: pnpm install
|
|
263
|
+
|
|
264
|
+
- run: pnpm build
|
|
265
|
+
|
|
266
|
+
- run: npx tspublish
|
|
267
|
+
env:
|
|
268
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
269
|
+
```
|
|
112
270
|
|
|
113
|
-
|
|
271
|
+
### GitLab CI
|
|
272
|
+
|
|
273
|
+
```yaml
|
|
274
|
+
publish:
|
|
275
|
+
stage: deploy
|
|
276
|
+
image: node:20
|
|
277
|
+
before_script:
|
|
278
|
+
- npm install -g pnpm
|
|
279
|
+
- pnpm install
|
|
280
|
+
script:
|
|
281
|
+
- pnpm build
|
|
282
|
+
- npx tspublish
|
|
283
|
+
only:
|
|
284
|
+
- tags
|
|
285
|
+
```
|
|
114
286
|
|
|
115
|
-
|
|
287
|
+
## 📚 API Reference
|
|
288
|
+
|
|
289
|
+
### TsPublish Class
|
|
116
290
|
|
|
117
291
|
```typescript
|
|
118
|
-
|
|
292
|
+
class TsPublish {
|
|
293
|
+
// Publish all packages in a monorepo
|
|
294
|
+
async publish(monorepoDirPath: string): Promise<void>
|
|
295
|
+
|
|
296
|
+
// Get all publishable module configurations
|
|
297
|
+
async getModuleSubDirs(dirPath: string): Promise<{[key: string]: ITsPublishJson}>
|
|
298
|
+
}
|
|
119
299
|
```
|
|
120
300
|
|
|
121
|
-
|
|
301
|
+
### PublishModule Class
|
|
122
302
|
|
|
123
|
-
|
|
303
|
+
```typescript
|
|
304
|
+
class PublishModule {
|
|
305
|
+
// Initialize the module for publishing
|
|
306
|
+
async init(): Promise<void>
|
|
307
|
+
|
|
308
|
+
// Create the publishing directory structure
|
|
309
|
+
async createPublishModuleDir(): Promise<void>
|
|
310
|
+
|
|
311
|
+
// Build the TypeScript package
|
|
312
|
+
async build(): Promise<void>
|
|
313
|
+
|
|
314
|
+
// Publish to configured registries
|
|
315
|
+
async publish(): Promise<void>
|
|
316
|
+
}
|
|
317
|
+
```
|
|
124
318
|
|
|
125
|
-
|
|
319
|
+
### ITsPublishJson Interface
|
|
126
320
|
|
|
127
321
|
```typescript
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
322
|
+
interface ITsPublishJson {
|
|
323
|
+
name: string // Package name
|
|
324
|
+
order: number // Build order
|
|
325
|
+
dependencies: string[] // Dependencies to include
|
|
326
|
+
registries: string[] // Target registries
|
|
327
|
+
bin: string[] // CLI binaries
|
|
328
|
+
}
|
|
131
329
|
```
|
|
132
330
|
|
|
133
|
-
|
|
331
|
+
## 🐛 Troubleshooting
|
|
134
332
|
|
|
135
|
-
###
|
|
333
|
+
### Common Issues
|
|
136
334
|
|
|
137
|
-
|
|
335
|
+
**Package already exists with version X.X.X**
|
|
336
|
+
- TSPublish detected a version collision
|
|
337
|
+
- Update your monorepo's package.json version
|
|
338
|
+
- Or unpublish the existing version if appropriate
|
|
138
339
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
340
|
+
**No publish modules found**
|
|
341
|
+
- Ensure your packages follow the `ts-*` naming convention
|
|
342
|
+
- Check that each package has a valid `tspublish.json`
|
|
142
343
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
344
|
+
**Build failures**
|
|
345
|
+
- Verify TypeScript configuration
|
|
346
|
+
- Check that all dependencies are installed
|
|
347
|
+
- Review the build output for specific errors
|
|
147
348
|
|
|
148
|
-
|
|
149
|
-
```
|
|
349
|
+
## 🔮 Future Features
|
|
150
350
|
|
|
151
|
-
|
|
351
|
+
- 🎯 Selective publishing with pattern matching
|
|
352
|
+
- 🔄 Automatic version bumping strategies
|
|
353
|
+
- 📊 Dry-run mode with detailed preview
|
|
354
|
+
- 🏷️ Git tag integration
|
|
355
|
+
- 📝 Changelog generation
|
|
356
|
+
- 🔐 Enhanced authentication handling
|
|
152
357
|
|
|
153
|
-
|
|
358
|
+
## License and Legal Information
|
|
154
359
|
|
|
155
|
-
|
|
360
|
+
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
|
|
156
361
|
|
|
157
|
-
|
|
158
|
-
my-monorepo/
|
|
159
|
-
├── ts-package1/
|
|
160
|
-
│ ├── src/
|
|
161
|
-
│ ├── tspublish.json
|
|
162
|
-
├── ts-package2/
|
|
163
|
-
│ ├── src/
|
|
164
|
-
│ ├── tspublish.json
|
|
165
|
-
```
|
|
362
|
+
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
|
166
363
|
|
|
167
|
-
|
|
364
|
+
### Trademarks
|
|
168
365
|
|
|
169
|
-
|
|
170
|
-
2. Create a CLI script such as `publish.js`:
|
|
366
|
+
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
|
|
171
367
|
|
|
172
|
-
|
|
173
|
-
import { runCli } from '@git.zone/tspublish';
|
|
174
|
-
|
|
175
|
-
runCli()
|
|
176
|
-
.then(() => {
|
|
177
|
-
console.log('Publishing completed successfully');
|
|
178
|
-
})
|
|
179
|
-
.catch((error) => {
|
|
180
|
-
console.error('Error during publishing:', error);
|
|
181
|
-
});
|
|
182
|
-
```
|
|
368
|
+
### Company Information
|
|
183
369
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
```bash
|
|
187
|
-
node publish.js
|
|
188
|
-
```
|
|
370
|
+
Task Venture Capital GmbH
|
|
371
|
+
Registered at District court Bremen HRB 35230 HB, Germany
|
|
189
372
|
|
|
190
|
-
|
|
373
|
+
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
|
191
374
|
|
|
192
|
-
By
|
|
193
|
-
undefined
|
|
375
|
+
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
package/ts/00_commitinfo_data.ts
CHANGED
|
@@ -44,37 +44,42 @@ export class GiteaAssets {
|
|
|
44
44
|
branch?: string
|
|
45
45
|
): Promise<IRepoFile[]> {
|
|
46
46
|
try {
|
|
47
|
-
const
|
|
48
|
-
this.baseUrl + `/repos/${owner}/${repo}/contents/${directory}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
47
|
+
const requestBuilder = plugins.smartrequest.SmartRequest.create()
|
|
48
|
+
.url(this.baseUrl + `/repos/${owner}/${repo}/contents/${directory}`)
|
|
49
|
+
.headers(this.headers);
|
|
50
|
+
|
|
51
|
+
if (branch) {
|
|
52
|
+
requestBuilder.query({ ref: branch });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const response = await requestBuilder.get();
|
|
56
|
+
let responseBody = await response.json();
|
|
57
|
+
|
|
58
|
+
if (!Array.isArray(responseBody) && typeof responseBody === 'object') {
|
|
59
|
+
responseBody = [responseBody];
|
|
60
|
+
} else if (Array.isArray(responseBody)) {
|
|
61
|
+
for (const entry of responseBody) {
|
|
59
62
|
if (entry.type === 'dir') {
|
|
60
63
|
continue;
|
|
61
64
|
} else if (entry.type === 'file') {
|
|
62
|
-
const
|
|
63
|
-
this.baseUrl + `/repos/${owner}/${repo}/contents/${entry.path}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
const requestBuilder2 = plugins.smartrequest.SmartRequest.create()
|
|
66
|
+
.url(this.baseUrl + `/repos/${owner}/${repo}/contents/${entry.path}`)
|
|
67
|
+
.headers(this.headers);
|
|
68
|
+
|
|
69
|
+
if (branch) {
|
|
70
|
+
requestBuilder2.query({ ref: branch });
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const response2 = await requestBuilder2.get();
|
|
74
|
+
const response2Body = await response2.json();
|
|
75
|
+
entry.encoding = response2Body.encoding;
|
|
76
|
+
entry.content = response2Body.content;
|
|
72
77
|
}
|
|
73
78
|
}
|
|
74
79
|
}
|
|
75
80
|
|
|
76
81
|
// lets map to the IRepoFile interface
|
|
77
|
-
|
|
82
|
+
responseBody = responseBody.map((entry: any) => {
|
|
78
83
|
return {
|
|
79
84
|
name: entry.name,
|
|
80
85
|
path: entry.path,
|
|
@@ -85,7 +90,7 @@ export class GiteaAssets {
|
|
|
85
90
|
};
|
|
86
91
|
});
|
|
87
92
|
|
|
88
|
-
return
|
|
93
|
+
return responseBody;
|
|
89
94
|
} catch (error) {
|
|
90
95
|
console.error('Error fetching repository files:', error);
|
|
91
96
|
throw error;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as plugins from './plugins.js';
|
|
2
2
|
import * as paths from './paths.js';
|
|
3
|
-
import { logger } from './logging.js';
|
|
3
|
+
import { logger, logInfo, logSuccess, logWarn, logError, logBuild, logPublish, logOngoing, logStart, logDone } from './logging.js';
|
|
4
4
|
|
|
5
5
|
import { type ITsPublishJson } from './interfaces/index.js';
|
|
6
6
|
import type { TsPublish } from './classes.tspublish.js';
|
|
@@ -66,16 +66,15 @@ export class PublishModule {
|
|
|
66
66
|
try {
|
|
67
67
|
packageInfo = await smartnpmInstance.getPackageInfo(this.options.name);
|
|
68
68
|
} catch (error) {
|
|
69
|
-
|
|
69
|
+
logWarn(`Package ${this.options.name} does not yet seem to exist. Proceeding in 10 seconds...`);
|
|
70
70
|
await plugins.smartdelay.delayFor(10000);
|
|
71
71
|
}
|
|
72
72
|
if (packageInfo) {
|
|
73
73
|
const availableVersions = packageInfo.allVersions.map((versionArg) => versionArg.version);
|
|
74
|
-
|
|
74
|
+
logInfo(`Available versions for ${this.options.name}: ${availableVersions.join(', ')}`);
|
|
75
75
|
if (availableVersions.includes(this.options.version)) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
`package ${this.options.name} already exists with version ${this.options.version}`
|
|
76
|
+
logError(
|
|
77
|
+
`Package ${this.options.name} already exists with version ${this.options.version}`
|
|
79
78
|
);
|
|
80
79
|
process.exit(1);
|
|
81
80
|
}
|
|
@@ -162,6 +161,7 @@ export class PublishModule {
|
|
|
162
161
|
}
|
|
163
162
|
|
|
164
163
|
public async createPublishModuleDir() {
|
|
164
|
+
logOngoing(`Creating publish directory for ${this.options.name}`);
|
|
165
165
|
this.options.publishModDirFullPath = plugins.path.join(
|
|
166
166
|
this.options.monoRepoDir,
|
|
167
167
|
`dist_publish_${this.options.packageSubFolder}`
|
|
@@ -207,10 +207,12 @@ export class PublishModule {
|
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
public async build() {
|
|
210
|
+
logBuild(`Building ${this.options.name}...`);
|
|
210
211
|
const smartshellInstance = new plugins.smartshell.Smartshell({
|
|
211
212
|
executor: 'bash',
|
|
212
213
|
});
|
|
213
214
|
await smartshellInstance.exec(`cd ${this.options.publishModDirFullPath} && pnpm run build`);
|
|
215
|
+
logSuccess(`Build completed for ${this.options.name}`);
|
|
214
216
|
}
|
|
215
217
|
|
|
216
218
|
public async createBinCliSetup() {
|
|
@@ -223,10 +225,13 @@ export class PublishModule {
|
|
|
223
225
|
'cli',
|
|
224
226
|
'assets/templates/cli/cli.js'
|
|
225
227
|
);
|
|
226
|
-
|
|
228
|
+
const indexPath = `./dist_${this.options.packageSubFolder}/index.js`;
|
|
229
|
+
const fileContent = atob(files[0].base64Content).replace('./dist_ts/index.js', indexPath);
|
|
230
|
+
await plugins.smartfile.memory.toFs(fileContent, plugins.path.join(this.options.publishModDirFullPath, 'cli.js'));
|
|
227
231
|
}
|
|
228
232
|
|
|
229
233
|
public async publish() {
|
|
234
|
+
logPublish(`Publishing ${this.options.name} v${this.options.version}...`);
|
|
230
235
|
const smartshellInstance = new plugins.smartshell.Smartshell({
|
|
231
236
|
executor: 'bash',
|
|
232
237
|
});
|
|
@@ -240,5 +245,6 @@ export class PublishModule {
|
|
|
240
245
|
} --no-git-checks --registry https://${registryUrl}`
|
|
241
246
|
);
|
|
242
247
|
}
|
|
248
|
+
logSuccess(`Successfully published ${this.options.name} v${this.options.version}!`);
|
|
243
249
|
}
|
|
244
250
|
}
|