create-platformatic 2.0.0-alpha.2 → 2.0.0-alpha.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/create-platformatic.mjs +2 -2
- package/eslint.config.js +3 -0
- package/package.json +15 -15
- package/src/index.mjs +52 -44
- package/src/utils.mjs +14 -22
- package/test/cli/composer.test.mjs +45 -41
- package/test/cli/db.test.mjs +52 -46
- package/test/cli/helper.mjs +5 -5
- package/test/cli/runtime.test.mjs +60 -52
- package/test/cli/service.test.mjs +126 -104
- package/test/cli/stackable.test.mjs +53 -40
- package/test/unit/create-git-repository.test.mjs +17 -11
- package/test/unit/fetch-stackables.mjs +4 -4
- package/test/unit/utils.test.mjs +46 -44
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { safeRemove } from '@platformatic/utils'
|
|
2
2
|
import { equal } from 'node:assert'
|
|
3
|
-
import {
|
|
3
|
+
import { mkdtemp } from 'node:fs/promises'
|
|
4
4
|
import { tmpdir } from 'node:os'
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { join } from 'node:path'
|
|
6
|
+
import { test } from 'node:test'
|
|
7
7
|
import { isFileAccessible } from '../../src/utils.mjs'
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
startMarketplace,
|
|
11
|
-
keys,
|
|
12
|
-
walk,
|
|
13
|
-
getServices
|
|
14
|
-
} from './helper.mjs'
|
|
8
|
+
import { executeCreatePlatformatic, getServices, keys, startMarketplace, walk } from './helper.mjs'
|
|
9
|
+
import { timeout } from './timeout.mjs'
|
|
15
10
|
|
|
16
11
|
let tmpDir
|
|
17
12
|
test.beforeEach(async () => {
|
|
@@ -20,56 +15,69 @@ test.beforeEach(async () => {
|
|
|
20
15
|
|
|
21
16
|
test.afterEach(async () => {
|
|
22
17
|
try {
|
|
23
|
-
await
|
|
18
|
+
await safeRemove(tmpDir)
|
|
24
19
|
} catch (e) {
|
|
25
20
|
// on purpose, in win the resource might be still "busy"
|
|
26
21
|
}
|
|
27
22
|
})
|
|
28
23
|
|
|
29
|
-
test('Creates a Platformatic Runtime with two Services', { timeout }, async
|
|
24
|
+
test('Creates a Platformatic Runtime with two Services', { timeout }, async t => {
|
|
30
25
|
const marketplaceHost = await startMarketplace(t)
|
|
31
26
|
// The actions must match IN ORDER
|
|
32
|
-
const actions = [
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
27
|
+
const actions = [
|
|
28
|
+
{
|
|
29
|
+
match: 'What kind of project do you want to create?',
|
|
30
|
+
do: [keys.ENTER], // Application
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
match: 'Where would you like to create your project?',
|
|
34
|
+
do: [keys.ENTER],
|
|
35
|
+
waitAfter: 8000,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
match: 'Which kind of project do you want to create?',
|
|
39
|
+
do: [keys.ENTER], // Service
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
match: 'What is the name of the service?',
|
|
43
|
+
do: [keys.ENTER],
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
match: 'Do you want to create another service?',
|
|
47
|
+
do: [keys.ENTER], // yes
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
match: 'Which kind of project do you want to create?',
|
|
51
|
+
do: [keys.ENTER], // Service
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
match: 'What is the name of the service?',
|
|
55
|
+
do: [keys.ENTER],
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
match: 'Do you want to create another service?',
|
|
59
|
+
do: [keys.DOWN, keys.ENTER], // no
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
match: 'Which service should be exposed?',
|
|
63
|
+
do: [keys.ENTER],
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
match: 'Do you want to use TypeScript',
|
|
67
|
+
do: [keys.DOWN, keys.ENTER], // yes
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
match: 'What port do you want to use?',
|
|
71
|
+
do: [keys.ENTER],
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
match: 'Do you want to init the git repository',
|
|
75
|
+
do: [keys.DOWN, keys.ENTER], // yes
|
|
76
|
+
},
|
|
77
|
+
]
|
|
70
78
|
await executeCreatePlatformatic(tmpDir, actions, {
|
|
71
79
|
marketplaceHost,
|
|
72
|
-
pkgManager: 'pnpm'
|
|
80
|
+
pkgManager: 'pnpm',
|
|
73
81
|
})
|
|
74
82
|
|
|
75
83
|
const baseProjectDir = join(tmpDir, 'platformatic')
|
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createDirectory, safeRemove } from '@platformatic/utils'
|
|
2
2
|
import { equal, notEqual } from 'node:assert'
|
|
3
|
-
import {
|
|
4
|
-
import { isFileAccessible, safeMkdir } from '../../src/utils.mjs'
|
|
3
|
+
import { mkdtemp, readFile, writeFile } from 'node:fs/promises'
|
|
5
4
|
import { join } from 'node:path'
|
|
5
|
+
import { test } from 'node:test'
|
|
6
6
|
import { tmpdir } from 'os'
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
startMarketplace,
|
|
11
|
-
keys,
|
|
12
|
-
walk,
|
|
13
|
-
getServices
|
|
14
|
-
} from './helper.mjs'
|
|
7
|
+
import { isFileAccessible } from '../../src/utils.mjs'
|
|
8
|
+
import { executeCreatePlatformatic, getServices, keys, startMarketplace, walk } from './helper.mjs'
|
|
9
|
+
import { timeout } from './timeout.mjs'
|
|
15
10
|
|
|
16
11
|
let tmpDir
|
|
17
12
|
test.beforeEach(async () => {
|
|
@@ -20,42 +15,51 @@ test.beforeEach(async () => {
|
|
|
20
15
|
|
|
21
16
|
test.afterEach(async () => {
|
|
22
17
|
try {
|
|
23
|
-
await
|
|
18
|
+
await safeRemove(tmpDir)
|
|
24
19
|
} catch (e) {
|
|
25
20
|
// on purpose, in win the resource might be still "busy"
|
|
26
21
|
}
|
|
27
22
|
})
|
|
28
23
|
|
|
29
|
-
test('Creates a Platformatic Service with no typescript', { timeout }, async
|
|
24
|
+
test('Creates a Platformatic Service with no typescript', { timeout }, async t => {
|
|
30
25
|
const marketplaceHost = await startMarketplace(t)
|
|
31
26
|
// The actions must match IN ORDER
|
|
32
|
-
const actions = [
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
27
|
+
const actions = [
|
|
28
|
+
{
|
|
29
|
+
match: 'What kind of project do you want to create?',
|
|
30
|
+
do: [keys.ENTER], // Application
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
match: 'Where would you like to create your project?',
|
|
34
|
+
do: [keys.ENTER],
|
|
35
|
+
waitAfter: 8000,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
match: 'Which kind of project do you want to create?',
|
|
39
|
+
do: [keys.ENTER], // Service
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
match: 'What is the name of the service?',
|
|
43
|
+
do: [keys.ENTER],
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
match: 'Do you want to create another service?',
|
|
47
|
+
do: [keys.DOWN, keys.ENTER], // no
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
// NOTE THAT HERE THE DEFAULT OPTION FOR SERVICE IS "YES"
|
|
51
|
+
match: 'Do you want to use TypeScript',
|
|
52
|
+
do: [keys.ENTER], // no
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
match: 'What port do you want to use?',
|
|
56
|
+
do: [keys.ENTER],
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
match: 'Do you want to init the git repository',
|
|
60
|
+
do: [keys.DOWN, keys.ENTER], // yes
|
|
61
|
+
},
|
|
62
|
+
]
|
|
59
63
|
await executeCreatePlatformatic(tmpDir, actions, { marketplaceHost })
|
|
60
64
|
|
|
61
65
|
const baseProjectDir = join(tmpDir, 'platformatic')
|
|
@@ -78,36 +82,45 @@ test('Creates a Platformatic Service with no typescript', { timeout }, async (t)
|
|
|
78
82
|
equal(await isFileAccessible(join(baseServiceDir, 'plugins', 'example.js')), true)
|
|
79
83
|
})
|
|
80
84
|
|
|
81
|
-
test('Creates a Platformatic Service with typescript', { timeout }, async
|
|
85
|
+
test('Creates a Platformatic Service with typescript', { timeout }, async t => {
|
|
82
86
|
const marketplaceHost = await startMarketplace(t)
|
|
83
87
|
// The actions must match IN ORDER
|
|
84
|
-
const actions = [
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
88
|
+
const actions = [
|
|
89
|
+
{
|
|
90
|
+
match: 'What kind of project do you want to create?',
|
|
91
|
+
do: [keys.ENTER], // Application
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
match: 'Where would you like to create your project?',
|
|
95
|
+
do: [keys.ENTER],
|
|
96
|
+
waitAfter: 8000,
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
match: 'Which kind of project do you want to create?',
|
|
100
|
+
do: [keys.ENTER], // Service
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
match: 'What is the name of the service?',
|
|
104
|
+
do: [keys.ENTER],
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
match: 'Do you want to create another service?',
|
|
108
|
+
do: [keys.DOWN, keys.ENTER], // no
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
// NOTE THAT HERE THE DEFAULT OPTION FOR SERVICE IS "YES"
|
|
112
|
+
match: 'Do you want to use TypeScript',
|
|
113
|
+
do: [keys.DOWN, keys.ENTER], // no
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
match: 'What port do you want to use?',
|
|
117
|
+
do: [keys.ENTER],
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
match: 'Do you want to init the git repository',
|
|
121
|
+
do: [keys.DOWN, keys.ENTER], // yes
|
|
122
|
+
},
|
|
123
|
+
]
|
|
111
124
|
await executeCreatePlatformatic(tmpDir, actions, { marketplaceHost })
|
|
112
125
|
|
|
113
126
|
const baseProjectDir = join(tmpDir, 'platformatic')
|
|
@@ -130,58 +143,67 @@ test('Creates a Platformatic Service with typescript', { timeout }, async (t) =>
|
|
|
130
143
|
equal(await isFileAccessible(join(baseServiceDir, 'plugins', 'example.ts')), true)
|
|
131
144
|
})
|
|
132
145
|
|
|
133
|
-
test('Creates a Platformatic Service in a non empty directory', { timeout, skip: true }, async
|
|
146
|
+
test('Creates a Platformatic Service in a non empty directory', { timeout, skip: true }, async t => {
|
|
134
147
|
const marketplaceHost = await startMarketplace(t)
|
|
135
148
|
const targetDirectory = join(tmpdir(), 'platformatic-service-test')
|
|
136
149
|
// const targetDirectory = '/tmp/tst'
|
|
137
150
|
async function generateServiceFileStructure (dir) {
|
|
138
151
|
const servicesDir = join(dir, 'services')
|
|
139
|
-
await
|
|
152
|
+
await createDirectory(servicesDir)
|
|
140
153
|
|
|
141
154
|
const serviceDir = join(servicesDir, 'foo')
|
|
142
|
-
await
|
|
143
|
-
await
|
|
155
|
+
await createDirectory(join(serviceDir, 'plugins'))
|
|
156
|
+
await createDirectory(join(serviceDir, 'routes'))
|
|
144
157
|
|
|
145
158
|
await writeFile(join(dir, '.env'), 'SAMPLE_ENV=foobar\n')
|
|
146
159
|
|
|
147
160
|
// creates 2 files. root.js will be overwritten
|
|
148
|
-
await writeFile(join(serviceDir, 'routes', 'root.js'),
|
|
149
|
-
await writeFile(join(serviceDir, 'routes', 'sample.js'),
|
|
161
|
+
await writeFile(join(serviceDir, 'routes', 'root.js'), "console.log('hello world')")
|
|
162
|
+
await writeFile(join(serviceDir, 'routes', 'sample.js'), "console.log('hello world')")
|
|
150
163
|
}
|
|
151
164
|
// generate a sample file structure
|
|
152
165
|
await generateServiceFileStructure(targetDirectory)
|
|
153
166
|
|
|
154
167
|
test.after(async () => {
|
|
155
|
-
await
|
|
168
|
+
await safeRemove(targetDirectory)
|
|
156
169
|
})
|
|
157
170
|
// The actions must match IN ORDER
|
|
158
|
-
const actions = [
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
171
|
+
const actions = [
|
|
172
|
+
{
|
|
173
|
+
match: 'What kind of project do you want to create?',
|
|
174
|
+
do: [keys.ENTER], // Application
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
match: 'Where would you like to create your project?',
|
|
178
|
+
do: [targetDirectory, keys.ENTER],
|
|
179
|
+
waitAfter: 8000,
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
match: 'Confirm you want to use',
|
|
183
|
+
do: [keys.ENTER], // confirm use existing directory
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
// NOTE THAT HERE THE DEFAULT OPTION FOR SERVICE IS "YES"
|
|
187
|
+
match: 'Do you want to use TypeScript',
|
|
188
|
+
do: [keys.DOWN, keys.ENTER], // no
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
match: 'What port do you want to use?',
|
|
192
|
+
do: [keys.ENTER],
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
match: 'Do you want to create the github action to deploy',
|
|
196
|
+
do: [keys.DOWN, keys.ENTER],
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
match: 'Do you want to enable PR Previews in your application',
|
|
200
|
+
do: [keys.DOWN, keys.ENTER],
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
match: 'Do you want to init the git repository',
|
|
204
|
+
do: [keys.DOWN, keys.ENTER], // yes
|
|
205
|
+
},
|
|
206
|
+
]
|
|
185
207
|
await executeCreatePlatformatic(tmpDir, actions, { marketplaceHost })
|
|
186
208
|
|
|
187
209
|
equal(await isFileAccessible(join(targetDirectory, '.gitignore')), true)
|
|
@@ -195,6 +217,6 @@ test('Creates a Platformatic Service in a non empty directory', { timeout, skip:
|
|
|
195
217
|
equal(await isFileAccessible(join(targetDirectory, '.git', 'config')), true)
|
|
196
218
|
|
|
197
219
|
// check file contents
|
|
198
|
-
notEqual(await readFile(join(targetDirectory, 'routes', 'root.js'), 'utf8'),
|
|
199
|
-
equal(await readFile(join(targetDirectory, 'routes', 'sample.js'), 'utf8'),
|
|
220
|
+
notEqual(await readFile(join(targetDirectory, 'routes', 'root.js'), 'utf8'), "console.log('hello world')")
|
|
221
|
+
equal(await readFile(join(targetDirectory, 'routes', 'sample.js'), 'utf8'), "console.log('hello world')")
|
|
200
222
|
})
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { safeRemove } from '@platformatic/utils'
|
|
2
2
|
import { equal } from 'node:assert'
|
|
3
|
-
import {
|
|
4
|
-
import { timeout } from './timeout.mjs'
|
|
5
|
-
import { isFileAccessible } from '../../src/utils.mjs'
|
|
3
|
+
import { mkdtemp } from 'node:fs/promises'
|
|
6
4
|
import { join } from 'node:path'
|
|
5
|
+
import { test } from 'node:test'
|
|
7
6
|
import { tmpdir } from 'os'
|
|
8
|
-
import {
|
|
7
|
+
import { isFileAccessible } from '../../src/utils.mjs'
|
|
8
|
+
import { executeCreatePlatformatic, keys, walk } from './helper.mjs'
|
|
9
|
+
import { timeout } from './timeout.mjs'
|
|
9
10
|
|
|
10
11
|
let tmpDir
|
|
11
12
|
test.beforeEach(async () => {
|
|
@@ -14,7 +15,7 @@ test.beforeEach(async () => {
|
|
|
14
15
|
|
|
15
16
|
test.afterEach(async () => {
|
|
16
17
|
try {
|
|
17
|
-
await
|
|
18
|
+
await safeRemove(tmpDir)
|
|
18
19
|
} catch (e) {
|
|
19
20
|
// on purpose, in win the resource might be still "busy"
|
|
20
21
|
}
|
|
@@ -22,24 +23,30 @@ test.afterEach(async () => {
|
|
|
22
23
|
|
|
23
24
|
test('Creates a Platformatic Stackable without typescript', { timeout }, async () => {
|
|
24
25
|
// The actions must match IN ORDER
|
|
25
|
-
const actions = [
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
26
|
+
const actions = [
|
|
27
|
+
{
|
|
28
|
+
match: 'What kind of project do you want to create?',
|
|
29
|
+
do: [keys.DOWN, keys.ENTER], // Stackable
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
match: 'Where would you like to create your project?',
|
|
33
|
+
do: [keys.ENTER],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
match: 'What is the name of the stackable?',
|
|
37
|
+
do: [keys.ENTER], // my-stackable
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
match: 'Do you want to use TypeScript',
|
|
41
|
+
do: [keys.ENTER], // no
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
match: 'Do you want to init the git repository',
|
|
45
|
+
do: [keys.DOWN, keys.ENTER], // yes
|
|
46
|
+
},
|
|
47
|
+
]
|
|
41
48
|
await executeCreatePlatformatic(tmpDir, actions, {
|
|
42
|
-
done: 'Stackable created successfully!'
|
|
49
|
+
done: 'Stackable created successfully!',
|
|
43
50
|
})
|
|
44
51
|
|
|
45
52
|
const baseProjectDir = join(tmpDir, 'platformatic')
|
|
@@ -62,24 +69,30 @@ test('Creates a Platformatic Stackable without typescript', { timeout }, async (
|
|
|
62
69
|
|
|
63
70
|
test('Creates a Platformatic Stackable with typescript', { timeout }, async () => {
|
|
64
71
|
// The actions must match IN ORDER
|
|
65
|
-
const actions = [
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
72
|
+
const actions = [
|
|
73
|
+
{
|
|
74
|
+
match: 'What kind of project do you want to create?',
|
|
75
|
+
do: [keys.DOWN, keys.ENTER], // Stackable
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
match: 'Where would you like to create your project?',
|
|
79
|
+
do: [keys.ENTER],
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
match: 'What is the name of the stackable?',
|
|
83
|
+
do: [keys.ENTER], // my-stackable
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
match: 'Do you want to use TypeScript',
|
|
87
|
+
do: [keys.DOWN, keys.ENTER], // yes
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
match: 'Do you want to init the git repository',
|
|
91
|
+
do: [keys.ENTER], // no
|
|
92
|
+
},
|
|
93
|
+
]
|
|
81
94
|
await executeCreatePlatformatic(tmpDir, actions, {
|
|
82
|
-
done: 'Stackable created successfully!'
|
|
95
|
+
done: 'Stackable created successfully!',
|
|
83
96
|
})
|
|
84
97
|
|
|
85
98
|
const baseProjectDir = join(tmpDir, 'platformatic')
|
|
@@ -1,34 +1,40 @@
|
|
|
1
|
-
import { tmpdir } from 'os'
|
|
2
|
-
import { join } from 'path'
|
|
3
1
|
import { execa } from 'execa'
|
|
4
|
-
import { test } from 'node:test'
|
|
5
2
|
import { equal, match } from 'node:assert'
|
|
3
|
+
import { test } from 'node:test'
|
|
4
|
+
import { tmpdir } from 'os'
|
|
5
|
+
import { join } from 'path'
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { createDirectory } from '@platformatic/utils'
|
|
8
|
+
import { writeFile } from 'fs/promises'
|
|
8
9
|
import { createGitRepository, GIT_FIRST_COMMIT_MESSAGE, GIT_MAIN_BRANCH } from '../../src/create-git-repository.mjs'
|
|
9
|
-
import {
|
|
10
|
+
import { isFileAccessible } from '../../src/utils.mjs'
|
|
10
11
|
|
|
11
12
|
const loggerSpy = {
|
|
12
13
|
_debug: [],
|
|
13
14
|
_info: [],
|
|
14
15
|
_error: [],
|
|
15
16
|
|
|
16
|
-
debug: function (...args) {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
debug: function (...args) {
|
|
18
|
+
this._debug.push(args)
|
|
19
|
+
},
|
|
20
|
+
info: function (...args) {
|
|
21
|
+
this._info.push(args)
|
|
22
|
+
},
|
|
23
|
+
error: function (...args) {
|
|
24
|
+
this._error.push(args)
|
|
25
|
+
},
|
|
19
26
|
|
|
20
27
|
reset: function () {
|
|
21
28
|
this._debug = []
|
|
22
29
|
this._info = []
|
|
23
30
|
this._error = []
|
|
24
|
-
}
|
|
31
|
+
},
|
|
25
32
|
}
|
|
26
33
|
|
|
27
34
|
const tmpDir = join(tmpdir(), 'test-create-platformatic-git-repo')
|
|
28
35
|
test.beforeEach(async () => {
|
|
29
36
|
loggerSpy.reset()
|
|
30
|
-
await
|
|
31
|
-
await mkdir(tmpDir, { recursive: true })
|
|
37
|
+
await createDirectory(tmpDir, true)
|
|
32
38
|
})
|
|
33
39
|
|
|
34
40
|
test('should create the git repo', async () => {
|
|
@@ -6,7 +6,7 @@ import { setTimeout } from 'node:timers/promises'
|
|
|
6
6
|
|
|
7
7
|
const mockAgent = new MockAgent({
|
|
8
8
|
keepAliveTimeout: 10,
|
|
9
|
-
keepAliveMaxTimeout: 10
|
|
9
|
+
keepAliveMaxTimeout: 10,
|
|
10
10
|
})
|
|
11
11
|
mockAgent.disableNetConnect()
|
|
12
12
|
|
|
@@ -21,7 +21,7 @@ test('should fetch stackables from the marketplace', async () => {
|
|
|
21
21
|
const mockStackables = [
|
|
22
22
|
{ name: 'mock-service-1' },
|
|
23
23
|
{ name: 'mock-service-2' },
|
|
24
|
-
{ name: 'mock-service-3' }
|
|
24
|
+
{ name: 'mock-service-3' },
|
|
25
25
|
]
|
|
26
26
|
|
|
27
27
|
mockPool.intercept({ path: '/templates' }).reply(200, mockStackables)
|
|
@@ -35,7 +35,7 @@ test('should fetch private stackables from the marketplace', async () => {
|
|
|
35
35
|
{ name: 'mock-service-1' },
|
|
36
36
|
{ name: 'mock-service-2' },
|
|
37
37
|
{ name: 'mock-service-3' },
|
|
38
|
-
{ name: 'private-mock-service-1' }
|
|
38
|
+
{ name: 'private-mock-service-1' },
|
|
39
39
|
]
|
|
40
40
|
|
|
41
41
|
mockPool.intercept({ path: '/templates' }).reply(200, mockStackables)
|
|
@@ -48,7 +48,7 @@ test('should fetch only public stackables if user api key is wrong', async () =>
|
|
|
48
48
|
const mockStackables = [
|
|
49
49
|
{ name: 'mock-service-1' },
|
|
50
50
|
{ name: 'mock-service-2' },
|
|
51
|
-
{ name: 'mock-service-3' }
|
|
51
|
+
{ name: 'mock-service-3' },
|
|
52
52
|
]
|
|
53
53
|
|
|
54
54
|
mockPool.intercept({ path: '/templates' }).reply(401)
|