@whook/create 22.0.0 → 24.0.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/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/services/author.d.ts +1 -1
- package/dist/services/author.js +8 -14
- package/dist/services/author.js.map +1 -1
- package/dist/services/author.test.js +10 -14
- package/dist/services/author.test.js.map +1 -1
- package/dist/services/createWhook.test.js +28 -21
- package/dist/services/createWhook.test.js.map +1 -1
- package/dist/services/project.d.ts +1 -1
- package/dist/services/project.js +8 -16
- package/dist/services/project.js.map +1 -1
- package/dist/services/project.test.js +8 -16
- package/dist/services/project.test.js.map +1 -1
- package/package.json +10 -7
- package/src/index.ts +1 -1
- package/src/services/__snapshots__/author.test.ts.snap +24 -42
- package/src/services/__snapshots__/createWhook.test.ts.snap +32 -28
- package/src/services/__snapshots__/project.test.ts.snap +16 -32
- package/src/services/author.test.ts +11 -15
- package/src/services/author.ts +9 -18
- package/src/services/createWhook.test.ts +28 -21
- package/src/services/project.test.ts +9 -17
- package/src/services/project.ts +9 -19
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
import { describe, test, beforeEach, jest, expect } from '@jest/globals';
|
|
3
|
-
import _inquirer from 'inquirer';
|
|
3
|
+
import * as _inquirer from '@inquirer/prompts';
|
|
4
4
|
import initProject from './project.js';
|
|
5
5
|
import { YError } from 'yerror';
|
|
6
6
|
import { type LogService, type LockService } from 'common-services';
|
|
7
7
|
|
|
8
8
|
describe('initProject', () => {
|
|
9
9
|
const CWD = '/home/whoiam/projects/';
|
|
10
|
-
const inquirer = {
|
|
10
|
+
const inquirer = { input: jest.fn<any>() };
|
|
11
11
|
const lock = {
|
|
12
12
|
take: jest.fn<LockService<unknown>['take']>(),
|
|
13
13
|
release: jest.fn<LockService<unknown>['release']>(),
|
|
@@ -17,7 +17,7 @@ describe('initProject', () => {
|
|
|
17
17
|
|
|
18
18
|
beforeEach(() => {
|
|
19
19
|
lock.take.mockReset();
|
|
20
|
-
inquirer.
|
|
20
|
+
inquirer.input.mockReset();
|
|
21
21
|
lock.release.mockReset();
|
|
22
22
|
ensureDir.mockReset();
|
|
23
23
|
log.mockReset();
|
|
@@ -25,12 +25,8 @@ describe('initProject', () => {
|
|
|
25
25
|
|
|
26
26
|
test('should work', async () => {
|
|
27
27
|
lock.take.mockResolvedValueOnce(undefined);
|
|
28
|
-
inquirer.
|
|
29
|
-
|
|
30
|
-
});
|
|
31
|
-
inquirer.prompt.mockResolvedValueOnce({
|
|
32
|
-
projectDirectory: '/home/whoiam/projects/yolo',
|
|
33
|
-
});
|
|
28
|
+
inquirer.input.mockResolvedValueOnce('super-project');
|
|
29
|
+
inquirer.input.mockResolvedValueOnce('/home/whoiam/projects/yolo');
|
|
34
30
|
lock.release.mockResolvedValueOnce(undefined);
|
|
35
31
|
ensureDir.mockResolvedValueOnce(undefined);
|
|
36
32
|
|
|
@@ -44,7 +40,7 @@ describe('initProject', () => {
|
|
|
44
40
|
|
|
45
41
|
expect({
|
|
46
42
|
project,
|
|
47
|
-
inquirerPromptCalls: inquirer.
|
|
43
|
+
inquirerPromptCalls: inquirer.input.mock.calls,
|
|
48
44
|
lockTakeCalls: lock.take.mock.calls,
|
|
49
45
|
lockReleaseCalls: lock.release.mock.calls,
|
|
50
46
|
ensureDirCalls: ensureDir.mock.calls,
|
|
@@ -55,12 +51,8 @@ describe('initProject', () => {
|
|
|
55
51
|
test('should fail with access problems', async () => {
|
|
56
52
|
lock.take.mockResolvedValueOnce(undefined);
|
|
57
53
|
lock.release.mockResolvedValueOnce(undefined);
|
|
58
|
-
inquirer.
|
|
59
|
-
|
|
60
|
-
});
|
|
61
|
-
inquirer.prompt.mockResolvedValueOnce({
|
|
62
|
-
projectDirectory: '/home/whoiam/projects/yolo',
|
|
63
|
-
});
|
|
54
|
+
inquirer.input.mockResolvedValueOnce('super-project');
|
|
55
|
+
inquirer.input.mockResolvedValueOnce('/home/whoiam/projects/yolo');
|
|
64
56
|
ensureDir.mockRejectedValueOnce(new YError('E_ACCESS'));
|
|
65
57
|
|
|
66
58
|
try {
|
|
@@ -76,7 +68,7 @@ describe('initProject', () => {
|
|
|
76
68
|
expect({
|
|
77
69
|
errorCode: (err as YError).code,
|
|
78
70
|
errorDebug: (err as YError).debug,
|
|
79
|
-
inquirerPromptCalls: inquirer.
|
|
71
|
+
inquirerPromptCalls: inquirer.input.mock.calls,
|
|
80
72
|
lockTakeCalls: lock.take.mock.calls,
|
|
81
73
|
lockReleaseCalls: lock.release.mock.calls,
|
|
82
74
|
ensureDirCalls: ensureDir.mock.calls,
|
package/src/services/project.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { autoService } from 'knifecycle';
|
|
2
2
|
import { default as fsExtra } from 'fs-extra';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
-
import _inquirer from 'inquirer';
|
|
4
|
+
import * as _inquirer from '@inquirer/prompts';
|
|
5
5
|
import { printStackTrace, YError } from 'yerror';
|
|
6
6
|
import { type LockService, type LogService } from 'common-services';
|
|
7
7
|
|
|
@@ -30,25 +30,15 @@ export default autoService(async function initProject({
|
|
|
30
30
|
try {
|
|
31
31
|
await lock.take('cli:input');
|
|
32
32
|
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
type: 'input',
|
|
38
|
-
default: DEFAULT_PROJECT_NAME,
|
|
39
|
-
},
|
|
40
|
-
]);
|
|
33
|
+
const projectName = await inquirer.input({
|
|
34
|
+
message: "What's this new project name",
|
|
35
|
+
default: DEFAULT_PROJECT_NAME,
|
|
36
|
+
});
|
|
41
37
|
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
name: 'projectDirectory',
|
|
47
|
-
message: "Provide the project's directory",
|
|
48
|
-
type: 'input',
|
|
49
|
-
default: path.join(CWD, projectName),
|
|
50
|
-
},
|
|
51
|
-
]);
|
|
38
|
+
const projectDirectory = await inquirer.input({
|
|
39
|
+
message: "Provide the project's directory",
|
|
40
|
+
default: path.join(CWD, projectName),
|
|
41
|
+
});
|
|
52
42
|
await lock.release('cli:input');
|
|
53
43
|
|
|
54
44
|
try {
|