@ossy/cli 1.17.3 → 1.17.4
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/package.json +4 -4
- package/src/app/publish.js +44 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ossy/cli",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.4",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/ossy-se/packages.git"
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@babel/parser": "^7.28.6",
|
|
23
|
-
"@ossy/app": "^1.17.
|
|
24
|
-
"@ossy/sdk": "^1.17.
|
|
23
|
+
"@ossy/app": "^1.17.4",
|
|
24
|
+
"@ossy/sdk": "^1.17.4",
|
|
25
25
|
"arg": "^5.0.2",
|
|
26
26
|
"glob": "^10.3.10"
|
|
27
27
|
},
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"/src",
|
|
34
34
|
"README.md"
|
|
35
35
|
],
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "45251429b7b1f4cdf7f81a5046419905c3c118c9"
|
|
37
37
|
}
|
package/src/app/publish.js
CHANGED
|
@@ -101,7 +101,7 @@ export async function publish (options) {
|
|
|
101
101
|
const remoteDest = parsedArgs['--build-dest']
|
|
102
102
|
? normaliseLoc(parsedArgs['--build-dest'])
|
|
103
103
|
: domain
|
|
104
|
-
?
|
|
104
|
+
? `/@ossy/apps/${domain}`
|
|
105
105
|
: null
|
|
106
106
|
|
|
107
107
|
if (!remoteDest) {
|
|
@@ -134,6 +134,25 @@ export async function publish (options) {
|
|
|
134
134
|
|
|
135
135
|
let errors = 0
|
|
136
136
|
|
|
137
|
+
// Ensure the full remoteDest path exists (e.g. /sites then /sites/ossy.se)
|
|
138
|
+
const destSegments = remoteDest.replace(/^\//, '').split('/')
|
|
139
|
+
for (let i = 0; i < destSegments.length; i++) {
|
|
140
|
+
const parent = i === 0 ? '/' : '/' + destSegments.slice(0, i).join('/')
|
|
141
|
+
const name = destSegments[i]
|
|
142
|
+
try {
|
|
143
|
+
await sdk.makeRequest(createDir)({ location: parent, name })
|
|
144
|
+
} catch (err) {
|
|
145
|
+
const status = err && err.status
|
|
146
|
+
if (status !== 409 && status !== 422) {
|
|
147
|
+
logError({
|
|
148
|
+
message: `[@ossy/cli] app publish: mkdir failed for ${parent}/${name}: ${err?.message ?? err}`,
|
|
149
|
+
})
|
|
150
|
+
errors++
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Create all directories first (sequential; parents must exist before children)
|
|
137
156
|
for (const d of dirs) {
|
|
138
157
|
const rel = d.slice(buildDir.length)
|
|
139
158
|
const parent = normaliseLoc(remoteDest + path.dirname(rel))
|
|
@@ -151,7 +170,11 @@ export async function publish (options) {
|
|
|
151
170
|
}
|
|
152
171
|
}
|
|
153
172
|
|
|
154
|
-
|
|
173
|
+
// Upload files in parallel with a concurrency limit
|
|
174
|
+
const CONCURRENCY = 10
|
|
175
|
+
let completed = 0
|
|
176
|
+
|
|
177
|
+
async function uploadOne (f) {
|
|
155
178
|
const rel = f.slice(buildDir.length)
|
|
156
179
|
const remoteDir = normaliseLoc(remoteDest + path.dirname(rel))
|
|
157
180
|
|
|
@@ -161,7 +184,7 @@ export async function publish (options) {
|
|
|
161
184
|
} catch (err) {
|
|
162
185
|
logError({ message: `[@ossy/cli] app publish: cannot read file ${f}: ${err.message}` })
|
|
163
186
|
errors++
|
|
164
|
-
|
|
187
|
+
return
|
|
165
188
|
}
|
|
166
189
|
|
|
167
190
|
let result
|
|
@@ -175,14 +198,14 @@ export async function publish (options) {
|
|
|
175
198
|
} catch (err) {
|
|
176
199
|
logError({ message: `[@ossy/cli] app publish: upload failed for ${f}: ${err?.message ?? err}` })
|
|
177
200
|
errors++
|
|
178
|
-
|
|
201
|
+
return
|
|
179
202
|
}
|
|
180
203
|
|
|
181
204
|
const uploadUrl = result?.content?.uploadUrl
|
|
182
205
|
if (!uploadUrl) {
|
|
183
206
|
logError({ message: `[@ossy/cli] app publish: no uploadUrl in response for ${f}` })
|
|
184
207
|
errors++
|
|
185
|
-
|
|
208
|
+
return
|
|
186
209
|
}
|
|
187
210
|
|
|
188
211
|
try {
|
|
@@ -190,9 +213,25 @@ export async function publish (options) {
|
|
|
190
213
|
} catch (err) {
|
|
191
214
|
logError({ message: `[@ossy/cli] app publish: S3 PUT failed for ${f}: ${err.message}` })
|
|
192
215
|
errors++
|
|
216
|
+
return
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
completed++
|
|
220
|
+
if (completed % 50 === 0 || completed === files.length) {
|
|
221
|
+
logInfo({ message: `[@ossy/cli] app publish: ${completed}/${files.length} files uploaded…` })
|
|
193
222
|
}
|
|
194
223
|
}
|
|
195
224
|
|
|
225
|
+
// Run uploadOne over all files with max CONCURRENCY in-flight at once
|
|
226
|
+
const queue = [...files]
|
|
227
|
+
const workers = Array.from({ length: Math.min(CONCURRENCY, files.length) }, async () => {
|
|
228
|
+
while (queue.length > 0) {
|
|
229
|
+
const f = queue.shift()
|
|
230
|
+
if (f) await uploadOne(f)
|
|
231
|
+
}
|
|
232
|
+
})
|
|
233
|
+
await Promise.all(workers)
|
|
234
|
+
|
|
196
235
|
if (errors > 0) {
|
|
197
236
|
logError({
|
|
198
237
|
message: `[@ossy/cli] app publish: done with ${errors} error${errors === 1 ? '' : 's'}`,
|