create-plasmic-app 0.0.33 → 0.0.37

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/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- export {};
2
+ export declare type CodeScheme = "codegen" | "loader";
package/dist/index.js CHANGED
@@ -34,7 +34,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
34
34
  Object.defineProperty(exports, "__esModule", { value: true });
35
35
  const cli_1 = require("@plasmicapp/cli");
36
36
  const Sentry = __importStar(require("@sentry/node"));
37
- const chalk_1 = __importDefault(require("chalk"));
38
37
  const fs = __importStar(require("fs"));
39
38
  const inquirer_1 = __importDefault(require("inquirer"));
40
39
  const path = __importStar(require("upath"));
@@ -198,16 +197,14 @@ function run() {
198
197
  : "codegen";
199
198
  // Get the projectId
200
199
  console.log();
201
- console.log(chalk_1.default.green.bold("Go to this URL and **clone** the project:"));
202
- console.log("https://studio.plasmic.app/starters/simple-light");
203
- console.log();
204
- console.log(" Note the project ID in the URL redirect");
205
- console.log(" (e.g. https://studio.plasmic.app/projects/PROJECT_ID)");
206
200
  let projectId;
207
201
  while (!projectId) {
208
202
  const rawProjectId = yield maybePrompt({
209
203
  name: "projectId",
210
- message: "What is the project ID of your project?",
204
+ message: `What is the URL of your project?
205
+ (If you don't have a project yet, create one by going to
206
+ https://studio.plasmic.app/starters/simple-light):
207
+ `,
211
208
  });
212
209
  projectId = rawProjectId
213
210
  .replace("https://studio.plasmic.app/projects/", "")
package/dist/lib.js CHANGED
@@ -37,7 +37,6 @@ const chalk_1 = __importDefault(require("chalk"));
37
37
  const path = __importStar(require("upath"));
38
38
  const validate_npm_package_name_1 = __importDefault(require("validate-npm-package-name"));
39
39
  const strategies_1 = require("./strategies");
40
- const cmd_utils_1 = require("./utils/cmd-utils");
41
40
  const file_utils_1 = require("./utils/file-utils");
42
41
  const npm_utils_1 = require("./utils/npm-utils");
43
42
  function toString(s) {
@@ -85,61 +84,49 @@ function create(args) {
85
84
  useTypescript,
86
85
  template,
87
86
  });
88
- // Ensure that
89
- if (useTypescript) {
87
+ // Ensure that we have a empty tsconfig and @types packages
88
+ // Gatsby by default supports typescript handling internally
89
+ // tsconfig so we don't have to ensure it
90
+ if (useTypescript && platform !== "gatsby") {
90
91
  yield file_utils_1.ensureTsconfig(resolvedProjectPath);
91
92
  }
92
- // Install dependency
93
- banner("INSTALLING THE PLASMIC DEPENDENCY");
94
- if (scheme === "codegen") {
95
- const installResult = yield npm_utils_1.installUpgrade("@plasmicapp/cli", {
96
- workingDir: resolvedProjectPath,
97
- });
98
- if (!installResult) {
99
- throw new Error("Failed to install the Plasmic dependency");
100
- }
101
- }
102
- // Trigger a sync
103
- const pkgMgr = npm_utils_1.detectPackageManager(resolvedProjectPath);
104
- const npmRunCmd = pkgMgr === "yarn" ? "yarn" : "npm run";
105
- if (scheme === "codegen") {
106
- banner("SYNCING PLASMIC COMPONENTS");
107
- const project = projectApiToken
108
- ? `${projectId}:${projectApiToken}`
109
- : projectId;
110
- if (platform === "nextjs") {
111
- yield file_utils_1.writeDefaultNextjsConfig(resolvedProjectPath, projectId, false);
112
- }
113
- yield cmd_utils_1.spawnOrFail(`npx -p @plasmicapp/cli plasmic sync --yes -p ${project}`, resolvedProjectPath);
114
- }
115
- else if (scheme === "loader") {
116
- if (!projectApiToken) {
117
- projectApiToken = yield cli_1.getProjectApiToken(projectId);
118
- }
93
+ // Make sure we have an api token for loader
94
+ if (scheme === "loader" && !projectApiToken) {
95
+ projectApiToken = yield cli_1.getProjectApiToken(projectId);
119
96
  if (!projectApiToken) {
120
97
  throw new Error(`Failed to get projectApiToken for ${projectId}`);
121
98
  }
122
- yield cpaStrategy.configLoader({
123
- projectPath: resolvedProjectPath,
124
- projectId,
125
- projectApiToken,
126
- useTypescript,
127
- });
128
99
  }
129
- if (scheme === "loader") {
130
- yield cpaStrategy.overwriteFiles({ projectPath: resolvedProjectPath });
131
- }
132
- else if (scheme === "codegen") {
133
- // The loader files to be overwritten are handled by cpaStrategy
134
- // but for codegen we still have to run it
135
- // Overwrite the index file
136
- yield file_utils_1.overwriteIndex(resolvedProjectPath, platform, scheme);
137
- // Overwrite the wrapper files to wrap PlasmicRootProvider
138
- yield file_utils_1.wrapAppRoot(resolvedProjectPath, platform, scheme);
100
+ // Install dependency
101
+ banner("INSTALLING THE PLASMIC DEPENDENCY");
102
+ const installResult = yield cpaStrategy.installDeps({
103
+ scheme,
104
+ projectPath: resolvedProjectPath,
105
+ });
106
+ if (!installResult) {
107
+ throw new Error("Failed to install the Plasmic dependency");
139
108
  }
109
+ // Configure
110
+ yield cpaStrategy.overwriteConfig({
111
+ projectId,
112
+ projectPath: resolvedProjectPath,
113
+ projectApiToken,
114
+ useTypescript,
115
+ scheme,
116
+ });
117
+ // Generate files
118
+ yield cpaStrategy.generateFiles({
119
+ projectPath: resolvedProjectPath,
120
+ useTypescript,
121
+ scheme,
122
+ projectId,
123
+ projectApiToken,
124
+ });
140
125
  /**
141
126
  * INSTRUCT USER ON NEXT STEPS
142
127
  */
128
+ const pkgMgr = npm_utils_1.detectPackageManager(resolvedProjectPath);
129
+ const npmRunCmd = pkgMgr === "yarn" ? "yarn" : "npm run";
143
130
  const command = platform === "nextjs"
144
131
  ? `${npmRunCmd} dev`
145
132
  : platform === "gatsby"
@@ -0,0 +1,8 @@
1
+ export declare function installCodegenDeps(opts: {
2
+ projectPath: string;
3
+ }): Promise<boolean>;
4
+ export declare function runCodegenSync(opts: {
5
+ projectId: string;
6
+ projectApiToken: string | undefined;
7
+ projectPath: string;
8
+ }): Promise<void>;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.runCodegenSync = exports.installCodegenDeps = void 0;
13
+ const lib_1 = require("../lib");
14
+ const cmd_utils_1 = require("../utils/cmd-utils");
15
+ const npm_utils_1 = require("../utils/npm-utils");
16
+ function installCodegenDeps(opts) {
17
+ return __awaiter(this, void 0, void 0, function* () {
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 })));
21
+ });
22
+ }
23
+ exports.installCodegenDeps = installCodegenDeps;
24
+ function runCodegenSync(opts) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ const { projectId, projectApiToken, projectPath } = opts;
27
+ lib_1.banner("SYNCING PLASMIC COMPONENTS");
28
+ const project = projectApiToken
29
+ ? `${projectId}:${projectApiToken}`
30
+ : projectId;
31
+ yield cmd_utils_1.spawnOrFail(`npx -p @plasmicapp/cli plasmic sync --yes -p ${project}`, projectPath);
32
+ });
33
+ }
34
+ exports.runCodegenSync = runCodegenSync;
@@ -44,68 +44,98 @@ const readline = __importStar(require("readline"));
44
44
  const gatsby_1 = require("../templates/gatsby");
