create-platformatic 1.50.0 → 1.52.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/package.json +8 -9
- package/src/index.mjs +3 -14
- package/test/unit/fetch-stackables.mjs +4 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-platformatic",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.52.0",
|
|
4
4
|
"description": "Create platformatic application interactive tool",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -35,10 +35,9 @@
|
|
|
35
35
|
"strip-ansi": "^7.1.0",
|
|
36
36
|
"undici": "^6.9.0",
|
|
37
37
|
"which": "^3.0.1",
|
|
38
|
-
"@platformatic/config": "1.
|
|
39
|
-
"@platformatic/
|
|
40
|
-
"@platformatic/
|
|
41
|
-
"@platformatic/utils": "1.50.0"
|
|
38
|
+
"@platformatic/config": "1.52.0",
|
|
39
|
+
"@platformatic/utils": "1.52.0",
|
|
40
|
+
"@platformatic/generators": "1.52.0"
|
|
42
41
|
},
|
|
43
42
|
"devDependencies": {
|
|
44
43
|
"ajv": "^8.12.0",
|
|
@@ -52,10 +51,10 @@
|
|
|
52
51
|
"standard": "^17.1.0",
|
|
53
52
|
"typescript": "~5.5.0",
|
|
54
53
|
"yaml": "^2.4.1",
|
|
55
|
-
"@platformatic/composer": "1.
|
|
56
|
-
"@platformatic/db": "1.
|
|
57
|
-
"@platformatic/runtime": "1.
|
|
58
|
-
"@platformatic/service": "1.
|
|
54
|
+
"@platformatic/composer": "1.52.0",
|
|
55
|
+
"@platformatic/db": "1.52.0",
|
|
56
|
+
"@platformatic/runtime": "1.52.0",
|
|
57
|
+
"@platformatic/service": "1.52.0"
|
|
59
58
|
},
|
|
60
59
|
"scripts": {
|
|
61
60
|
"test:cli": "borp --pattern \"test/cli/*test.mjs\" --timeout 120000 --concurrency=1",
|
package/src/index.mjs
CHANGED
|
@@ -6,7 +6,6 @@ import { getUsername, getVersion, minimumSupportedNodeVersions, isCurrentVersion
|
|
|
6
6
|
import { createGitRepository } from './create-git-repository.mjs'
|
|
7
7
|
import { getPkgManager } from '@platformatic/utils'
|
|
8
8
|
import { StackableGenerator } from '@platformatic/generators'
|
|
9
|
-
import { getUserApiKey } from '@platformatic/authenticate'
|
|
10
9
|
import pino from 'pino'
|
|
11
10
|
import pretty from 'pino-pretty'
|
|
12
11
|
import { execa } from 'execa'
|
|
@@ -20,15 +19,10 @@ import resolve from 'resolve'
|
|
|
20
19
|
|
|
21
20
|
const MARKETPLACE_HOST = 'https://marketplace.platformatic.dev'
|
|
22
21
|
|
|
23
|
-
export async function fetchStackables (marketplaceHost
|
|
22
|
+
export async function fetchStackables (marketplaceHost) {
|
|
24
23
|
marketplaceHost = marketplaceHost || MARKETPLACE_HOST
|
|
25
24
|
|
|
26
|
-
const stackablesRequest = request(marketplaceHost + '/templates'
|
|
27
|
-
method: 'GET',
|
|
28
|
-
headers: {
|
|
29
|
-
'x-platformatic-user-api-key': userApiKey
|
|
30
|
-
}
|
|
31
|
-
})
|
|
25
|
+
const stackablesRequest = request(marketplaceHost + '/templates')
|
|
32
26
|
const stackablesRequestTimeout = setTimeout(5000, new Error('Request timed out'))
|
|
33
27
|
|
|
34
28
|
try {
|
|
@@ -36,9 +30,6 @@ export async function fetchStackables (marketplaceHost, userApiKey) {
|
|
|
36
30
|
stackablesRequest,
|
|
37
31
|
stackablesRequestTimeout
|
|
38
32
|
])
|
|
39
|
-
if (statusCode === 401 && userApiKey) {
|
|
40
|
-
return fetchStackables(marketplaceHost)
|
|
41
|
-
}
|
|
42
33
|
if (statusCode === 200) {
|
|
43
34
|
return (await body.json()).map(stackable => stackable.name)
|
|
44
35
|
}
|
|
@@ -159,9 +150,7 @@ async function createApplication (args, logger, pkgManager) {
|
|
|
159
150
|
await say('Using existing configuration')
|
|
160
151
|
}
|
|
161
152
|
|
|
162
|
-
const
|
|
163
|
-
const userApiKey = await getUserApiKey(globalConfigPath).catch(() => {})
|
|
164
|
-
const stackables = await fetchStackables(args['marketplace-host'], userApiKey)
|
|
153
|
+
const stackables = await fetchStackables(args['marketplace-host'])
|
|
165
154
|
|
|
166
155
|
const names = []
|
|
167
156
|
|
|
@@ -38,15 +38,9 @@ test('should fetch private stackables from the marketplace', async () => {
|
|
|
38
38
|
{ name: 'private-mock-service-1' }
|
|
39
39
|
]
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
mockPool.intercept({
|
|
43
|
-
path: '/templates',
|
|
44
|
-
headers: {
|
|
45
|
-
'x-platformatic-user-api-key': userApiKey
|
|
46
|
-
}
|
|
47
|
-
}).reply(200, mockStackables)
|
|
41
|
+
mockPool.intercept({ path: '/templates' }).reply(200, mockStackables)
|
|
48
42
|
|
|
49
|
-
const stackables = await fetchStackables(MARKETPLACE_HOST
|
|
43
|
+
const stackables = await fetchStackables(MARKETPLACE_HOST)
|
|
50
44
|
deepEqual(stackables, mockStackables.map(s => s.name))
|
|
51
45
|
})
|
|
52
46
|
|
|
@@ -57,17 +51,10 @@ test('should fetch only public stackables if user api key is wrong', async () =>
|
|
|
57
51
|
{ name: 'mock-service-3' }
|
|
58
52
|
]
|
|
59
53
|
|
|
60
|
-
|
|
61
|
-
mockPool.intercept({
|
|
62
|
-
path: '/templates',
|
|
63
|
-
headers: {
|
|
64
|
-
'x-platformatic-user-api-key': userApiKey
|
|
65
|
-
}
|
|
66
|
-
}).reply(401)
|
|
67
|
-
|
|
54
|
+
mockPool.intercept({ path: '/templates' }).reply(401)
|
|
68
55
|
mockPool.intercept({ path: '/templates' }).reply(200, mockStackables)
|
|
69
56
|
|
|
70
|
-
const stackables = await fetchStackables(MARKETPLACE_HOST
|
|
57
|
+
const stackables = await fetchStackables(MARKETPLACE_HOST)
|
|
71
58
|
deepEqual(stackables, mockStackables.map(s => s.name))
|
|
72
59
|
})
|
|
73
60
|
|