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