@commercetools-frontend/create-mc-app 22.2.1 → 22.3.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/CHANGELOG.md +10 -0
- package/dist/commercetools-frontend-create-mc-app.cjs.dev.js +48 -91
- package/dist/commercetools-frontend-create-mc-app.cjs.prod.js +48 -91
- package/dist/commercetools-frontend-create-mc-app.esm.js +48 -91
- package/dist/declarations/src/types.d.ts +5 -1
- package/dist/declarations/src/utils.d.ts +3 -1
- package/dist/declarations/src/validations.d.ts +2 -2
- package/package.json +10 -3
- package/src/cli.ts +15 -6
- package/src/process-options.ts +1 -0
- package/src/tasks/install-dependencies.ts +3 -3
- package/src/tasks/update-package-json.ts +8 -1
- package/src/types.ts +6 -1
- package/src/utils.ts +16 -0
- package/src/validations.ts +2 -4
package/src/types.ts
CHANGED
|
@@ -2,13 +2,17 @@ export type TCliGlobalOptions = {
|
|
|
2
2
|
'--'?: string[];
|
|
3
3
|
};
|
|
4
4
|
|
|
5
|
+
export type TTemplate = 'starter' | 'starter-typescript';
|
|
6
|
+
export type TPackageManager = 'npm' | 'yarn' | 'pnpm';
|
|
7
|
+
|
|
5
8
|
export type TCliCommandOptions = {
|
|
6
|
-
template:
|
|
9
|
+
template: TTemplate;
|
|
7
10
|
templateVersion: string;
|
|
8
11
|
skipInstall: boolean;
|
|
9
12
|
yes: boolean;
|
|
10
13
|
entryPointUriPath?: string;
|
|
11
14
|
initialProjectKey?: string;
|
|
15
|
+
packageManager?: TPackageManager;
|
|
12
16
|
};
|
|
13
17
|
|
|
14
18
|
export type TCliTaskOptions = {
|
|
@@ -18,4 +22,5 @@ export type TCliTaskOptions = {
|
|
|
18
22
|
tagOrBranchVersion: string;
|
|
19
23
|
entryPointUriPath: string;
|
|
20
24
|
initialProjectKey: string;
|
|
25
|
+
packageManager: TCliCommandOptions['packageManager'];
|
|
21
26
|
};
|
package/src/utils.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import execa from 'execa';
|
|
3
|
+
import type { TCliTaskOptions, TPackageManager } from './types';
|
|
3
4
|
|
|
4
5
|
const isSemVer = (version: string) => /^(v?)([0-9].[0-9].[0-9])+/.test(version);
|
|
5
6
|
|
|
@@ -12,6 +13,20 @@ const shouldUseYarn = () => {
|
|
|
12
13
|
}
|
|
13
14
|
};
|
|
14
15
|
|
|
16
|
+
const getPreferredPackageManager = (
|
|
17
|
+
options: TCliTaskOptions
|
|
18
|
+
): TPackageManager => {
|
|
19
|
+
if (options.packageManager) {
|
|
20
|
+
return options.packageManager;
|
|
21
|
+
}
|
|
22
|
+
// Attempt to use yarn (backwards compatibility)
|
|
23
|
+
if (shouldUseYarn()) {
|
|
24
|
+
return 'yarn';
|
|
25
|
+
}
|
|
26
|
+
// Fall back to npm
|
|
27
|
+
return 'npm';
|
|
28
|
+
};
|
|
29
|
+
|
|
15
30
|
const slugify = (name: string) => name.toLowerCase().replace(/_/gi, '-');
|
|
16
31
|
|
|
17
32
|
const upperFirst = (value: string) =>
|
|
@@ -38,4 +53,5 @@ export {
|
|
|
38
53
|
wordify,
|
|
39
54
|
upperFirst,
|
|
40
55
|
resolveFilePathByExtension,
|
|
56
|
+
getPreferredPackageManager,
|
|
41
57
|
};
|
package/src/validations.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import semver from 'semver';
|
|
4
|
-
import type {
|
|
4
|
+
import type { TTemplate } from './types';
|
|
5
5
|
import { isSemVer } from './utils';
|
|
6
6
|
|
|
7
7
|
const availableTemplates = {
|
|
@@ -9,9 +9,7 @@ const availableTemplates = {
|
|
|
9
9
|
'starter-typescript': 'starter-typescript',
|
|
10
10
|
} as const;
|
|
11
11
|
|
|
12
|
-
const throwIfTemplateIsNotSupported = (
|
|
13
|
-
templateName: TCliCommandOptions['template']
|
|
14
|
-
) => {
|
|
12
|
+
const throwIfTemplateIsNotSupported = (templateName: TTemplate) => {
|
|
15
13
|
switch (templateName) {
|
|
16
14
|
case availableTemplates.starter:
|
|
17
15
|
case availableTemplates['starter-typescript']:
|