create-tina-app 0.0.1 → 0.1.0
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/CHANGELOG.md +6 -0
- package/README.md +3 -0
- package/bin/create-tina-app +2 -2
- package/dist/examples.d.ts +27 -0
- package/dist/index.js +180 -43
- package/examples/basic/.tina/__generated__/_graphql.json +2304 -0
- package/examples/basic/.tina/__generated__/_lookup.json +56 -0
- package/examples/basic/.tina/__generated__/_schema.json +57 -0
- package/examples/basic/.tina/__generated__/config/schema.json +38 -0
- package/examples/basic/.tina/__generated__/schema.gql +159 -0
- package/examples/basic/.tina/__generated__/types.ts +285 -0
- package/examples/basic/.tina/schema.ts +40 -0
- package/examples/basic/README.md +24 -0
- package/examples/basic/components/Layout.js +28 -0
- package/examples/basic/content/page/home.mdx +2 -0
- package/examples/basic/content/post/HelloWorld.md +7 -0
- package/examples/basic/next.config.js +1 -0
- package/examples/basic/package.json +23 -0
- package/examples/basic/pages/_app.js +33 -0
- package/examples/basic/pages/admin/[[...slug]].js +3 -0
- package/examples/basic/pages/index.js +30 -0
- package/examples/basic/pages/posts/[slug].js +64 -0
- package/examples/basic/pages/posts/index.js +44 -0
- package/examples/basic/public/favicon.ico +0 -0
- package/examples/basic/public/vercel.svg +4 -0
- package/examples/tina-tailwind-sidebar-demo/.tina/PageTemplate.ts +427 -0
- package/examples/tina-tailwind-sidebar-demo/.tina/ThemeTemplate.ts +42 -0
- package/examples/tina-tailwind-sidebar-demo/.tina/__generated__/_graphql.json +4180 -0
- package/examples/tina-tailwind-sidebar-demo/.tina/__generated__/_lookup.json +68 -0
- package/examples/tina-tailwind-sidebar-demo/.tina/__generated__/_schema.json +851 -0
- package/examples/tina-tailwind-sidebar-demo/.tina/__generated__/config/schema.json +479 -0
- package/examples/tina-tailwind-sidebar-demo/.tina/__generated__/schema.gql +391 -0
- package/examples/tina-tailwind-sidebar-demo/.tina/__generated__/types.ts +520 -0
- package/examples/tina-tailwind-sidebar-demo/.tina/schema.ts +35 -0
- package/examples/tina-tailwind-sidebar-demo/CHANGELOG.md +95 -0
- package/examples/tina-tailwind-sidebar-demo/LICENSE +201 -0
- package/examples/tina-tailwind-sidebar-demo/README.md +10 -0
- package/examples/tina-tailwind-sidebar-demo/components/PageBlocks.tsx +25 -0
- package/examples/tina-tailwind-sidebar-demo/components/actions.js +114 -0
- package/examples/tina-tailwind-sidebar-demo/components/features.tsx +171 -0
- package/examples/tina-tailwind-sidebar-demo/components/footer.tsx +247 -0
- package/examples/tina-tailwind-sidebar-demo/components/hero.js +156 -0
- package/examples/tina-tailwind-sidebar-demo/components/icon.js +264 -0
- package/examples/tina-tailwind-sidebar-demo/components/modal.js +79 -0
- package/examples/tina-tailwind-sidebar-demo/components/nav.tsx +121 -0
- package/examples/tina-tailwind-sidebar-demo/components/section.js +53 -0
- package/examples/tina-tailwind-sidebar-demo/components/testimonial.tsx +87 -0
- package/examples/tina-tailwind-sidebar-demo/components/theme.tsx +81 -0
- package/examples/tina-tailwind-sidebar-demo/components/tina-wrapper.js +85 -0
- package/examples/tina-tailwind-sidebar-demo/content/data/homepage.json +186 -0
- package/examples/tina-tailwind-sidebar-demo/content/theme/NormalTheme.json +5 -0
- package/examples/tina-tailwind-sidebar-demo/graphql.config.js +24 -0
- package/examples/tina-tailwind-sidebar-demo/next-env.d.ts +15 -0
- package/examples/tina-tailwind-sidebar-demo/package.json +42 -0
- package/examples/tina-tailwind-sidebar-demo/pages/_app.js +48 -0
- package/examples/tina-tailwind-sidebar-demo/pages/admin.tsx +26 -0
- package/examples/tina-tailwind-sidebar-demo/pages/index.tsx +186 -0
- package/examples/tina-tailwind-sidebar-demo/postcss.config.js +19 -0
- package/examples/tina-tailwind-sidebar-demo/public/canal.jpg +0 -0
- package/examples/tina-tailwind-sidebar-demo/public/index.html +42 -0
- package/examples/tina-tailwind-sidebar-demo/styles.css +20 -0
- package/examples/tina-tailwind-sidebar-demo/tailwind.config.js +83 -0
- package/examples/tina-tailwind-sidebar-demo/tsconfig.json +19 -0
- package/package.json +7 -3
package/CHANGELOG.md
ADDED
package/README.md
ADDED
package/bin/create-tina-app
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Copyright 2021 Forestry.io Holdings, Inc.
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
See the License for the specific language governing permissions and
|
|
11
|
+
limitations under the License.
|
|
12
|
+
*/
|
|
13
|
+
declare type BaseExample = {
|
|
14
|
+
title: string;
|
|
15
|
+
value: string;
|
|
16
|
+
};
|
|
17
|
+
export declare type InternalExample = BaseExample & {
|
|
18
|
+
isInternal: true;
|
|
19
|
+
};
|
|
20
|
+
export declare type ExternalExample = BaseExample & {
|
|
21
|
+
isInternal: false;
|
|
22
|
+
gitURL: string;
|
|
23
|
+
};
|
|
24
|
+
export declare type Example = InternalExample | ExternalExample;
|
|
25
|
+
export declare const EXAMPLES: Example[];
|
|
26
|
+
export declare const downloadExample: (example: Example, root: string) => Promise<void>;
|
|
27
|
+
export {};
|
package/dist/index.js
CHANGED
|
@@ -28,37 +28,11 @@ __export(exports, {
|
|
|
28
28
|
});
|
|
29
29
|
var import_commander = __toModule(require("commander"));
|
|
30
30
|
var import_prompts = __toModule(require("prompts"));
|
|
31
|
-
var
|
|
31
|
+
var import_path4 = __toModule(require("path"));
|
|
32
32
|
|
|
33
33
|
// pnp:/home/runner/work/tinacms/tinacms/packages/create-tina-app/package.json
|
|
34
34
|
var name = "create-tina-app";
|
|
35
|
-
var version = "0.0
|
|
36
|
-
|
|
37
|
-
// pnp:/home/runner/work/tinacms/tinacms/packages/create-tina-app/src/util/examples.ts
|
|
38
|
-
var import_got = __toModule(require("got"));
|
|
39
|
-
var import_stream = __toModule(require("stream"));
|
|
40
|
-
var import_util = __toModule(require("util"));
|
|
41
|
-
var import_tar = __toModule(require("tar"));
|
|
42
|
-
var pipeline = (0, import_util.promisify)(import_stream.Stream.pipeline);
|
|
43
|
-
async function getRepoInfo(url, examplePath) {
|
|
44
|
-
const [, username, name2, t, _branch, ...file] = url.pathname.split("/");
|
|
45
|
-
const filePath = examplePath ? examplePath.replace(/^\//, "") : file.join("/");
|
|
46
|
-
if (t === void 0) {
|
|
47
|
-
const infoResponse = await (0, import_got.default)(`https://api.github.com/repos/${username}/${name2}`).catch((e) => e);
|
|
48
|
-
if (infoResponse.statusCode !== 200) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const info = JSON.parse(infoResponse.body);
|
|
52
|
-
return { username, name: name2, branch: info["default_branch"], filePath };
|
|
53
|
-
}
|
|
54
|
-
const branch = examplePath ? `${_branch}/${file.join("/")}`.replace(new RegExp(`/${filePath}|/$`), "") : _branch;
|
|
55
|
-
if (username && name2 && branch && t === "tree") {
|
|
56
|
-
return { username, name: name2, branch, filePath };
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
function downloadAndExtractRepo(root, { username, name: name2, branch, filePath }) {
|
|
60
|
-
return pipeline(import_got.default.stream(`https://codeload.github.com/${username}/${name2}/tar.gz/${branch}`), import_tar.default.extract({ cwd: root, strip: filePath ? filePath.split("/").length + 1 : 1 }, [`${name2}-${branch}${filePath ? `/${filePath}` : ""}`]));
|
|
61
|
-
}
|
|
35
|
+
var version = "0.1.0";
|
|
62
36
|
|
|
63
37
|
// pnp:/home/runner/work/tinacms/tinacms/packages/create-tina-app/src/util/fileUtil.ts
|
|
64
38
|
var import_fs = __toModule(require("fs"));
|
|
@@ -179,48 +153,211 @@ function install(root, dependencies, { useYarn, isOnline, devDependencies }) {
|
|
|
179
153
|
}
|
|
180
154
|
|
|
181
155
|
// pnp:/home/runner/work/tinacms/tinacms/packages/create-tina-app/src/index.ts
|
|
156
|
+
var import_chalk4 = __toModule(require("chalk"));
|
|
157
|
+
|
|
158
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/create-tina-app/src/util/git.ts
|
|
159
|
+
var import_child_process = __toModule(require("child_process"));
|
|
160
|
+
var import_path2 = __toModule(require("path"));
|
|
161
|
+
var import_rimraf = __toModule(require("rimraf"));
|
|
162
|
+
function isInGitRepository() {
|
|
163
|
+
try {
|
|
164
|
+
(0, import_child_process.execSync)("git rev-parse --is-inside-work-tree", { stdio: "ignore" });
|
|
165
|
+
return true;
|
|
166
|
+
} catch (_) {
|
|
167
|
+
}
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
function isInMercurialRepository() {
|
|
171
|
+
try {
|
|
172
|
+
(0, import_child_process.execSync)("hg --cwd . root", { stdio: "ignore" });
|
|
173
|
+
return true;
|
|
174
|
+
} catch (_) {
|
|
175
|
+
}
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
function tryGitInit(root) {
|
|
179
|
+
let didInit = false;
|
|
180
|
+
try {
|
|
181
|
+
(0, import_child_process.execSync)("git --version", { stdio: "ignore" });
|
|
182
|
+
if (isInGitRepository() || isInMercurialRepository()) {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
(0, import_child_process.execSync)("git init", { stdio: "ignore" });
|
|
186
|
+
didInit = true;
|
|
187
|
+
(0, import_child_process.execSync)("git checkout -b main", { stdio: "ignore" });
|
|
188
|
+
(0, import_child_process.execSync)("git add -A", { stdio: "ignore" });
|
|
189
|
+
(0, import_child_process.execSync)('git commit -m "Initial commit from Create Tina App"', {
|
|
190
|
+
stdio: "ignore"
|
|
191
|
+
});
|
|
192
|
+
return true;
|
|
193
|
+
} catch (e) {
|
|
194
|
+
if (didInit) {
|
|
195
|
+
try {
|
|
196
|
+
import_rimraf.default.sync(import_path2.default.join(root, ".git"));
|
|
197
|
+
} catch (_) {
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/create-tina-app/src/index.ts
|
|
205
|
+
var import_process = __toModule(require("process"));
|
|
206
|
+
|
|
207
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/create-tina-app/src/util/examples.ts
|
|
208
|
+
var import_got = __toModule(require("got"));
|
|
209
|
+
var import_stream = __toModule(require("stream"));
|
|
210
|
+
var import_util = __toModule(require("util"));
|
|
211
|
+
var import_tar = __toModule(require("tar"));
|
|
212
|
+
var pipeline = (0, import_util.promisify)(import_stream.Stream.pipeline);
|
|
213
|
+
async function getRepoInfo(url, examplePath) {
|
|
214
|
+
const [, username, name2, t, _branch, ...file] = url.pathname.split("/");
|
|
215
|
+
const filePath = examplePath ? examplePath.replace(/^\//, "") : file.join("/");
|
|
216
|
+
if (t === void 0) {
|
|
217
|
+
const infoResponse = await (0, import_got.default)(`https://api.github.com/repos/${username}/${name2}`).catch((e) => e);
|
|
218
|
+
if (infoResponse.statusCode !== 200) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
const info = JSON.parse(infoResponse.body);
|
|
222
|
+
return { username, name: name2, branch: info["default_branch"], filePath };
|
|
223
|
+
}
|
|
224
|
+
const branch = examplePath ? `${_branch}/${file.join("/")}`.replace(new RegExp(`/${filePath}|/$`), "") : _branch;
|
|
225
|
+
if (username && name2 && branch && t === "tree") {
|
|
226
|
+
return { username, name: name2, branch, filePath };
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
function downloadAndExtractRepo(root, { username, name: name2, branch, filePath }) {
|
|
230
|
+
return pipeline(import_got.default.stream(`https://codeload.github.com/${username}/${name2}/tar.gz/${branch}`), import_tar.default.extract({ cwd: root, strip: filePath ? filePath.split("/").length + 1 : 1 }, [`${name2}-${branch}${filePath ? `/${filePath}` : ""}`]));
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/create-tina-app/src/examples.ts
|
|
182
234
|
var import_chalk3 = __toModule(require("chalk"));
|
|
235
|
+
var import_fs_extra = __toModule(require("fs-extra"));
|
|
236
|
+
var import_path3 = __toModule(require("path"));
|
|
237
|
+
var EXAMPLES = [
|
|
238
|
+
{ title: "Basic", value: "basic", isInternal: true },
|
|
239
|
+
{
|
|
240
|
+
title: "Tailwind Starter",
|
|
241
|
+
value: "tina-cloud-starter",
|
|
242
|
+
isInternal: false,
|
|
243
|
+
gitURL: "https://github.com/tinacms/tina-cloud-starter"
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
title: "Documentation Starter",
|
|
247
|
+
value: "tina-docs-starter",
|
|
248
|
+
isInternal: false,
|
|
249
|
+
gitURL: "https://github.com/tinacms/tina-docs-starter"
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
title: "Tailwind Site Builder",
|
|
253
|
+
value: "tina-tailwind-sidebar-demo",
|
|
254
|
+
isInternal: true
|
|
255
|
+
}
|
|
256
|
+
];
|
|
257
|
+
var downloadExample = async (example, root) => {
|
|
258
|
+
if (example.isInternal === false) {
|
|
259
|
+
const repoURL = new URL(example.gitURL);
|
|
260
|
+
const repoInfo = await getRepoInfo(repoURL);
|
|
261
|
+
const repoInfo2 = repoInfo;
|
|
262
|
+
console.log(`Downloading files from repo ${import_chalk3.default.cyan(repoInfo.username + "/" + repoInfo.name)}. This might take a moment.`);
|
|
263
|
+
await downloadAndExtractRepo(root, repoInfo2);
|
|
264
|
+
} else {
|
|
265
|
+
const exampleFile = import_path3.default.join(__dirname, "..", "examples", example.value);
|
|
266
|
+
await (0, import_fs_extra.copy)(`${exampleFile}/`, "./");
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/create-tina-app/src/index.ts
|
|
183
271
|
var program = new import_commander.Command(name);
|
|
184
272
|
var projectName = "";
|
|
185
|
-
program.version(version).option("-e, --example <example>", "Choose which example to start from").arguments("[project-directory]").usage(`${
|
|
273
|
+
program.version(version).option("-e, --example <example>", "Choose which example to start from").option("-d, --dir <dir>", "Choose which directory to run this script from").arguments("[project-directory]").usage(`${import_chalk4.default.green("<project-directory>")} [options]`).action((name2) => {
|
|
186
274
|
projectName = name2;
|
|
187
275
|
});
|
|
188
276
|
var run = async () => {
|
|
189
277
|
program.parse(process.argv);
|
|
190
278
|
const opts = program.opts();
|
|
191
|
-
|
|
279
|
+
if (opts.dir) {
|
|
280
|
+
process.chdir(opts.dir);
|
|
281
|
+
}
|
|
282
|
+
let example = opts.example;
|
|
283
|
+
const res = await (0, import_prompts.default)({
|
|
284
|
+
message: "Which package manager would you like to use?",
|
|
285
|
+
name: "useYarn",
|
|
286
|
+
type: "select",
|
|
287
|
+
choices: [
|
|
288
|
+
{ title: "Yarn", value: "yarn" },
|
|
289
|
+
{ title: "NPM", value: "npm" }
|
|
290
|
+
]
|
|
291
|
+
});
|
|
292
|
+
const useYarn = res.useYarn === "yarn";
|
|
293
|
+
const displayedCommand = useYarn ? "yarn" : "npm";
|
|
192
294
|
if (!projectName) {
|
|
193
|
-
const
|
|
295
|
+
const res2 = await (0, import_prompts.default)({
|
|
194
296
|
name: "name",
|
|
195
297
|
type: "text",
|
|
196
298
|
message: "What is your project named?",
|
|
197
299
|
initial: "my-tina-app"
|
|
198
300
|
});
|
|
199
|
-
projectName =
|
|
301
|
+
projectName = res2.name;
|
|
200
302
|
}
|
|
201
303
|
const dirName = projectName;
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
304
|
+
let isInternalExample = false;
|
|
305
|
+
if (!example) {
|
|
306
|
+
const res2 = await (0, import_prompts.default)({
|
|
307
|
+
name: "example",
|
|
308
|
+
type: "select",
|
|
309
|
+
message: "What starter code would you like to use?",
|
|
310
|
+
choices: EXAMPLES
|
|
311
|
+
});
|
|
312
|
+
if (typeof res2.example !== "string") {
|
|
313
|
+
console.error(import_chalk4.default.red("Input must be a string"));
|
|
314
|
+
(0, import_process.exit)(1);
|
|
315
|
+
}
|
|
316
|
+
example = res2.example;
|
|
317
|
+
}
|
|
318
|
+
const chosenExample = EXAMPLES.find((x) => x.value === example);
|
|
319
|
+
if (!chosenExample) {
|
|
320
|
+
console.error(`The example provided is not a valid example. Please provide one of the following; ${EXAMPLES.map((x) => x.value)}`);
|
|
321
|
+
}
|
|
322
|
+
const root = import_path4.default.join(process.cwd(), dirName);
|
|
323
|
+
if (!await isWriteable(import_path4.default.dirname(root))) {
|
|
205
324
|
console.error("The application path is not writable, please check folder permissions and try again.");
|
|
206
325
|
console.error("It is likely you do not have write permissions for this folder.");
|
|
207
326
|
process.exit(1);
|
|
208
327
|
}
|
|
209
|
-
const appName =
|
|
328
|
+
const appName = import_path4.default.basename(root);
|
|
210
329
|
await makeDir(root);
|
|
330
|
+
process.chdir(root);
|
|
211
331
|
if (!isFolderEmpty(root, appName)) {
|
|
212
332
|
process.exit(1);
|
|
213
333
|
}
|
|
214
|
-
|
|
215
|
-
const repoInfo2 = repoInfo;
|
|
216
|
-
console.log(`Downloading files from repo ${import_chalk3.default.cyan(example)}. This might take a moment.`);
|
|
217
|
-
await downloadAndExtractRepo(root, repoInfo2);
|
|
334
|
+
await downloadExample(chosenExample, root);
|
|
218
335
|
console.log("Installing packages. This might take a couple of minutes.");
|
|
219
336
|
console.log();
|
|
220
|
-
await install(root, null, { useYarn
|
|
337
|
+
await install(root, null, { useYarn, isOnline: true });
|
|
338
|
+
console.log(import_chalk4.default.green("Finished installing all packages"));
|
|
339
|
+
console.log();
|
|
340
|
+
if (tryGitInit(root)) {
|
|
341
|
+
console.log("Initialized a git repository.");
|
|
342
|
+
console.log();
|
|
343
|
+
}
|
|
344
|
+
console.log(`${import_chalk4.default.green("Success!")} Created ${appName} at ${root}`);
|
|
345
|
+
console.log("Inside that directory, you can run several commands:");
|
|
346
|
+
console.log();
|
|
347
|
+
console.log(import_chalk4.default.cyan(` ${displayedCommand} ${useYarn ? "" : "run "}dev`));
|
|
348
|
+
console.log(" Starts the development server.");
|
|
349
|
+
console.log();
|
|
350
|
+
console.log(import_chalk4.default.cyan(` ${displayedCommand} ${useYarn ? "" : "run "}build`));
|
|
351
|
+
console.log(" Builds the app for production.");
|
|
352
|
+
console.log();
|
|
353
|
+
console.log(import_chalk4.default.cyan(` ${displayedCommand} start`));
|
|
354
|
+
console.log(" Runs the built app in production mode.");
|
|
355
|
+
console.log();
|
|
356
|
+
console.log("We suggest that you begin by typing:");
|
|
357
|
+
console.log();
|
|
358
|
+
console.log(import_chalk4.default.cyan(" cd"), appName);
|
|
359
|
+
console.log(` ${import_chalk4.default.cyan(`${displayedCommand} ${useYarn ? "" : "run "}dev`)}`);
|
|
221
360
|
console.log();
|
|
222
|
-
console.log({ repoInfo });
|
|
223
|
-
console.log({ opts });
|
|
224
361
|
};
|
|
225
362
|
run();
|
|
226
363
|
// Annotate the CommonJS export names for ESM import in node:
|