create-plasmic-app 0.0.50 → 0.0.51
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/strategies/gatsby.d.ts +4 -0
- package/dist/strategies/gatsby.js +21 -7
- package/package.json +1 -1
- package/src/strategies/gatsby.ts +26 -10
|
@@ -38,6 +38,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
39
39
|
};
|
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.GATSBY_TEMPLATES = void 0;
|
|
41
42
|
const fs_1 = require("fs");
|
|
42
43
|
const path_1 = __importDefault(require("path"));
|
|
43
44
|
const readline = __importStar(require("readline"));
|
|
@@ -47,19 +48,22 @@ const file_utils_1 = require("../utils/file-utils");
|
|
|
47
48
|
const lang_utils_1 = require("../utils/lang-utils");
|
|
48
49
|
const npm_utils_1 = require("../utils/npm-utils");
|
|
49
50
|
const common_1 = require("./common");
|
|
51
|
+
exports.GATSBY_TEMPLATES = {
|
|
52
|
+
js: `https://github.com/gatsbyjs/gatsby-starter-minimal.git`,
|
|
53
|
+
ts: `https://github.com/gatsbyjs/gatsby-starter-minimal-ts.git`,
|
|
54
|
+
};
|
|
50
55
|
const gatsbyStrategy = {
|
|
51
56
|
create: (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
57
|
const { projectPath, template, useTypescript } = args;
|
|
53
58
|
if (template) {
|
|
54
59
|
console.log(`Warning: Ignoring template '${template}' (argument is not supported by Gatsby).`);
|
|
55
60
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
yield cmd_utils_1.spawnOrFail(`${createCommand}`, parent);
|
|
61
|
+
const gatsbyTemplate = exports.GATSBY_TEMPLATES[useTypescript ? "ts" : "js"];
|
|
62
|
+
const createCommand = `git clone ${gatsbyTemplate} ${projectPath} --recursive --depth 1 --quiet`;
|
|
63
|
+
yield cmd_utils_1.spawnOrFail(`${createCommand}`);
|
|
64
|
+
// Remove .git and LICENSE so that we don't generate linked outputs
|
|
65
|
+
yield cmd_utils_1.spawnOrFail(`rm -rf ${projectPath}/.git`);
|
|
66
|
+
yield cmd_utils_1.spawnOrFail(`rm -rf ${projectPath}/LICENSE`);
|
|
63
67
|
}),
|
|
64
68
|
installDeps: ({ projectPath, scheme, useTypescript }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65
69
|
const installedHelmet = yield npm_utils_1.installUpgrade("react-helmet", {
|
|
@@ -89,6 +93,16 @@ const gatsbyStrategy = {
|
|
|
89
93
|
var e_1, _a;
|
|
90
94
|
const { projectId, projectPath, projectApiToken, useTypescript, scheme, } = args;
|
|
91
95
|
const extension = useTypescript ? "ts" : "js";
|
|
96
|
+
const packageName = path_1.default.basename(projectPath);
|
|
97
|
+
// Update package.json: adding name and description, removing license and author
|
|
98
|
+
const packageJsonPath = path_1.default.join(projectPath, "package.json");
|
|
99
|
+
const packageJson = yield fs_1.promises.readFile(packageJsonPath, "utf8");
|
|
100
|
+
const packageJsonObject = JSON.parse(packageJson);
|
|
101
|
+
packageJsonObject.name = packageName;
|
|
102
|
+
packageJsonObject.description = `Plasmic app for ${projectId}`;
|
|
103
|
+
delete packageJsonObject.license;
|
|
104
|
+
delete packageJsonObject.author;
|
|
105
|
+
yield fs_1.promises.writeFile(packageJsonPath, JSON.stringify(packageJsonObject, null, 2));
|
|
92
106
|
if (scheme === "loader") {
|
|
93
107
|
// create-gatsby will create a default gatsby-config that we need to modify
|
|
94
108
|
const gatsbyConfigFile = path_1.default.join(projectPath, `gatsby-config.${extension}`);
|
package/package.json
CHANGED
package/src/strategies/gatsby.ts
CHANGED
|
@@ -17,6 +17,11 @@ import { installUpgrade } from "../utils/npm-utils";
|
|
|
17
17
|
import { installCodegenDeps, runCodegenSync } from "./common";
|
|
18
18
|
import { CPAStrategy } from "./types";
|
|
19
19
|
|
|
20
|
+
export const GATSBY_TEMPLATES = {
|
|
21
|
+
js: `https://github.com/gatsbyjs/gatsby-starter-minimal.git`,
|
|
22
|
+
ts: `https://github.com/gatsbyjs/gatsby-starter-minimal-ts.git`,
|
|
23
|
+
};
|
|
24
|
+
|
|
20
25
|
const gatsbyStrategy: CPAStrategy = {
|
|
21
26
|
create: async (args) => {
|
|
22
27
|
const { projectPath, template, useTypescript } = args;
|
|
@@ -25,16 +30,12 @@ const gatsbyStrategy: CPAStrategy = {
|
|
|
25
30
|
`Warning: Ignoring template '${template}' (argument is not supported by Gatsby).`
|
|
26
31
|
);
|
|
27
32
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
await
|
|
33
|
-
|
|
34
|
-
const createCommand = `npx -p create-gatsby create-gatsby ${
|
|
35
|
-
useTypescript ? "-ts" : ""
|
|
36
|
-
} -y ${dir}`;
|
|
37
|
-
await spawnOrFail(`${createCommand}`, parent);
|
|
33
|
+
const gatsbyTemplate = GATSBY_TEMPLATES[useTypescript ? "ts" : "js"];
|
|
34
|
+
const createCommand = `git clone ${gatsbyTemplate} ${projectPath} --recursive --depth 1 --quiet`;
|
|
35
|
+
await spawnOrFail(`${createCommand}`);
|
|
36
|
+
// Remove .git and LICENSE so that we don't generate linked outputs
|
|
37
|
+
await spawnOrFail(`rm -rf ${projectPath}/.git`);
|
|
38
|
+
await spawnOrFail(`rm -rf ${projectPath}/LICENSE`);
|
|
38
39
|
},
|
|
39
40
|
installDeps: async ({ projectPath, scheme, useTypescript }) => {
|
|
40
41
|
const installedHelmet = await installUpgrade("react-helmet", {
|
|
@@ -74,6 +75,21 @@ const gatsbyStrategy: CPAStrategy = {
|
|
|
74
75
|
} = args;
|
|
75
76
|
const extension = useTypescript ? "ts" : "js";
|
|
76
77
|
|
|
78
|
+
const packageName = path.basename(projectPath);
|
|
79
|
+
|
|
80
|
+
// Update package.json: adding name and description, removing license and author
|
|
81
|
+
const packageJsonPath = path.join(projectPath, "package.json");
|
|
82
|
+
const packageJson = await fs.readFile(packageJsonPath, "utf8");
|
|
83
|
+
const packageJsonObject = JSON.parse(packageJson);
|
|
84
|
+
packageJsonObject.name = packageName;
|
|
85
|
+
packageJsonObject.description = `Plasmic app for ${projectId}`;
|
|
86
|
+
delete packageJsonObject.license;
|
|
87
|
+
delete packageJsonObject.author;
|
|
88
|
+
await fs.writeFile(
|
|
89
|
+
packageJsonPath,
|
|
90
|
+
JSON.stringify(packageJsonObject, null, 2)
|
|
91
|
+
);
|
|
92
|
+
|
|
77
93
|
if (scheme === "loader") {
|
|
78
94
|
// create-gatsby will create a default gatsby-config that we need to modify
|
|
79
95
|
const gatsbyConfigFile = path.join(
|