@commercetools-frontend/create-mc-app 22.8.0 → 22.8.2
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/CHANGELOG.md +4 -0
- package/dist/commercetools-frontend-create-mc-app.cjs.dev.js +82 -35
- package/dist/commercetools-frontend-create-mc-app.cjs.prod.js +82 -35
- package/dist/commercetools-frontend-create-mc-app.esm.js +82 -35
- package/dist/declarations/src/constants.d.ts +9 -0
- package/dist/declarations/src/tasks/index.d.ts +1 -1
- package/dist/declarations/src/tasks/update-application-config.d.ts +4 -0
- package/dist/declarations/src/types.d.ts +6 -2
- package/dist/declarations/src/utils.d.ts +3 -2
- package/dist/declarations/src/validations.d.ts +3 -2
- package/package.json +1 -1
- package/src/cli.ts +11 -3
- package/src/constants.ts +11 -0
- package/src/process-options.ts +11 -3
- package/src/tasks/download-template.ts +7 -4
- package/src/tasks/index.ts +1 -1
- package/src/tasks/{update-custom-application-config.ts → update-application-config.ts} +34 -17
- package/src/tasks/update-application-constants.ts +6 -4
- package/src/tasks/update-package-json.ts +3 -3
- package/src/types.ts +7 -2
- package/src/utils.ts +10 -2
- package/src/validations.ts +27 -8
- package/dist/declarations/src/tasks/update-custom-application-config.d.ts +0 -4
package/src/types.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
import { applicationTypes, availableTemplates } from './constants';
|
|
2
|
+
|
|
1
3
|
export type TCliGlobalOptions = {
|
|
2
4
|
'--'?: string[];
|
|
3
5
|
};
|
|
4
6
|
|
|
5
|
-
export type
|
|
7
|
+
export type TApplicationType = keyof typeof applicationTypes;
|
|
8
|
+
export type TTemplate = keyof typeof availableTemplates;
|
|
6
9
|
export type TPackageManager = 'npm' | 'yarn' | 'pnpm';
|
|
7
10
|
|
|
8
11
|
export type TCliCommandOptions = {
|
|
12
|
+
applicationType: TApplicationType;
|
|
9
13
|
template: TTemplate;
|
|
10
14
|
templateVersion: string;
|
|
11
15
|
skipInstall: boolean;
|
|
@@ -16,11 +20,12 @@ export type TCliCommandOptions = {
|
|
|
16
20
|
};
|
|
17
21
|
|
|
18
22
|
export type TCliTaskOptions = {
|
|
23
|
+
applicationType: TApplicationType;
|
|
19
24
|
projectDirectoryName: string;
|
|
20
25
|
projectDirectoryPath: string;
|
|
21
26
|
templateName: TCliCommandOptions['template'];
|
|
22
27
|
tagOrBranchVersion: string;
|
|
23
|
-
entryPointUriPath
|
|
28
|
+
entryPointUriPath?: string;
|
|
24
29
|
initialProjectKey: string;
|
|
25
30
|
packageManager: TCliCommandOptions['packageManager'];
|
|
26
31
|
};
|
package/src/utils.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
1
|
+
import fs from 'node:fs';
|
|
2
2
|
import execa from 'execa';
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
TApplicationType,
|
|
5
|
+
TCliTaskOptions,
|
|
6
|
+
TPackageManager,
|
|
7
|
+
} from './types';
|
|
4
8
|
|
|
5
9
|
const isSemVer = (version: string) => /^(v?)([0-9].[0-9].[0-9])+/.test(version);
|
|
6
10
|
|
|
@@ -57,6 +61,9 @@ const resolveFilePathByExtension = (requestedModule: string) => {
|
|
|
57
61
|
return `${requestedModule}${fileExtension}`;
|
|
58
62
|
};
|
|
59
63
|
|
|
64
|
+
const isCustomView = (applicationType: TApplicationType) =>
|
|
65
|
+
applicationType === 'custom-view';
|
|
66
|
+
|
|
60
67
|
export {
|
|
61
68
|
isSemVer,
|
|
62
69
|
shouldUseYarn,
|
|
@@ -66,4 +73,5 @@ export {
|
|
|
66
73
|
resolveFilePathByExtension,
|
|
67
74
|
getPreferredPackageManager,
|
|
68
75
|
getInstallCommand,
|
|
76
|
+
isCustomView,
|
|
69
77
|
};
|
package/src/validations.ts
CHANGED
|
@@ -1,24 +1,42 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
3
|
import semver from 'semver';
|
|
4
|
-
import
|
|
4
|
+
import { applicationTypes, availableTemplates } from './constants';
|
|
5
|
+
import type { TApplicationType, TTemplate } from './types';
|
|
5
6
|
import { isSemVer } from './utils';
|
|
6
7
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const throwIfApplicationTypeIsNotSupported = (
|
|
9
|
+
applicationType: TApplicationType
|
|
10
|
+
) => {
|
|
11
|
+
switch (applicationType) {
|
|
12
|
+
case applicationTypes['custom-view']: {
|
|
13
|
+
if (process.env.ENABLE_EXPERIMENTAL_CUSTOM_VIEWS !== 'true') {
|
|
14
|
+
throw new Error(`Custom Views generation is not yet supported.`);
|
|
15
|
+
}
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
case applicationTypes['custom-application']:
|
|
19
|
+
break;
|
|
20
|
+
default: {
|
|
21
|
+
const applicationTypesList = Object.keys(applicationTypes).toString();
|
|
22
|
+
throw new Error(
|
|
23
|
+
`The provided application type "${applicationType}" does not exist. Available types are "${applicationTypesList}". Make sure you are also using the latest version of "@commercetools-frontend/create-mc-app".`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
11
28
|
|
|
12
29
|
const throwIfTemplateIsNotSupported = (templateName: TTemplate) => {
|
|
13
30
|
switch (templateName) {
|
|
14
31
|
case availableTemplates.starter:
|
|
15
32
|
case availableTemplates['starter-typescript']:
|
|
16
33
|
break;
|
|
17
|
-
default:
|
|
34
|
+
default: {
|
|
18
35
|
const templateNamesList = Object.keys(availableTemplates).toString();
|
|
19
36
|
throw new Error(
|
|
20
37
|
`The provided template name "${templateName}" does not exist. Available templates are "${templateNamesList}". Make sure you are also using the latest version of "@commercetools-frontend/create-mc-app".`
|
|
21
38
|
);
|
|
39
|
+
}
|
|
22
40
|
}
|
|
23
41
|
};
|
|
24
42
|
|
|
@@ -80,6 +98,7 @@ const throwIfNodeVersionIsNotSupported = (
|
|
|
80
98
|
};
|
|
81
99
|
|
|
82
100
|
export {
|
|
101
|
+
throwIfApplicationTypeIsNotSupported,
|
|
83
102
|
throwIfTemplateIsNotSupported,
|
|
84
103
|
throwIfProjectDirectoryExists,
|
|
85
104
|
throwIfTemplateVersionDoesNotExist,
|