create-plasmic-app 0.0.53 → 0.0.56
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/.eslintrc.js +1 -0
- package/LICENSE.md +21 -0
- package/dist/index.js +13 -9
- package/dist/lib.js +13 -9
- package/dist/strategies/common.js +4 -4
- package/dist/strategies/gatsby.js +24 -20
- package/dist/strategies/index.d.ts +1 -1
- package/dist/strategies/nextjs.js +11 -11
- package/dist/strategies/react.js +19 -8
- package/dist/templates/gatsby.js +9 -9
- package/dist/templates/nextjs.js +4 -4
- package/dist/templates/readme.js +1 -1
- package/dist/utils/cmd-utils.js +1 -1
- package/dist/utils/file-utils.js +13 -9
- package/dist/utils/npm-utils.js +7 -3
- package/package.json +4 -3
- package/src/strategies/react.ts +16 -1
- package/src/utils/file-utils.ts +1 -1
- package/tsconfig.json +3 -2
package/.eslintrc.js
CHANGED
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Plasmic
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
4
|
if (k2 === undefined) k2 = k;
|
|
5
|
-
Object.
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
6
10
|
}) : (function(o, m, k, k2) {
|
|
7
11
|
if (k2 === undefined) k2 = k;
|
|
8
12
|
o[k2] = m[k];
|
|
@@ -45,7 +49,7 @@ if (process.env.CPA_DEBUG_CHDIR) {
|
|
|
45
49
|
process.chdir(process.env.CPA_DEBUG_CHDIR);
|
|
46
50
|
}
|
|
47
51
|
// Check for updates
|
|
48
|
-
const createPlasmicAppVersion = npm_utils_1.updateNotify();
|
|
52
|
+
const createPlasmicAppVersion = (0, npm_utils_1.updateNotify)();
|
|
49
53
|
// Specify command-line args
|
|
50
54
|
const argv = yargs_1.default
|
|
51
55
|
.usage("Usage: $0 [options] <project-directory>")
|
|
@@ -101,8 +105,8 @@ Sentry.configureScope((scope) => {
|
|
|
101
105
|
*/
|
|
102
106
|
function maybePrompt(question) {
|
|
103
107
|
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
-
const name = lang_utils_1.ensure(question.name);
|
|
105
|
-
const message = lang_utils_1.ensure(question.message);
|
|
108
|
+
const name = (0, lang_utils_1.ensure)(question.name);
|
|
109
|
+
const message = (0, lang_utils_1.ensure)(question.message);
|
|
106
110
|
const maybeAnswer = argv[name];
|
|
107
111
|
if (maybeAnswer === null || maybeAnswer === undefined || maybeAnswer === "") {
|
|
108
112
|
const ans = yield inquirer_1.default.prompt(Object.assign({}, question));
|
|
@@ -110,7 +114,7 @@ function maybePrompt(question) {
|
|
|
110
114
|
}
|
|
111
115
|
else {
|
|
112
116
|
console.log(`${message}: ${maybeAnswer} (specified in CLI arg)`);
|
|
113
|
-
return lang_utils_1.ensure(argv[name]);
|
|
117
|
+
return (0, lang_utils_1.ensure)(argv[name]);
|
|
114
118
|
}
|
|
115
119
|
});
|
|
116
120
|
}
|
|
@@ -153,7 +157,7 @@ function run() {
|
|
|
153
157
|
default: true,
|
|
154
158
|
});
|
|
155
159
|
// Prompt for the platform
|
|
156
|
-
const platform = lang_utils_1.ensureString(yield maybePrompt({
|
|
160
|
+
const platform = (0, lang_utils_1.ensureString)(yield maybePrompt({
|
|
157
161
|
name: "platform",
|
|
158
162
|
message: "What React framework do you want to use?",
|
|
159
163
|
type: "list",
|
|
@@ -215,11 +219,11 @@ https://studio.plasmic.app/starters/blank
|
|
|
215
219
|
}
|
|
216
220
|
// RUN IT
|
|
217
221
|
console.log();
|
|
218
|
-
lang_utils_1.assert(platform === "nextjs" || platform === "gatsby" || platform === "react", "platform must be one of ['nextjs', 'gatsby', 'react']");
|
|
222
|
+
(0, lang_utils_1.assert)(platform === "nextjs" || platform === "gatsby" || platform === "react", "platform must be one of ['nextjs', 'gatsby', 'react']");
|
|
219
223
|
const template = argv["template"];
|
|
220
224
|
const projectApiToken = argv["projectApiToken"];
|
|
221
225
|
// Set the metadata environment variable to tag the future Segment codegen event
|
|
222
|
-
cli_1.setMetadataEnv({
|
|
226
|
+
(0, cli_1.setMetadataEnv)({
|
|
223
227
|
source: "create-plasmic-app",
|
|
224
228
|
});
|
|
225
229
|
yield cpa.create({
|
|
@@ -245,7 +249,7 @@ run().catch((err) => {
|
|
|
245
249
|
console.log(`Please remove ${resolvedProjectPath} and try again.`);
|
|
246
250
|
}
|
|
247
251
|
// Check if we satisfy the engine policy
|
|
248
|
-
const satisfiesVersion = npm_utils_1.checkEngineStrict();
|
|
252
|
+
const satisfiesVersion = (0, npm_utils_1.checkEngineStrict)();
|
|
249
253
|
// Log to Sentry only if user has correct Node version
|
|
250
254
|
if (satisfiesVersion && err) {
|
|
251
255
|
Sentry.captureException(err);
|
package/dist/lib.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -57,12 +61,12 @@ function create(args) {
|
|
|
57
61
|
console.log("Skipping auth; using the given project API token.");
|
|
58
62
|
}
|
|
59
63
|
else {
|
|
60
|
-
const promise = cli_1.auth({
|
|
64
|
+
const promise = (0, cli_1.auth)({
|
|
61
65
|
host: "https://studio.plasmic.app",
|
|
62
66
|
check: true,
|
|
63
67
|
})
|
|
64
68
|
.catch(() => {
|
|
65
|
-
return cli_1.auth({ host: "https://studio.plasmic.app" });
|
|
69
|
+
return (0, cli_1.auth)({ host: "https://studio.plasmic.app" });
|
|
66
70
|
})
|
|
67
71
|
.catch(() => {
|
|
68
72
|
throw new Error("Failed to authenticate with Plasmic. Please run `npx @plasmicapp/cli auth` manually.");
|
|
@@ -77,7 +81,7 @@ function create(args) {
|
|
|
77
81
|
if (!["codegen", "loader"].includes(scheme)) {
|
|
78
82
|
throw new Error(`Unrecognized Plasmic scheme: ${scheme}`);
|
|
79
83
|
}
|
|
80
|
-
const cpaStrategy = strategies_1.getCPAStrategy(platform);
|
|
84
|
+
const cpaStrategy = (0, strategies_1.getCPAStrategy)(platform);
|
|
81
85
|
// Create project using strategy for platform
|
|
82
86
|
yield cpaStrategy.create({
|
|
83
87
|
projectPath: resolvedProjectPath,
|
|
@@ -88,11 +92,11 @@ function create(args) {
|
|
|
88
92
|
// Gatsby and Next.js by default support typescript handling internally
|
|
89
93
|
// tsconfig so we don't have to ensure it.
|
|
90
94
|
if (useTypescript && platform === "react") {
|
|
91
|
-
yield file_utils_1.ensureTsconfig(resolvedProjectPath);
|
|
95
|
+
yield (0, file_utils_1.ensureTsconfig)(resolvedProjectPath);
|
|
92
96
|
}
|
|
93
97
|
// Make sure we have an api token for loader
|
|
94
98
|
if (scheme === "loader" && !projectApiToken) {
|
|
95
|
-
projectApiToken = yield cli_1.getProjectApiToken(projectId);
|
|
99
|
+
projectApiToken = yield (0, cli_1.getProjectApiToken)(projectId);
|
|
96
100
|
if (!projectApiToken) {
|
|
97
101
|
throw new Error(`Failed to get projectApiToken for ${projectId}`);
|
|
98
102
|
}
|
|
@@ -126,7 +130,7 @@ function create(args) {
|
|
|
126
130
|
/**
|
|
127
131
|
* INSTRUCT USER ON NEXT STEPS
|
|
128
132
|
*/
|
|
129
|
-
const pkgMgr = npm_utils_1.detectPackageManager(resolvedProjectPath);
|
|
133
|
+
const pkgMgr = (0, npm_utils_1.detectPackageManager)(resolvedProjectPath);
|
|
130
134
|
const npmRunCmd = pkgMgr === "yarn" ? "yarn" : "npm run";
|
|
131
135
|
const command = platform === "nextjs"
|
|
132
136
|
? `${npmRunCmd} dev`
|
|
@@ -137,7 +141,7 @@ function create(args) {
|
|
|
137
141
|
: "";
|
|
138
142
|
const relativeDir = path.relative(process.cwd(), resolvedProjectPath);
|
|
139
143
|
// Overwrite README
|
|
140
|
-
yield file_utils_1.overwriteReadme(resolvedProjectPath, platform, command);
|
|
144
|
+
yield (0, file_utils_1.overwriteReadme)(resolvedProjectPath, platform, command);
|
|
141
145
|
console.log("----------------------------------------");
|
|
142
146
|
console.log(chalk_1.default.green.bold(`Congrats! We created the Plasmic-connected project at ${relativeDir}`));
|
|
143
147
|
console.log();
|
|
@@ -165,7 +169,7 @@ function checkValidName(name) {
|
|
|
165
169
|
return false;
|
|
166
170
|
}
|
|
167
171
|
// Check that projectName is a valid npm package name
|
|
168
|
-
const nameValidation = validate_npm_package_name_1.default(name);
|
|
172
|
+
const nameValidation = (0, validate_npm_package_name_1.default)(name);
|
|
169
173
|
if (!nameValidation.validForNewPackages) {
|
|
170
174
|
if (nameValidation.warnings) {
|
|
171
175
|
nameValidation.warnings.forEach((e) => console.warn(e));
|
|
@@ -16,19 +16,19 @@ const npm_utils_1 = require("../utils/npm-utils");
|
|
|
16
16
|
function installCodegenDeps(opts) {
|
|
17
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
18
|
const { projectPath } = opts;
|
|
19
|
-
return ((yield npm_utils_1.installUpgrade("@plasmicapp/cli", { workingDir: projectPath })) &&
|
|
20
|
-
(yield npm_utils_1.installUpgrade("@plasmicapp/host", { workingDir: projectPath })));
|
|
19
|
+
return ((yield (0, npm_utils_1.installUpgrade)("@plasmicapp/cli", { workingDir: projectPath })) &&
|
|
20
|
+
(yield (0, npm_utils_1.installUpgrade)("@plasmicapp/host", { workingDir: projectPath })));
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
exports.installCodegenDeps = installCodegenDeps;
|
|
24
24
|
function runCodegenSync(opts) {
|
|
25
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
26
|
const { projectId, projectApiToken, projectPath } = opts;
|
|
27
|
-
lib_1.banner("SYNCING PLASMIC COMPONENTS");
|
|
27
|
+
(0, lib_1.banner)("SYNCING PLASMIC COMPONENTS");
|
|
28
28
|
const project = projectApiToken
|
|
29
29
|
? `${projectId}:${projectApiToken}`
|
|
30
30
|
: projectId;
|
|
31
|
-
yield cmd_utils_1.spawnOrFail(`npx -p @plasmicapp/cli plasmic sync --yes -p ${project}`, projectPath);
|
|
31
|
+
yield (0, cmd_utils_1.spawnOrFail)(`npx -p @plasmicapp/cli plasmic sync --yes -p ${project}`, projectPath);
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
exports.runCodegenSync = runCodegenSync;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -60,33 +64,33 @@ const gatsbyStrategy = {
|
|
|
60
64
|
}
|
|
61
65
|
const gatsbyTemplate = exports.GATSBY_TEMPLATES[useTypescript ? "ts" : "js"];
|
|
62
66
|
const createCommand = `git clone ${gatsbyTemplate} ${projectPath} --recursive --depth 1 --quiet`;
|
|
63
|
-
yield cmd_utils_1.spawnOrFail(`${createCommand}`);
|
|
67
|
+
yield (0, cmd_utils_1.spawnOrFail)(`${createCommand}`);
|
|
64
68
|
// 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`);
|
|
69
|
+
yield (0, cmd_utils_1.spawnOrFail)(`rm -rf ${projectPath}/.git`);
|
|
70
|
+
yield (0, cmd_utils_1.spawnOrFail)(`rm -rf ${projectPath}/LICENSE`);
|
|
67
71
|
}),
|
|
68
72
|
installDeps: ({ projectPath, scheme, useTypescript }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
|
-
const installedHelmet = yield npm_utils_1.installUpgrade("react-helmet", {
|
|
73
|
+
const installedHelmet = yield (0, npm_utils_1.installUpgrade)("react-helmet", {
|
|
70
74
|
workingDir: projectPath,
|
|
71
75
|
});
|
|
72
76
|
const installedHelmetTypes = !useTypescript ||
|
|
73
|
-
(yield npm_utils_1.installUpgrade("@types/react-helmet", {
|
|
77
|
+
(yield (0, npm_utils_1.installUpgrade)("@types/react-helmet", {
|
|
74
78
|
workingDir: projectPath,
|
|
75
79
|
dev: true,
|
|
76
80
|
}));
|
|
77
|
-
const installedHelmetPlugin = yield npm_utils_1.installUpgrade("gatsby-plugin-react-helmet", {
|
|
81
|
+
const installedHelmetPlugin = yield (0, npm_utils_1.installUpgrade)("gatsby-plugin-react-helmet", {
|
|
78
82
|
workingDir: projectPath,
|
|
79
83
|
});
|
|
80
84
|
if (!installedHelmet || !installedHelmetPlugin || !installedHelmetTypes) {
|
|
81
85
|
return false;
|
|
82
86
|
}
|
|
83
87
|
if (scheme === "loader") {
|
|
84
|
-
return yield npm_utils_1.installUpgrade("@plasmicapp/loader-gatsby", {
|
|
88
|
+
return yield (0, npm_utils_1.installUpgrade)("@plasmicapp/loader-gatsby", {
|
|
85
89
|
workingDir: projectPath,
|
|
86
90
|
});
|
|
87
91
|
}
|
|
88
92
|
else {
|
|
89
|
-
return yield common_1.installCodegenDeps({ projectPath });
|
|
93
|
+
return yield (0, common_1.installCodegenDeps)({ projectPath });
|
|
90
94
|
}
|
|
91
95
|
}),
|
|
92
96
|
overwriteConfig: (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -107,13 +111,13 @@ const gatsbyStrategy = {
|
|
|
107
111
|
// create-gatsby will create a default gatsby-config that we need to modify
|
|
108
112
|
const gatsbyConfigFile = path_1.default.join(projectPath, `gatsby-config.${extension}`);
|
|
109
113
|
const rl = readline.createInterface({
|
|
110
|
-
input: fs_1.createReadStream(gatsbyConfigFile),
|
|
114
|
+
input: (0, fs_1.createReadStream)(gatsbyConfigFile),
|
|
111
115
|
crlfDelay: Infinity,
|
|
112
116
|
});
|
|
113
117
|
// Typescript doesn't accept require.resolve
|
|
114
118
|
// https://www.gatsbyjs.com/docs/how-to/custom-configuration/typescript/#requireresolve
|
|
115
119
|
let result = useTypescript ? `import path from "path";\n` : "";
|
|
116
|
-
const pluginConfig = gatsby_1.GATSBY_PLUGIN_CONFIG(projectId, lang_utils_1.ensure(projectApiToken), useTypescript);
|
|
120
|
+
const pluginConfig = (0, gatsby_1.GATSBY_PLUGIN_CONFIG)(projectId, (0, lang_utils_1.ensure)(projectApiToken), useTypescript);
|
|
117
121
|
try {
|
|
118
122
|
for (var rl_1 = __asyncValues(rl), rl_1_1; rl_1_1 = yield rl_1.next(), !rl_1_1.done;) {
|
|
119
123
|
const line = rl_1_1.value;
|
|
@@ -143,11 +147,11 @@ const gatsbyStrategy = {
|
|
|
143
147
|
// to be handled by templates/defaultPlasmicPage
|
|
144
148
|
const { projectId, projectApiToken, projectPath, useTypescript, scheme, } = args;
|
|
145
149
|
const extension = useTypescript ? "ts" : "js";
|
|
146
|
-
file_utils_1.deleteGlob(path_1.default.join(projectPath, "src/@(pages|components|templates)/*.*"));
|
|
150
|
+
(0, file_utils_1.deleteGlob)(path_1.default.join(projectPath, "src/@(pages|components|templates)/*.*"));
|
|
147
151
|
// Create a very basic 404 page - `gatsby build` fails without it.
|
|
148
152
|
yield fs_1.promises.writeFile(path_1.default.join(projectPath, `src/pages/404.${extension}`), gatsby_1.GATSBY_404);
|
|
149
153
|
// Add plasmic-host page
|
|
150
|
-
yield fs_1.promises.writeFile(path_1.default.join(projectPath, `src/pages/plasmic-host.${extension}x`), gatsby_1.makeGatsbyHostPage({
|
|
154
|
+
yield fs_1.promises.writeFile(path_1.default.join(projectPath, `src/pages/plasmic-host.${extension}x`), (0, gatsby_1.makeGatsbyHostPage)({
|
|
151
155
|
useTypescript,
|
|
152
156
|
scheme,
|
|
153
157
|
}));
|
|
@@ -156,24 +160,24 @@ const gatsbyStrategy = {
|
|
|
156
160
|
// Updates `gatsby-ssr` to include script tag for preamble
|
|
157
161
|
yield fs_1.promises.writeFile(path_1.default.join(projectPath, `gatsby-ssr.${extension}x`), gatsby_1.GATSBY_SSR_CONFIG);
|
|
158
162
|
if (scheme === "loader") {
|
|
159
|
-
yield fs_1.promises.writeFile(path_1.default.join(projectPath, `src/plasmic-init.${extension}`), gatsby_1.makeGatsbyPlasmicInit(extension));
|
|
163
|
+
yield fs_1.promises.writeFile(path_1.default.join(projectPath, `src/plasmic-init.${extension}`), (0, gatsby_1.makeGatsbyPlasmicInit)(extension));
|
|
160
164
|
const templatesFolder = path_1.default.join(projectPath, "src/templates");
|
|
161
|
-
if (!fs_1.existsSync(templatesFolder)) {
|
|
165
|
+
if (!(0, fs_1.existsSync)(templatesFolder)) {
|
|
162
166
|
yield fs_1.promises.mkdir(templatesFolder);
|
|
163
167
|
}
|
|
164
168
|
const defaultPagePath = path_1.default.join(templatesFolder, `defaultPlasmicPage.${extension}x`);
|
|
165
|
-
yield fs_1.promises.writeFile(defaultPagePath, gatsby_1.makeGatsbyDefaultPage(extension));
|
|
169
|
+
yield fs_1.promises.writeFile(defaultPagePath, (0, gatsby_1.makeGatsbyDefaultPage)(extension));
|
|
166
170
|
}
|
|
167
171
|
else {
|
|
168
|
-
yield common_1.runCodegenSync({
|
|
172
|
+
yield (0, common_1.runCodegenSync)({
|
|
169
173
|
projectId,
|
|
170
174
|
projectApiToken,
|
|
171
175
|
projectPath,
|
|
172
176
|
});
|
|
173
177
|
// Overwrite the index file
|
|
174
|
-
yield file_utils_1.overwriteIndex(projectPath, "gatsby", scheme);
|
|
178
|
+
yield (0, file_utils_1.overwriteIndex)(projectPath, "gatsby", scheme);
|
|
175
179
|
// Overwrite the wrapper files to wrap PlasmicRootProvider
|
|
176
|
-
const wrapperContent = gatsby_1.wrapAppRootForCodegen();
|
|
180
|
+
const wrapperContent = (0, gatsby_1.wrapAppRootForCodegen)();
|
|
177
181
|
const browserFilePath = path_1.default.join(projectPath, `gatsby-browser.${extension}x`);
|
|
178
182
|
yield fs_1.promises.writeFile(browserFilePath, wrapperContent);
|
|
179
183
|
const ssrFilePath = path_1.default.join(projectPath, `gatsby-ssr.${extension}x`);
|
|
@@ -186,7 +190,7 @@ const gatsbyStrategy = {
|
|
|
186
190
|
// https://github.com/gatsbyjs/gatsby/issues/20957
|
|
187
191
|
// This may be a local problem for each person, but maybe we can try to handle it
|
|
188
192
|
// here
|
|
189
|
-
yield cmd_utils_1.spawnOrFail(`${npmRunCmd} build`, projectPath);
|
|
193
|
+
yield (0, cmd_utils_1.spawnOrFail)(`${npmRunCmd} build`, projectPath);
|
|
190
194
|
}),
|
|
191
195
|
};
|
|
192
196
|
exports.default = gatsbyStrategy;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { CPAStrategy } from "./types";
|
|
2
|
-
export declare const getCPAStrategy: (platform: string, errorMsg?: string
|
|
2
|
+
export declare const getCPAStrategy: (platform: string, errorMsg?: string) => CPAStrategy;
|
|
@@ -27,16 +27,16 @@ const nextjsStrategy = {
|
|
|
27
27
|
const templateArg = template ? ` --template ${template}` : "";
|
|
28
28
|
// Default Next.js starter already supports Typescript
|
|
29
29
|
// See where we `touch tsconfig.json` later on
|
|
30
|
-
yield cmd_utils_1.spawnOrFail(`${createCommand}${templateArg}`);
|
|
30
|
+
yield (0, cmd_utils_1.spawnOrFail)(`${createCommand}${templateArg}`);
|
|
31
31
|
}),
|
|
32
32
|
installDeps: ({ scheme, projectPath }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
33
|
if (scheme === "loader") {
|
|
34
|
-
return yield npm_utils_1.installUpgrade("@plasmicapp/loader-nextjs", {
|
|
34
|
+
return yield (0, npm_utils_1.installUpgrade)("@plasmicapp/loader-nextjs", {
|
|
35
35
|
workingDir: projectPath,
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
else {
|
|
39
|
-
return yield common_1.installCodegenDeps({ projectPath });
|
|
39
|
+
return yield (0, common_1.installCodegenDeps)({ projectPath });
|
|
40
40
|
}
|
|
41
41
|
}),
|
|
42
42
|
overwriteConfig: (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -73,32 +73,32 @@ module.exports = nextConfig
|
|
|
73
73
|
const { projectPath, scheme, useTypescript, projectId, projectApiToken, } = args;
|
|
74
74
|
// Always start fresh
|
|
75
75
|
const pagesPath = path_1.default.join(projectPath, "pages");
|
|
76
|
-
file_utils_1.deleteGlob(path_1.default.join(pagesPath, `*.*`));
|
|
76
|
+
(0, file_utils_1.deleteGlob)(path_1.default.join(pagesPath, `*.*`));
|
|
77
77
|
const hostPage = path_1.default.join(pagesPath, `plasmic-host.${useTypescript ? "tsx" : "jsx"}`);
|
|
78
|
-
yield fs_1.promises.writeFile(hostPage, nextjs_1.makeNextjsHostPage(scheme));
|
|
78
|
+
yield fs_1.promises.writeFile(hostPage, (0, nextjs_1.makeNextjsHostPage)(scheme));
|
|
79
79
|
if (scheme === "loader") {
|
|
80
80
|
const initFile = path_1.default.join(projectPath, `plasmic-init.${useTypescript ? "ts" : "js"}`);
|
|
81
|
-
yield fs_1.promises.writeFile(initFile, nextjs_1.makeNextjsInitPage(projectId, lang_utils_1.ensure(projectApiToken)));
|
|
81
|
+
yield fs_1.promises.writeFile(initFile, (0, nextjs_1.makeNextjsInitPage)(projectId, (0, lang_utils_1.ensure)(projectApiToken)));
|
|
82
82
|
// Write catch-all page for loader
|
|
83
83
|
const loaderPage = path_1.default.join(pagesPath, `[[...catchall]].${useTypescript ? "tsx" : "jsx"}`);
|
|
84
|
-
yield fs_1.promises.writeFile(loaderPage, nextjs_1.makeNextjsCatchallPage(useTypescript ? "ts" : "js"));
|
|
84
|
+
yield fs_1.promises.writeFile(loaderPage, (0, nextjs_1.makeNextjsCatchallPage)(useTypescript ? "ts" : "js"));
|
|
85
85
|
}
|
|
86
86
|
else {
|
|
87
|
-
yield common_1.runCodegenSync({
|
|
87
|
+
yield (0, common_1.runCodegenSync)({
|
|
88
88
|
projectId,
|
|
89
89
|
projectApiToken,
|
|
90
90
|
projectPath,
|
|
91
91
|
});
|
|
92
92
|
// Overwrite the index file
|
|
93
|
-
yield file_utils_1.overwriteIndex(projectPath, "nextjs", scheme);
|
|
93
|
+
yield (0, file_utils_1.overwriteIndex)(projectPath, "nextjs", scheme);
|
|
94
94
|
// Overwrite the wrapper files to wrap PlasmicRootProvider
|
|
95
95
|
const appFilePath = path_1.default.join(projectPath, "pages", `_app.js`);
|
|
96
|
-
yield fs_1.promises.writeFile(appFilePath, nextjs_1.wrapAppRootForCodegen());
|
|
96
|
+
yield fs_1.promises.writeFile(appFilePath, (0, nextjs_1.wrapAppRootForCodegen)());
|
|
97
97
|
}
|
|
98
98
|
}),
|
|
99
99
|
build: (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
100
100
|
const { npmRunCmd, projectPath } = args;
|
|
101
|
-
yield cmd_utils_1.spawnOrFail(`${npmRunCmd} build`, projectPath);
|
|
101
|
+
yield (0, cmd_utils_1.spawnOrFail)(`${npmRunCmd} build`, projectPath);
|
|
102
102
|
}),
|
|
103
103
|
};
|
|
104
104
|
exports.default = nextjsStrategy;
|
package/dist/strategies/react.js
CHANGED
|
@@ -8,7 +8,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const fs_1 = __importDefault(require("fs"));
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
12
17
|
const cmd_utils_1 = require("../utils/cmd-utils");
|
|
13
18
|
const file_utils_1 = require("../utils/file-utils");
|
|
14
19
|
const npm_utils_1 = require("../utils/npm-utils");
|
|
@@ -22,39 +27,45 @@ const reactStrategy = {
|
|
|
22
27
|
template = "typescript";
|
|
23
28
|
}
|
|
24
29
|
const templateArg = template ? ` --template ${template}` : "";
|
|
25
|
-
yield cmd_utils_1.spawnOrFail(`${createCommand}${templateArg}`);
|
|
30
|
+
yield (0, cmd_utils_1.spawnOrFail)(`${createCommand}${templateArg}`);
|
|
26
31
|
}),
|
|
27
32
|
installDeps: ({ projectPath, scheme }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
33
|
if (scheme === "loader") {
|
|
29
|
-
return yield npm_utils_1.installUpgrade("@plasmicapp/loader-react", {
|
|
34
|
+
return yield (0, npm_utils_1.installUpgrade)("@plasmicapp/loader-react", {
|
|
30
35
|
workingDir: projectPath,
|
|
31
36
|
});
|
|
32
37
|
}
|
|
33
38
|
else {
|
|
34
|
-
return yield common_1.installCodegenDeps({ projectPath });
|
|
39
|
+
return yield (0, common_1.installCodegenDeps)({ projectPath });
|
|
35
40
|
}
|
|
36
41
|
}),
|
|
37
42
|
overwriteConfig: (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
43
|
// No config to overwrite
|
|
39
44
|
}),
|
|
40
|
-
generateFiles: ({ scheme, projectApiToken, projectId, projectPath, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
+
generateFiles: ({ scheme, projectApiToken, projectId, projectPath, useTypescript, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
46
|
if (scheme === "loader") {
|
|
42
47
|
// Nothing to do
|
|
43
48
|
}
|
|
44
49
|
else {
|
|
45
|
-
yield common_1.runCodegenSync({
|
|
50
|
+
yield (0, common_1.runCodegenSync)({
|
|
46
51
|
projectId,
|
|
47
52
|
projectApiToken,
|
|
48
53
|
projectPath,
|
|
49
54
|
});
|
|
50
|
-
// Overwrite the
|
|
51
|
-
yield file_utils_1.overwriteIndex(projectPath, "react", scheme);
|
|
55
|
+
// Overwrite the App.tsx
|
|
56
|
+
yield (0, file_utils_1.overwriteIndex)(projectPath, "react", scheme);
|
|
52
57
|
}
|
|
58
|
+
// Deactivate React.StrictMode from index.tsx
|
|
59
|
+
const indexFileName = path_1.default.join(projectPath, "src", `index.${useTypescript ? "tsx" : "ts"}`);
|
|
60
|
+
let indexFile = fs_1.default.readFileSync(indexFileName).toString();
|
|
61
|
+
indexFile = indexFile.replace("<React.StrictMode>", "");
|
|
62
|
+
indexFile = indexFile.replace("</React.StrictMode>", "");
|
|
63
|
+
fs_1.default.writeFileSync(indexFileName, indexFile);
|
|
53
64
|
return;
|
|
54
65
|
}),
|
|
55
66
|
build: (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
56
67
|
const { npmRunCmd, projectPath } = args;
|
|
57
|
-
yield cmd_utils_1.spawnOrFail(`${npmRunCmd} build`, projectPath);
|
|
68
|
+
yield (0, cmd_utils_1.spawnOrFail)(`${npmRunCmd} build`, projectPath);
|
|
58
69
|
}),
|
|
59
70
|
};
|
|
60
71
|
exports.default = reactStrategy;
|
package/dist/templates/gatsby.js
CHANGED
|
@@ -9,11 +9,11 @@ import React from "react";
|
|
|
9
9
|
import Helmet from "react-helmet";
|
|
10
10
|
import {
|
|
11
11
|
PlasmicComponent,
|
|
12
|
-
PlasmicRootProvider,${file_utils_1.ifTs(ts, `
|
|
12
|
+
PlasmicRootProvider,${(0, file_utils_1.ifTs)(ts, `
|
|
13
13
|
InitOptions,
|
|
14
14
|
ComponentRenderData,`)}
|
|
15
15
|
} from "@plasmicapp/loader-gatsby";
|
|
16
|
-
import { graphql${file_utils_1.ifTs(ts, ", PageProps")} } from "gatsby";
|
|
16
|
+
import { graphql${(0, file_utils_1.ifTs)(ts, ", PageProps")} } from "gatsby";
|
|
17
17
|
import { initPlasmicLoaderWithRegistrations } from "../plasmic-init";
|
|
18
18
|
|
|
19
19
|
export const query = graphql\`
|
|
@@ -23,14 +23,14 @@ export const query = graphql\`
|
|
|
23
23
|
}
|
|
24
24
|
\`;
|
|
25
25
|
|
|
26
|
-
${file_utils_1.ifTs(ts, `interface PlasmicGatsbyPageProps extends PageProps {
|
|
26
|
+
${(0, file_utils_1.ifTs)(ts, `interface PlasmicGatsbyPageProps extends PageProps {
|
|
27
27
|
data: {
|
|
28
28
|
plasmicOptions: InitOptions
|
|
29
29
|
plasmicComponents: ComponentRenderData
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
`)}
|
|
33
|
-
const PlasmicGatsbyPage = ({ data, location }${file_utils_1.ifTs(ts, ": PlasmicGatsbyPageProps")}) => {
|
|
33
|
+
const PlasmicGatsbyPage = ({ data, location }${(0, file_utils_1.ifTs)(ts, ": PlasmicGatsbyPageProps")}) => {
|
|
34
34
|
const {
|
|
35
35
|
plasmicComponents,
|
|
36
36
|
plasmicOptions,
|
|
@@ -91,7 +91,7 @@ const makeGatsbyHostPage = (opts) => {
|
|
|
91
91
|
return `
|
|
92
92
|
import * as React from "react"
|
|
93
93
|
import {
|
|
94
|
-
PlasmicCanvasHost${file_utils_1.ifTs(useTypescript, `, InitOptions`)}
|
|
94
|
+
PlasmicCanvasHost${(0, file_utils_1.ifTs)(useTypescript, `, InitOptions`)}
|
|
95
95
|
} from "@plasmicapp/loader-gatsby"
|
|
96
96
|
import { graphql } from "gatsby"
|
|
97
97
|
import { initPlasmicLoaderWithRegistrations } from "../plasmic-init"
|
|
@@ -102,13 +102,13 @@ export const query = graphql\`
|
|
|
102
102
|
}
|
|
103
103
|
\`
|
|
104
104
|
|
|
105
|
-
${file_utils_1.ifTs(useTypescript, `interface HostProps {
|
|
105
|
+
${(0, file_utils_1.ifTs)(useTypescript, `interface HostProps {
|
|
106
106
|
data: {
|
|
107
107
|
plasmicOptions: InitOptions;
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
`)}
|
|
111
|
-
export default function Host({ data }${file_utils_1.ifTs(useTypescript, ": HostProps")}) {
|
|
111
|
+
export default function Host({ data }${(0, file_utils_1.ifTs)(useTypescript, ": HostProps")}) {
|
|
112
112
|
const { plasmicOptions } = data
|
|
113
113
|
initPlasmicLoaderWithRegistrations(plasmicOptions)
|
|
114
114
|
return <PlasmicCanvasHost />
|
|
@@ -188,11 +188,11 @@ const makeGatsbyPlasmicInit = (format) => {
|
|
|
188
188
|
const ts = format === "ts";
|
|
189
189
|
return `
|
|
190
190
|
import {
|
|
191
|
-
initPlasmicLoader,${file_utils_1.ifTs(ts, `
|
|
191
|
+
initPlasmicLoader,${(0, file_utils_1.ifTs)(ts, `
|
|
192
192
|
InitOptions,`)}
|
|
193
193
|
} from "@plasmicapp/loader-gatsby";
|
|
194
194
|
|
|
195
|
-
export function initPlasmicLoaderWithRegistrations(plasmicOptions${file_utils_1.ifTs(ts, ": InitOptions")}) {
|
|
195
|
+
export function initPlasmicLoaderWithRegistrations(plasmicOptions${(0, file_utils_1.ifTs)(ts, ": InitOptions")}) {
|
|
196
196
|
const PLASMIC = initPlasmicLoader(plasmicOptions);
|
|
197
197
|
|
|
198
198
|
// You can register any code components that you want to use here; see
|
package/dist/templates/nextjs.js
CHANGED
|
@@ -40,12 +40,12 @@ import {
|
|
|
40
40
|
ComponentRenderData,
|
|
41
41
|
PlasmicRootProvider,
|
|
42
42
|
} from "@plasmicapp/loader-nextjs";
|
|
43
|
-
${file_utils_1.ifTs(ts, `import type { GetStaticPaths, GetStaticProps } from "next";\n`)}
|
|
43
|
+
${(0, file_utils_1.ifTs)(ts, `import type { GetStaticPaths, GetStaticProps } from "next";\n`)}
|
|
44
44
|
import Error from "next/error";
|
|
45
45
|
import { useRouter } from "next/router";
|
|
46
46
|
import { PLASMIC } from "../plasmic-init";
|
|
47
47
|
|
|
48
|
-
export default function PlasmicLoaderPage(props${file_utils_1.ifTs(ts, `: {
|
|
48
|
+
export default function PlasmicLoaderPage(props${(0, file_utils_1.ifTs)(ts, `: {
|
|
49
49
|
plasmicData?: ComponentRenderData;
|
|
50
50
|
queryCache?: Record<string, any>;
|
|
51
51
|
}`)}) {
|
|
@@ -68,7 +68,7 @@ export default function PlasmicLoaderPage(props${file_utils_1.ifTs(ts, `: {
|
|
|
68
68
|
);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
export const getStaticProps${file_utils_1.ifTs(ts, `: GetStaticProps`)} = async (context) => {
|
|
71
|
+
export const getStaticProps${(0, file_utils_1.ifTs)(ts, `: GetStaticProps`)} = async (context) => {
|
|
72
72
|
const { catchall } = context.params ?? {};
|
|
73
73
|
const plasmicPath = typeof catchall === 'string' ? catchall : Array.isArray(catchall) ? \`/\${catchall.join('/')}\` : '/';
|
|
74
74
|
const plasmicData = await PLASMIC.maybeFetchComponentData(plasmicPath);
|
|
@@ -91,7 +91,7 @@ export const getStaticProps${file_utils_1.ifTs(ts, `: GetStaticProps`)} = async
|
|
|
91
91
|
return { props: { plasmicData, queryCache }, revalidate: 60 };
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
export const getStaticPaths${file_utils_1.ifTs(ts, `: GetStaticPaths`)} = async () => {
|
|
94
|
+
export const getStaticPaths${(0, file_utils_1.ifTs)(ts, `: GetStaticPaths`)} = async () => {
|
|
95
95
|
const pageModules = await PLASMIC.fetchPages();
|
|
96
96
|
return {
|
|
97
97
|
paths: pageModules.map((mod) => ({
|
package/dist/templates/readme.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.README = void 0;
|
|
4
4
|
const lib_1 = require("../lib");
|
|
5
5
|
const README = (platform, buildCommand) => `
|
|
6
|
-
This is a ${lib_1.toString(platform)} project bootstrapped with [\`create-plasmic-app\`](https://www.npmjs.com/package/create-plasmic-app).
|
|
6
|
+
This is a ${(0, lib_1.toString)(platform)} project bootstrapped with [\`create-plasmic-app\`](https://www.npmjs.com/package/create-plasmic-app).
|
|
7
7
|
|
|
8
8
|
## Getting Started
|
|
9
9
|
|
package/dist/utils/cmd-utils.js
CHANGED
|
@@ -17,7 +17,7 @@ const npm_utils_1 = require("./npm-utils");
|
|
|
17
17
|
*/
|
|
18
18
|
function spawnOrFail(cmd, workingDir, customErrorMsg) {
|
|
19
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
const result = yield npm_utils_1.spawn(cmd, workingDir);
|
|
20
|
+
const result = yield (0, npm_utils_1.spawn)(cmd, workingDir);
|
|
21
21
|
if (!result) {
|
|
22
22
|
throw new Error(customErrorMsg !== null && customErrorMsg !== void 0 ? customErrorMsg : `Failed to run "${cmd}"`);
|
|
23
23
|
}
|
package/dist/utils/file-utils.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -50,7 +54,7 @@ function deleteGlob(searchPattern, skipPatterns) {
|
|
|
50
54
|
const filesToDelete = glob_1.default
|
|
51
55
|
.sync(searchPattern)
|
|
52
56
|
.filter((file) => !skipPatterns || !skipPatterns.find((pattern) => file.includes(pattern)));
|
|
53
|
-
filesToDelete.forEach((f) => fs_1.unlinkSync(f));
|
|
57
|
+
filesToDelete.forEach((f) => (0, fs_1.unlinkSync)(f));
|
|
54
58
|
}
|
|
55
59
|
exports.deleteGlob = deleteGlob;
|
|
56
60
|
function stripExtension(filename, removeComposedPath = false) {
|
|
@@ -95,7 +99,7 @@ function overwriteIndex(projectPath, platform, scheme) {
|
|
|
95
99
|
const config = yield getPlasmicConfig(projectPath, platform, scheme);
|
|
96
100
|
const plasmicFiles = lodash_1.default.map(lodash_1.default.flatMap(config.projects, (p) => p.components), (c) => c.importSpec.modulePath);
|
|
97
101
|
const isTypescript = ((_a = config === null || config === void 0 ? void 0 : config.code) === null || _a === void 0 ? void 0 : _a.lang) === "ts";
|
|
98
|
-
const pagesDir = lang_utils_1.ensure(isNextjs
|
|
102
|
+
const pagesDir = (0, lang_utils_1.ensure)(isNextjs
|
|
99
103
|
? path.join(projectPath, "pages/")
|
|
100
104
|
: isGatsby
|
|
101
105
|
? path.join(projectPath, "src/pages/")
|
|
@@ -127,7 +131,7 @@ function overwriteIndex(projectPath, platform, scheme) {
|
|
|
127
131
|
plasmicFiles.find((f) => f.includes("/index."))) {
|
|
128
132
|
return;
|
|
129
133
|
}
|
|
130
|
-
const homeFilePossibilities = glob_1.default.sync(path.join(projectPath, lang_utils_1.ensureString(config.srcDir), "**", "@(index|Home|home).*"));
|
|
134
|
+
const homeFilePossibilities = glob_1.default.sync(path.join(projectPath, (0, lang_utils_1.ensureString)(config.srcDir), "**", "@(index|Home|home|Homepage).*"));
|
|
131
135
|
const content = isCra && homeFilePossibilities.length > 0
|
|
132
136
|
? generateHomePage(homeFilePossibilities[0], indexAbsPath)
|
|
133
137
|
: generateWelcomePage(config, platform);
|
|
@@ -144,7 +148,7 @@ exports.overwriteIndex = overwriteIndex;
|
|
|
144
148
|
function overwriteReadme(projectPath, platform, buildCommand) {
|
|
145
149
|
return __awaiter(this, void 0, void 0, function* () {
|
|
146
150
|
const readmeFile = path.join(projectPath, "README.md");
|
|
147
|
-
const contents = readme_1.README(platform, buildCommand);
|
|
151
|
+
const contents = (0, readme_1.README)(platform, buildCommand);
|
|
148
152
|
yield fs_1.promises.writeFile(readmeFile, contents);
|
|
149
153
|
});
|
|
150
154
|
}
|
|
@@ -211,7 +215,7 @@ function generateWelcomePage(config, platform) {
|
|
|
211
215
|
</ul>
|
|
212
216
|
`;
|
|
213
217
|
};
|
|
214
|
-
const content = welcomePage_1.WELCOME_PAGE(hasPages, platform, hasPages ? getPageSection() : "");
|
|
218
|
+
const content = (0, welcomePage_1.WELCOME_PAGE)(hasPages, platform, hasPages ? getPageSection() : "");
|
|
215
219
|
return content;
|
|
216
220
|
}
|
|
217
221
|
function getPlasmicConfig(projectPath, platform, scheme) {
|
|
@@ -220,7 +224,7 @@ function getPlasmicConfig(projectPath, platform, scheme) {
|
|
|
220
224
|
const isGatsby = platform === "gatsby";
|
|
221
225
|
const isLoader = scheme === "loader";
|
|
222
226
|
const isCodegen = scheme === "codegen";
|
|
223
|
-
const configPath = lang_utils_1.ensure(isCodegen
|
|
227
|
+
const configPath = (0, lang_utils_1.ensure)(isCodegen
|
|
224
228
|
? "plasmic.json"
|
|
225
229
|
: isNextjs && isLoader
|
|
226
230
|
? ".plasmic/plasmic.json"
|
|
@@ -236,9 +240,9 @@ function getPlasmicConfig(projectPath, platform, scheme) {
|
|
|
236
240
|
function ensureTsconfig(projectPath) {
|
|
237
241
|
return __awaiter(this, void 0, void 0, function* () {
|
|
238
242
|
const tsconfigPath = path.join(projectPath, "tsconfig.json");
|
|
239
|
-
if (!fs_1.existsSync(tsconfigPath)) {
|
|
243
|
+
if (!(0, fs_1.existsSync)(tsconfigPath)) {
|
|
240
244
|
yield fs_1.promises.writeFile(tsconfigPath, "");
|
|
241
|
-
const installTsResult = yield npm_utils_1.installUpgrade("typescript @types/react", {
|
|
245
|
+
const installTsResult = yield (0, npm_utils_1.installUpgrade)("typescript @types/react", {
|
|
242
246
|
workingDir: projectPath,
|
|
243
247
|
});
|
|
244
248
|
if (!installTsResult) {
|
package/dist/utils/npm-utils.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -47,7 +51,7 @@ const update_notifier_1 = __importDefault(require("update-notifier"));
|
|
|
47
51
|
*/
|
|
48
52
|
function updateNotify() {
|
|
49
53
|
const pkg = require("../../package.json");
|
|
50
|
-
const notifier = update_notifier_1.default({
|
|
54
|
+
const notifier = (0, update_notifier_1.default)({
|
|
51
55
|
pkg,
|
|
52
56
|
updateCheckInterval: 1000 * 60 * 60, // Check once an hour
|
|
53
57
|
});
|
|
@@ -149,7 +153,7 @@ function detectPackageManager(dir) {
|
|
|
149
153
|
// with findupSync, the reason for this is that the current gatsby template
|
|
150
154
|
// uses npm, so if the user has some yarn.lock in a parent directory it's
|
|
151
155
|
// going to run yarn commands, this is going to trigger an error with sharp
|
|
152
|
-
const yarnLock = fs_1.existsSync(path_1.default.join(dir ? dir : "", "yarn.lock"));
|
|
156
|
+
const yarnLock = (0, fs_1.existsSync)(path_1.default.join(dir ? dir : "", "yarn.lock"));
|
|
153
157
|
if (yarnLock) {
|
|
154
158
|
return "yarn";
|
|
155
159
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-plasmic-app",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.56",
|
|
4
4
|
"description": "Create Plasmic-powered React apps",
|
|
5
5
|
"main": "./dist/lib.js",
|
|
6
6
|
"types": "./dist/lib.d.ts",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"typescript": "^4.2.3"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@plasmicapp/cli": "
|
|
43
|
+
"@plasmicapp/cli": "0.1.187",
|
|
44
44
|
"@sentry/node": "^6.2.2",
|
|
45
45
|
"chalk": "^4.1.0",
|
|
46
46
|
"execa": "^5.0.0",
|
|
@@ -53,5 +53,6 @@
|
|
|
53
53
|
"update-notifier": "^5.1.0",
|
|
54
54
|
"validate-npm-package-name": "^3.0.0",
|
|
55
55
|
"yargs": "^16.2.0"
|
|
56
|
-
}
|
|
56
|
+
},
|
|
57
|
+
"gitHead": "698a9369125b9655bffeed9507a441224e354d01"
|
|
57
58
|
}
|
package/src/strategies/react.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
1
3
|
import { spawnOrFail } from "../utils/cmd-utils";
|
|
2
4
|
import { overwriteIndex } from "../utils/file-utils";
|
|
3
5
|
import { installUpgrade } from "../utils/npm-utils";
|
|
@@ -34,6 +36,7 @@ const reactStrategy: CPAStrategy = {
|
|
|
34
36
|
projectApiToken,
|
|
35
37
|
projectId,
|
|
36
38
|
projectPath,
|
|
39
|
+
useTypescript,
|
|
37
40
|
}) => {
|
|
38
41
|
if (scheme === "loader") {
|
|
39
42
|
// Nothing to do
|
|
@@ -44,9 +47,21 @@ const reactStrategy: CPAStrategy = {
|
|
|
44
47
|
projectPath,
|
|
45
48
|
});
|
|
46
49
|
|
|
47
|
-
// Overwrite the
|
|
50
|
+
// Overwrite the App.tsx
|
|
48
51
|
await overwriteIndex(projectPath, "react", scheme);
|
|
49
52
|
}
|
|
53
|
+
|
|
54
|
+
// Deactivate React.StrictMode from index.tsx
|
|
55
|
+
const indexFileName = path.join(
|
|
56
|
+
projectPath,
|
|
57
|
+
"src",
|
|
58
|
+
`index.${useTypescript ? "tsx" : "ts"}`
|
|
59
|
+
);
|
|
60
|
+
let indexFile = fs.readFileSync(indexFileName).toString();
|
|
61
|
+
indexFile = indexFile.replace("<React.StrictMode>", "");
|
|
62
|
+
indexFile = indexFile.replace("</React.StrictMode>", "");
|
|
63
|
+
fs.writeFileSync(indexFileName, indexFile);
|
|
64
|
+
|
|
50
65
|
return;
|
|
51
66
|
},
|
|
52
67
|
build: async (args) => {
|
package/src/utils/file-utils.ts
CHANGED
package/tsconfig.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// "allowJs": true, /* Allow javascript files to be compiled. */
|
|
9
9
|
// "checkJs": true, /* Report errors in .js files. */
|
|
10
10
|
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
|
11
|
-
"declaration": true
|
|
11
|
+
"declaration": true /* Generates corresponding '.d.ts' file. */,
|
|
12
12
|
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
|
13
13
|
// "sourceMap": true, /* Generates corresponding '.map' file. */
|
|
14
14
|
// "outFile": "./", /* Concatenate and emit output to single file. */
|
|
@@ -61,7 +61,8 @@
|
|
|
61
61
|
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
|
62
62
|
|
|
63
63
|
/* Advanced Options */
|
|
64
|
-
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file.
|
|
64
|
+
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
|
|
65
|
+
"skipLibCheck": true
|
|
65
66
|
},
|
|
66
67
|
"include": ["src"]
|
|
67
68
|
}
|