45
45
  const cmd_utils_1 = require("../utils/cmd-utils");
46
46
  const file_utils_1 = require("../utils/file-utils");
47
+ const lang_utils_1 = require("../utils/lang-utils");
47
48
  const npm_utils_1 = require("../utils/npm-utils");
49
+ const common_1 = require("./common");
48
50
  const gatsbyStrategy = {
49
51
  create: (args) => __awaiter(void 0, void 0, void 0, function* () {
50
52
  const { projectPath, template } = args;
51
53
  const createCommand = `npx -p gatsby gatsby new ${projectPath}`;
52
54
  const templateArg = template ? ` ${template}` : "";
53
- // Default Gatsby starter already supports Typescript
54
- // See where we `touch tsconfig.json` later on
55
55
  yield cmd_utils_1.spawnOrFail(`${createCommand}${templateArg}`);
56
56
  }),
57
- configLoader: (args) => __awaiter(void 0, void 0, void 0, function* () {
58
- var e_1, _a;
59
- const { projectId, projectPath, projectApiToken } = args;
60
- const installResult = yield npm_utils_1.installUpgrade("@plasmicapp/loader-gatsby", {
61
- workingDir: projectPath,
62
- });
63
- if (!installResult) {
64
- throw new Error("Failed to install the Plasmic dependency");
57
+ installDeps: ({ projectPath, scheme }) => __awaiter(void 0, void 0, void 0, function* () {
58
+ if (scheme === "loader") {
59
+ return yield npm_utils_1.installUpgrade("@plasmicapp/loader-gatsby", {
60
+ workingDir: projectPath,
61
+ });
65
62
  }
66
- // create-gatsby will create a default gatsby-config.js that we need to modify
67
- const gatsbyConfigFile = path_1.default.join(projectPath, "gatsby-config.js");
68
- const rl = readline.createInterface({
69
- input: fs_1.createReadStream(gatsbyConfigFile),
70
- crlfDelay: Infinity,
71
- });
72
- let result = "";
73
- try {
74
- for (var rl_1 = __asyncValues(rl), rl_1_1; rl_1_1 = yield rl_1.next(), !rl_1_1.done;) {
75
- const line = rl_1_1.value;
76
- result += line + "\n";
77
- // Prepend PlasmicLoader to list of plugins
78
- if (line.includes("plugins:")) {
79
- result += gatsby_1.GATSBY_PLUGIN_CONFIG(projectId, projectApiToken);
80
- }
81
- }
63
+ else {
64
+ return yield common_1.installCodegenDeps({ projectPath });
82
65
  }
83
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
84
- finally {
66
+ }),
67
+ overwriteConfig: (args) => __awaiter(void 0, void 0, void 0, function* () {
68
+ var e_1, _a;
69
+ const { projectId, projectPath, projectApiToken, useTypescript, scheme, } = args;
70
+ if (scheme === "loader") {
71
+ // create-gatsby will create a default gatsby-config.js that we need to modify
72
+ const gatsbyConfigFile = path_1.default.join(projectPath, "gatsby-config.js");
73
+ const rl = readline.createInterface({
74
+ input: fs_1.createReadStream(gatsbyConfigFile),
75
+ crlfDelay: Infinity,
76
+ });
77
+ let result = "";
85
78
  try {
86
- if (rl_1_1 && !rl_1_1.done && (_a = rl_1.return)) yield _a.call(rl_1);
79
+ for (var rl_1 = __asyncValues(rl), rl_1_1; rl_1_1 = yield rl_1.next(), !rl_1_1.done;) {
80
+ const line = rl_1_1.value;
81
+ result += line + "\n";
82
+ // Prepend PlasmicLoader to list of plugins
83
+ if (line.includes("plugins:")) {
84
+ result += gatsby_1.GATSBY_PLUGIN_CONFIG(projectId, lang_utils_1.ensure(projectApiToken), useTypescript);
85
+ }
86
+ }
87
+ }
88
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
89
+ finally {
90
+ try {
91
+ if (rl_1_1 && !rl_1_1.done && (_a = rl_1.return)) yield _a.call(rl_1);
92
+ }
93
+ finally { if (e_1) throw e_1.error; }
87
94
  }
88
- finally { if (e_1) throw e_1.error; }
95
+ yield fs_1.promises.writeFile(gatsbyConfigFile, result);
89
96
  }
90
- yield fs_1.promises.writeFile(gatsbyConfigFile, result);
91
97
  }),
92
- overwriteFiles: (args) => __awaiter(void 0, void 0, void 0, function* () {
98
+ generateFiles: (args) => __awaiter(void 0, void 0, void 0, function* () {
93
99
  // in gatsby we can delete all existing pages/components, since all pages are going
94
100
  // to be handled by templates/defaultPlasmicPage
95
- const { projectPath } = args;
101
+ const { projectId, projectApiToken, projectPath, useTypescript, scheme, } = args;
102
+ const extension = useTypescript ? "ts" : "js";
96
103
  file_utils_1.deleteGlob(path_1.default.join(projectPath, "src/@(pages|components|templates)/*.*"));
97
104
  // Create a very basic 404 page - `gatsby build` fails without it.
98
- // We've deleted the components that the default 404 page depended
99
- // on, so
100
- yield fs_1.promises.writeFile(path_1.default.join(projectPath, "src/pages/404.js"), gatsby_1.GATSBY_404);
105
+ yield fs_1.promises.writeFile(path_1.default.join(projectPath, `src/pages/404.js`), gatsby_1.GATSBY_404);
106
+ // Add plasmic-host page
107
+ yield fs_1.promises.writeFile(path_1.default.join(projectPath, `src/pages/plasmic-host.${extension}x`), gatsby_1.makeGatsbyHostPage({
108
+ useTypescript,
109
+ scheme,
110
+ }));
101
111
  // Start with an empty gatsby-node.js
102
112
  yield fs_1.promises.writeFile(path_1.default.join(projectPath, "gatsby-node.js"), "");
103
- const templatesFolder = path_1.default.join(projectPath, "src/templates");
104
- const defaultPagePath = path_1.default.join(templatesFolder, "defaultPlasmicPage.js");
105
- if (!fs_1.existsSync(templatesFolder)) {
106
- yield fs_1.promises.mkdir(templatesFolder);
113
+ // Updates `gatsby-ssr` to include script tag for preamble
114
+ yield fs_1.promises.writeFile(path_1.default.join(projectPath, "gatsby-ssr.js"), gatsby_1.GATSBY_SSR_CONFIG);
115
+ if (scheme === "loader") {
116
+ yield fs_1.promises.writeFile(path_1.default.join(projectPath, `src/plasmic-init.${extension}`), gatsby_1.makeGatsbyPlasmicInit(extension));
117
+ const templatesFolder = path_1.default.join(projectPath, "src/templates");
118
+ if (!fs_1.existsSync(templatesFolder)) {
119
+ yield fs_1.promises.mkdir(templatesFolder);
120
+ }
121
+ const defaultPagePath = path_1.default.join(templatesFolder, `defaultPlasmicPage.${extension}x`);
122
+ yield fs_1.promises.writeFile(defaultPagePath, gatsby_1.makeGatsbyDefaultPage(extension));
123
+ }
124
+ else {
125
+ yield common_1.runCodegenSync({
126
+ projectId,
127
+ projectApiToken,
128
+ projectPath,
129
+ });
130
+ // Overwrite the index file
131
+ yield file_utils_1.overwriteIndex(projectPath, "gatsby", scheme);
132
+ // Overwrite the wrapper files to wrap PlasmicRootProvider
133
+ const wrapperContent = gatsby_1.wrapAppRootForCodegen();
134
+ const browserFilePath = path_1.default.join(projectPath, "gatsby-browser.js");
135
+ yield fs_1.promises.writeFile(browserFilePath, wrapperContent);
136
+ const ssrFilePath = path_1.default.join(projectPath, "gatsby-ssr.js");
137
+ yield fs_1.promises.writeFile(ssrFilePath, wrapperContent);
107
138
  }
108
- yield fs_1.promises.writeFile(defaultPagePath, gatsby_1.GATSBY_DEFAULT_PAGE);
109
139
  }),
110
140
  build: (args) => __awaiter(void 0, void 0, void 0, function* () {
111
141
  const { npmRunCmd, projectPath } = args;
@@ -12,10 +12,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ const promises_1 = __importDefault(require("fs/promises"));
15
16
  const path_1 = __importDefault(require("path"));
17
+ const nextjs_1 = require("../templates/nextjs");
16
18
  const cmd_utils_1 = require("../utils/cmd-utils");
17
19
  const file_utils_1 = require("../utils/file-utils");
20
+ const lang_utils_1 = require("../utils/lang-utils");
18
21
  const npm_utils_1 = require("../utils/npm-utils");
22
+ const common_1 = require("./common");
19
23
  const nextjsStrategy = {
20
24
  create: (args) => __awaiter(void 0, void 0, void 0, function* () {
21
25
  const { projectPath, template, useTypescript } = args;
@@ -25,25 +29,59 @@ const nextjsStrategy = {
25
29
  // See where we `touch tsconfig.json` later on
26
30
  yield cmd_utils_1.spawnOrFail(`${createCommand}${templateArg}`);
27
31
  }),
28
- configLoader: (args) => __awaiter(void 0, void 0, void 0, function* () {
29
- const { projectId, projectPath, projectApiToken, useTypescript } = args;
30
- const installResult = yield npm_utils_1.installUpgrade("@plasmicapp/loader-nextjs", {
31
- workingDir: projectPath,
32
- });
33
- if (!installResult) {
34
- throw new Error("Failed to install the Plasmic dependency");
32
+ installDeps: ({ scheme, projectPath }) => __awaiter(void 0, void 0, void 0, function* () {
33
+ if (scheme === "loader") {
34
+ return yield npm_utils_1.installUpgrade("@plasmicapp/loader-nextjs", {
35
+ workingDir: projectPath,
36
+ });
37
+ }
38
+ else {
39
+ return yield common_1.installCodegenDeps({ projectPath });
40
+ }
41
+ }),
42
+ overwriteConfig: (args) => __awaiter(void 0, void 0, void 0, function* () {
43
+ const { projectPath, scheme } = args;
44
+ if (scheme === "codegen") {
45
+ const nextjsConfigFile = path_1.default.join(projectPath, "next.config.js");
46
+ yield promises_1.default.writeFile(nextjsConfigFile, `
47
+ module.exports = {
48
+ eslint: {
49
+ ignoreDuringBuilds: true,
50
+ },
51
+ trailingSlash: true,
52
+ // Your NextJS config.
53
+ };
54
+ `);
35
55
  }
36
- yield file_utils_1.writeDefaultNextjsConfig(projectPath, projectId, true, projectApiToken, useTypescript);
37
56
  }),
38
- overwriteFiles: (args) => __awaiter(void 0, void 0, void 0, function* () {
57
+ generateFiles: (args) => __awaiter(void 0, void 0, void 0, function* () {
39
58
  // this is supposed to be called for loader case, so we are supposed to remove
40
59
  // all the files from pages/ since we have inserted a optional catch all
41
- const { projectPath } = args;
60
+ const { projectPath, scheme, useTypescript, projectId, projectApiToken, } = args;
61
+ // Always start fresh
42
62
  const pagesPath = path_1.default.join(projectPath, "pages");
43
- file_utils_1.deleteGlob(path_1.default.join(pagesPath, `*.*`), [
44
- "[[...catchall]]",
45
- "plasmic-host",
46
- ]);
63
+ file_utils_1.deleteGlob(path_1.default.join(pagesPath, `*.*`));
64
+ const hostPage = path_1.default.join(pagesPath, `plasmic-host.${useTypescript ? "tsx" : "jsx"}`);
65
+ yield promises_1.default.writeFile(hostPage, nextjs_1.makeNextjsHostPage(scheme));
66
+ if (scheme === "loader") {
67
+ const initFile = path_1.default.join(projectPath, `plasmic-init.${useTypescript ? "ts" : "js"}`);
68
+ yield promises_1.default.writeFile(initFile, nextjs_1.makeNextjsInitPage(projectId, lang_utils_1.ensure(projectApiToken)));
69
+ // Write catch-all page for loader
70
+ const loaderPage = path_1.default.join(pagesPath, `[[...catchall]].${useTypescript ? "tsx" : "jsx"}`);
71
+ yield promises_1.default.writeFile(loaderPage, nextjs_1.makeNextjsCatchallPage(useTypescript ? "ts" : "js"));
72
+ }
73
+ else {
74
+ yield common_1.runCodegenSync({
75
+ projectId,
76
+ projectApiToken,
77
+ projectPath,
78
+ });
79
+ // Overwrite the index file
80
+ yield file_utils_1.overwriteIndex(projectPath, "nextjs", scheme);
81
+ // Overwrite the wrapper files to wrap PlasmicRootProvider
82
+ const appFilePath = path_1.default.join(projectPath, "pages", `_app.js`);
83
+ yield promises_1.default.writeFile(appFilePath, nextjs_1.wrapAppRootForCodegen());
84
+ }
47
85
  }),
48
86
  build: (args) => __awaiter(void 0, void 0, void 0, function* () {
49
87
  const { npmRunCmd, projectPath } = args;
@@ -10,7 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const cmd_utils_1 = require("../utils/cmd-utils");
13
+ const file_utils_1 = require("../utils/file-utils");
13
14
  const npm_utils_1 = require("../utils/npm-utils");
15
+ const common_1 = require("./common");
14
16
  const reactStrategy = {
15
17
  create: (args) => __awaiter(void 0, void 0, void 0, function* () {
16
18
  const { projectPath, useTypescript } = args;
@@ -22,17 +24,32 @@ const reactStrategy = {
22
24
  const templateArg = template ? ` --template ${template}` : "";
23
25
  yield cmd_utils_1.spawnOrFail(`${createCommand}${templateArg}`);
24
26
  }),
25
- configLoader: (args) => __awaiter(void 0, void 0, void 0, function* () {
26
- // this is unreachable for now, but should we have it ??
27
- const { projectPath } = args;
28
- const installResult = yield npm_utils_1.installUpgrade("@plasmicapp/loader-react", {
29
- workingDir: projectPath,
30
- });
31
- if (!installResult) {
32
- throw new Error("Failed to install the Plasmic dependency");
27
+ installDeps: ({ projectPath, scheme }) => __awaiter(void 0, void 0, void 0, function* () {
28
+ if (scheme === "loader") {
29
+ return yield npm_utils_1.installUpgrade("@plasmicapp/loader-react", {
30
+ workingDir: projectPath,
31
+ });
33
32
  }
33
+ else {
34
+ return yield common_1.installCodegenDeps({ projectPath });
35
+ }
36
+ }),
37
+ overwriteConfig: (args) => __awaiter(void 0, void 0, void 0, function* () {
38
+ // No config to overwrite
34
39
  }),
35
- overwriteFiles: () => __awaiter(void 0, void 0, void 0, function* () {
40
+ generateFiles: ({ scheme, projectApiToken, projectId, projectPath, }) => __awaiter(void 0, void 0, void 0, function* () {
41
+ if (scheme === "loader") {
42
+ // Nothing to do
43
+ }
44
+ else {
45
+ yield common_1.runCodegenSync({
46
+ projectId,
47
+ projectApiToken,
48
+ projectPath,
49
+ });
50
+ // Overwrite the index file
51
+ yield file_utils_1.overwriteIndex(projectPath, "react", scheme);
52
+ }
36
53
  return;
37
54
  }),
38
55
  build: (args) => __awaiter(void 0, void 0, void 0, function* () {
@@ -1,3 +1,4 @@
1
+ import { CodeScheme } from "..";
1
2
  interface CreateArgs {
2
3
  projectPath: string;
3
4
  template?: string;
@@ -6,20 +7,30 @@ interface CreateArgs {
6
7
  interface ConfigArgs {
7
8
  projectId: string;
8
9
  projectPath: string;
9
- projectApiToken: string;
10
10
  useTypescript: boolean;
11
+ scheme: CodeScheme;
12
+ projectApiToken: string | undefined;
11
13
  }
12
- interface OverwriteFilesArgs {
14
+ interface GenerateFilesArgs {
13
15
  projectPath: string;
16
+ useTypescript: boolean;
17
+ scheme: CodeScheme;
18
+ projectId: string;
19
+ projectApiToken: string | undefined;
14
20
  }
15
21
  interface BuildArgs {
16
22
  projectPath: string;
17
23
  npmRunCmd: string;
18
24
  }
25
+ interface InstallArgs {
26
+ scheme: CodeScheme;
27
+ projectPath: string;
28
+ }
19
29
  export interface CPAStrategy {
20
30
  create: (args: CreateArgs) => Promise<void>;
21
- configLoader: (args: ConfigArgs) => Promise<void>;
22
- overwriteFiles: (args: OverwriteFilesArgs) => Promise<void>;
31
+ installDeps: (args: InstallArgs) => Promise<boolean>;
32
+ overwriteConfig: (args: ConfigArgs) => Promise<void>;
33
+ generateFiles: (args: GenerateFilesArgs) => Promise<void>;
23
34
  build: (args: BuildArgs) => Promise<void>;
24
35
  }
25
36
  export {};
@@ -1,3 +1,11 @@
1
- export declare const GATSBY_DEFAULT_PAGE: string;
1
+ import { CodeScheme } from "..";
2
+ export declare const makeGatsbyDefaultPage: (format: "ts" | "js") => string;
2
3
  export declare const GATSBY_404: string;
3
- export declare const GATSBY_PLUGIN_CONFIG: (projectId: string, projectApiToken: string) => string;
4
+ export declare const GATSBY_PLUGIN_CONFIG: (projectId: string, projectApiToken: string, useTypescript: boolean) => string;
5
+ export declare const makeGatsbyHostPage: (opts: {
6
+ useTypescript: boolean;
7
+ scheme: CodeScheme;
8
+ }) => string;
9
+ export declare const GATSBY_SSR_CONFIG: string;
10
+ export declare const makeGatsbyPlasmicInit: (format: "ts" | "js") => string;
11
+ export declare function wrapAppRootForCodegen(): string;