@slicemachine/init 1.1.16-dev-alpha.5 → 1.1.16-dev-ct-slice-delete.3
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/.depcheckrc +1 -3
- package/babel.config.js +7 -0
- package/build/index.js +16 -2181
- package/build/index.js.map +1 -1
- package/jest.config.js +1 -0
- package/package.json +12 -8
- package/src/index.ts +1 -6
- package/src/steps/detect-framework.ts +8 -12
- package/src/steps/install-required-dependencies.ts +6 -22
- package/src/utils/index.ts +0 -1
- package/src/utils/versionCheck.ts +0 -10
package/jest.config.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slicemachine/init",
|
|
3
|
-
"version": "1.1.16-dev-
|
|
3
|
+
"version": "1.1.16-dev-ct-slice-delete.3",
|
|
4
4
|
"description": "The easiest way to add Slice Machine to your project",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
"prepublishOnly": "npm run test && npm run build",
|
|
17
17
|
"test": "jest",
|
|
18
18
|
"tsc": "tsc --project tsconfig.json --noEmit",
|
|
19
|
-
"watch": "tsc --project tsconfig.json --noEmit --watch"
|
|
19
|
+
"tsc:watch": "tsc --project tsconfig.json --noEmit --watch"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@hapi/hapi": "^20.2.0",
|
|
23
|
-
"@prismicio/types-internal": "^
|
|
24
|
-
"@slicemachine/client": "1.1.16-dev-
|
|
25
|
-
"@slicemachine/core": "1.1.16-dev-
|
|
23
|
+
"@prismicio/types-internal": "^0.2.8",
|
|
24
|
+
"@slicemachine/client": "1.1.16-dev-ct-slice-delete.3",
|
|
25
|
+
"@slicemachine/core": "1.1.16-dev-ct-slice-delete.3",
|
|
26
26
|
"adm-zip": "^0.5.9",
|
|
27
27
|
"analytics-node": "^6.0.0",
|
|
28
28
|
"axios": "^0.24.0",
|
|
@@ -37,6 +37,9 @@
|
|
|
37
37
|
"uuid": "^8.3.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
+
"@babel/core": "^7.15.8",
|
|
41
|
+
"@babel/preset-env": "^7.15.8",
|
|
42
|
+
"@babel/preset-typescript": "^7.15.0",
|
|
40
43
|
"@rollup/plugin-replace": "^3.0.1",
|
|
41
44
|
"@types/adm-zip": "^0.4.34",
|
|
42
45
|
"@types/analytics-node": "^3.1.7",
|
|
@@ -49,6 +52,7 @@
|
|
|
49
52
|
"@types/uuid": "^8.3.4",
|
|
50
53
|
"@typescript-eslint/eslint-plugin": "^5.10.0",
|
|
51
54
|
"@typescript-eslint/parser": "^5.10.0",
|
|
55
|
+
"babel-jest": "^27.0.2",
|
|
52
56
|
"better-npm-audit": "^3.4.0",
|
|
53
57
|
"depcheck": "^1.4.3",
|
|
54
58
|
"eslint": "^7.32.0",
|
|
@@ -56,16 +60,16 @@
|
|
|
56
60
|
"eslint-import-resolver-typescript": "^2.4.0",
|
|
57
61
|
"eslint-plugin-import": "^2.24.0",
|
|
58
62
|
"eslint-plugin-jest": "^24.4.0",
|
|
59
|
-
"jest": "^
|
|
63
|
+
"jest": "^27.4.7",
|
|
60
64
|
"mock-fs": "^5.1.2",
|
|
61
65
|
"nock": "^13.1.3",
|
|
62
66
|
"siroc": "^0.16.0",
|
|
63
67
|
"stdout-stderr": "^0.1.13",
|
|
64
|
-
"ts-jest": "^
|
|
68
|
+
"ts-jest": "^27.0.5",
|
|
65
69
|
"typescript": "^4.4.3"
|
|
66
70
|
},
|
|
67
71
|
"engines": {
|
|
68
72
|
"node": ">=14"
|
|
69
73
|
},
|
|
70
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "a536ee23906ec61b1b30d43d60c85c35892798f9"
|
|
71
75
|
}
|
package/src/index.ts
CHANGED
|
@@ -95,12 +95,7 @@ async function init() {
|
|
|
95
95
|
);
|
|
96
96
|
|
|
97
97
|
// Install the required dependencies in the project.
|
|
98
|
-
await installRequiredDependencies(
|
|
99
|
-
cwd,
|
|
100
|
-
frameworkResult.value,
|
|
101
|
-
wasStarter,
|
|
102
|
-
frameworkResult.version
|
|
103
|
-
);
|
|
98
|
+
await installRequiredDependencies(cwd, frameworkResult.value, wasStarter);
|
|
104
99
|
|
|
105
100
|
setVersion(cwd);
|
|
106
101
|
|
|
@@ -7,7 +7,6 @@ import Tracker from "../utils/tracker";
|
|
|
7
7
|
export type FrameworkResult = {
|
|
8
8
|
value: Models.Frameworks;
|
|
9
9
|
manuallyAdded: boolean;
|
|
10
|
-
version?: string;
|
|
11
10
|
};
|
|
12
11
|
|
|
13
12
|
export async function promptForFramework(): Promise<FrameworkResult> {
|
|
@@ -32,7 +31,6 @@ export async function promptForFramework(): Promise<FrameworkResult> {
|
|
|
32
31
|
return {
|
|
33
32
|
value: res.framework,
|
|
34
33
|
manuallyAdded: true,
|
|
35
|
-
version: undefined,
|
|
36
34
|
};
|
|
37
35
|
});
|
|
38
36
|
}
|
|
@@ -49,22 +47,21 @@ export async function detectFramework(cwd: string): Promise<FrameworkResult> {
|
|
|
49
47
|
spinner.start();
|
|
50
48
|
|
|
51
49
|
try {
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
});
|
|
50
|
+
const maybeFramework = NodeUtils.Framework.defineFramework({
|
|
51
|
+
cwd,
|
|
52
|
+
supportedFrameworks: Object.values(Models.Frameworks),
|
|
53
|
+
});
|
|
57
54
|
|
|
58
55
|
spinner.stop();
|
|
59
56
|
|
|
60
|
-
if (!
|
|
57
|
+
if (!maybeFramework || maybeFramework === Models.Frameworks.vanillajs) {
|
|
61
58
|
logs.writeError("Framework not detected");
|
|
62
59
|
return await promptForFramework();
|
|
63
60
|
}
|
|
64
61
|
|
|
65
|
-
const nameToPrint = NodeUtils.Framework.fancyName(
|
|
62
|
+
const nameToPrint = NodeUtils.Framework.fancyName(maybeFramework);
|
|
66
63
|
|
|
67
|
-
if (!NodeUtils.Framework.isFrameworkSupported(
|
|
64
|
+
if (!NodeUtils.Framework.isFrameworkSupported(maybeFramework)) {
|
|
68
65
|
logs.writeError(`${nameToPrint} is currently not supported`);
|
|
69
66
|
console.log(failMessage);
|
|
70
67
|
process.exit(1);
|
|
@@ -73,9 +70,8 @@ export async function detectFramework(cwd: string): Promise<FrameworkResult> {
|
|
|
73
70
|
logs.writeCheck(`${nameToPrint} detected`);
|
|
74
71
|
|
|
75
72
|
return {
|
|
76
|
-
value:
|
|
73
|
+
value: maybeFramework,
|
|
77
74
|
manuallyAdded: false,
|
|
78
|
-
version,
|
|
79
75
|
};
|
|
80
76
|
} catch (error) {
|
|
81
77
|
spinner.fail("package.json not found");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import {
|
|
2
|
+
import { execCommand, logs } from "../utils";
|
|
3
3
|
import { CONSTS, Models } from "@slicemachine/core";
|
|
4
4
|
import * as NodeUtils from "@slicemachine/core/build/node-utils";
|
|
5
5
|
|
|
@@ -7,7 +7,6 @@ const {
|
|
|
7
7
|
PRISMIC_CLIENT,
|
|
8
8
|
PRISMIC_DOM_PACKAGE_NAME,
|
|
9
9
|
PRISMIC_REACT_PACKAGE_NAME,
|
|
10
|
-
PRISMIC_NEXT,
|
|
11
10
|
SM_PACKAGE_NAME,
|
|
12
11
|
NUXT_PRISMIC,
|
|
13
12
|
PRISMIC_VUE,
|
|
@@ -17,25 +16,12 @@ const {
|
|
|
17
16
|
PRISMIC_TYPES,
|
|
18
17
|
} = CONSTS;
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
if (checkVersion(">=13.0.0", version)) {
|
|
22
|
-
return PRISMIC_NEXT;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return "";
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function depsForFramework(
|
|
29
|
-
framework: Models.Frameworks,
|
|
30
|
-
version?: string
|
|
31
|
-
): string {
|
|
19
|
+
function depsForFramework(framework: Models.Frameworks): string {
|
|
32
20
|
switch (framework) {
|
|
33
21
|
case Models.Frameworks.react:
|
|
34
22
|
return `${PRISMIC_REACT_PACKAGE_NAME} ${PRISMIC_CLIENT} ${PRISMIC_HELPERS}`;
|
|
35
23
|
case Models.Frameworks.next:
|
|
36
|
-
return `${PRISMIC_REACT_PACKAGE_NAME} ${
|
|
37
|
-
version
|
|
38
|
-
)} ${PRISMIC_CLIENT} ${SLICE_SIMULATOR_REACT} ${PRISMIC_HELPERS}`;
|
|
24
|
+
return `${PRISMIC_REACT_PACKAGE_NAME} ${PRISMIC_CLIENT} ${SLICE_SIMULATOR_REACT} ${PRISMIC_HELPERS}`;
|
|
39
25
|
case Models.Frameworks.svelte:
|
|
40
26
|
return `${PRISMIC_DOM_PACKAGE_NAME} ${PRISMIC_CLIENT}`;
|
|
41
27
|
case Models.Frameworks.nuxt:
|
|
@@ -49,7 +35,6 @@ function depsForFramework(
|
|
|
49
35
|
|
|
50
36
|
async function addAndInstallDeps(
|
|
51
37
|
framework: Models.Frameworks,
|
|
52
|
-
version?: string,
|
|
53
38
|
useYarn = false
|
|
54
39
|
): Promise<string> {
|
|
55
40
|
const installDevDependencyCommand = useYarn
|
|
@@ -61,7 +46,7 @@ async function addAndInstallDeps(
|
|
|
61
46
|
`${installDevDependencyCommand} ${SM_PACKAGE_NAME} ${PRISMIC_TYPES}`
|
|
62
47
|
);
|
|
63
48
|
|
|
64
|
-
const deps = depsForFramework(framework
|
|
49
|
+
const deps = depsForFramework(framework);
|
|
65
50
|
if (deps) await execCommand(`${installDependencyCommand} ${deps}`);
|
|
66
51
|
|
|
67
52
|
return stderr;
|
|
@@ -76,8 +61,7 @@ async function installDeps(useYarn = false): Promise<string> {
|
|
|
76
61
|
export async function installRequiredDependencies(
|
|
77
62
|
cwd: string,
|
|
78
63
|
framework: Models.Frameworks,
|
|
79
|
-
skipDependencies: boolean
|
|
80
|
-
version?: string
|
|
64
|
+
skipDependencies: boolean
|
|
81
65
|
): Promise<void> {
|
|
82
66
|
const yarnLock = NodeUtils.Files.exists(NodeUtils.YarnLockPath(cwd));
|
|
83
67
|
|
|
@@ -86,7 +70,7 @@ export async function installRequiredDependencies(
|
|
|
86
70
|
|
|
87
71
|
const stderr = await (skipDependencies
|
|
88
72
|
? installDeps(yarnLock)
|
|
89
|
-
: addAndInstallDeps(framework,
|
|
73
|
+
: addAndInstallDeps(framework, yarnLock));
|
|
90
74
|
|
|
91
75
|
const pathToPkg = path.join(
|
|
92
76
|
NodeUtils.PackagePaths(cwd).value(),
|
package/src/utils/index.ts
CHANGED
|
@@ -5,7 +5,6 @@ export * as logs from "./logs";
|
|
|
5
5
|
export { Auth } from "./auth";
|
|
6
6
|
export * from "./client";
|
|
7
7
|
export * from "./fs";
|
|
8
|
-
export * from "./versionCheck";
|
|
9
8
|
|
|
10
9
|
export function findArgument(args: string[], name: string): string | undefined {
|
|
11
10
|
const flagIndex: number = args.indexOf(`--${name}`);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import semverCoerce from "semver/functions/coerce";
|
|
2
|
-
import semverSatisfies from "semver/functions/satisfies";
|
|
3
|
-
|
|
4
|
-
export function checkVersion(threshold: string, version?: string): boolean {
|
|
5
|
-
if (!version) return false;
|
|
6
|
-
const parsedVersion = semverCoerce(version);
|
|
7
|
-
if (parsedVersion === null) return false;
|
|
8
|
-
|
|
9
|
-
return semverSatisfies(parsedVersion, threshold);
|
|
10
|
-
}
|