create-tina-app 0.0.1 → 0.1.3
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 +26 -0
- package/README.md +3 -0
- package/bin/create-tina-app +2 -2
- package/dist/examples.d.ts +27 -0
- package/dist/index.js +186 -43
- 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
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# create-tina-app
|
|
2
|
+
|
|
3
|
+
## 0.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d0ac25b73: Update link for bare bones starter
|
|
8
|
+
|
|
9
|
+
## 0.1.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 371fc73dd: remove tailwind site builder from list of starters
|
|
14
|
+
|
|
15
|
+
## 0.1.1
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 127b0ae5d: Use the github URL instead of the local copy
|
|
20
|
+
- 10a36f3a0: Fix issue where startup time was very slow
|
|
21
|
+
|
|
22
|
+
## 0.1.0
|
|
23
|
+
|
|
24
|
+
### Minor Changes
|
|
25
|
+
|
|
26
|
+
- e792dd0fd: Added basic Create Tina App
|
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.
|
|
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.3";
|
|
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,217 @@ 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_chalk5 = __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
|
+
var import_fs_extra = __toModule(require("fs-extra"));
|
|
182
163
|
var import_chalk3 = __toModule(require("chalk"));
|
|
164
|
+
function isInGitRepository() {
|
|
165
|
+
try {
|
|
166
|
+
(0, import_child_process.execSync)("git rev-parse --is-inside-work-tree", { stdio: "ignore" });
|
|
167
|
+
return true;
|
|
168
|
+
} catch (_) {
|
|
169
|
+
}
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
function isInMercurialRepository() {
|
|
173
|
+
try {
|
|
174
|
+
(0, import_child_process.execSync)("hg --cwd . root", { stdio: "ignore" });
|
|
175
|
+
return true;
|
|
176
|
+
} catch (_) {
|
|
177
|
+
}
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
function tryGitInit(root) {
|
|
181
|
+
let didInit = false;
|
|
182
|
+
try {
|
|
183
|
+
(0, import_child_process.execSync)("git --version", { stdio: "ignore" });
|
|
184
|
+
if (isInGitRepository() || isInMercurialRepository()) {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
if (!import_fs_extra.default.existsSync(".gitignore")) {
|
|
188
|
+
console.warn(import_chalk3.default.yellow("There is no .gitignore file in this repository, creating one..."));
|
|
189
|
+
import_fs_extra.default.writeFileSync(".gitignore", `node_modules
|
|
190
|
+
.yarn/*
|
|
191
|
+
.DS_Store
|
|
192
|
+
.cache
|
|
193
|
+
.next/
|
|
194
|
+
`);
|
|
195
|
+
}
|
|
196
|
+
(0, import_child_process.execSync)("git init", { stdio: "ignore" });
|
|
197
|
+
didInit = true;
|
|
198
|
+
(0, import_child_process.execSync)("git checkout -b main", { stdio: "ignore" });
|
|
199
|
+
(0, import_child_process.execSync)("git add -A", { stdio: "ignore" });
|
|
200
|
+
(0, import_child_process.execSync)('git commit -m "Initial commit from Create Tina App"', {
|
|
201
|
+
stdio: "ignore"
|
|
202
|
+
});
|
|
203
|
+
return true;
|
|
204
|
+
} catch (e) {
|
|
205
|
+
if (didInit) {
|
|
206
|
+
try {
|
|
207
|
+
import_rimraf.default.sync(import_path2.default.join(root, ".git"));
|
|
208
|
+
} catch (_) {
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/create-tina-app/src/index.ts
|
|
216
|
+
var import_process = __toModule(require("process"));
|
|
217
|
+
|
|
218
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/create-tina-app/src/util/examples.ts
|
|
219
|
+
var import_got = __toModule(require("got"));
|
|
220
|
+
var import_stream = __toModule(require("stream"));
|
|
221
|
+
var import_util = __toModule(require("util"));
|
|
222
|
+
var import_tar = __toModule(require("tar"));
|
|
223
|
+
var pipeline = (0, import_util.promisify)(import_stream.Stream.pipeline);
|
|
224
|
+
async function getRepoInfo(url, examplePath) {
|
|
225
|
+
const [, username, name2, t, _branch, ...file] = url.pathname.split("/");
|
|
226
|
+
const filePath = examplePath ? examplePath.replace(/^\//, "") : file.join("/");
|
|
227
|
+
if (t === void 0) {
|
|
228
|
+
const infoResponse = await (0, import_got.default)(`https://api.github.com/repos/${username}/${name2}`).catch((e) => e);
|
|
229
|
+
if (infoResponse.statusCode !== 200) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
const info = JSON.parse(infoResponse.body);
|
|
233
|
+
return { username, name: name2, branch: info["default_branch"], filePath };
|
|
234
|
+
}
|
|
235
|
+
const branch = examplePath ? `${_branch}/${file.join("/")}`.replace(new RegExp(`/${filePath}|/$`), "") : _branch;
|
|
236
|
+
if (username && name2 && branch && t === "tree") {
|
|
237
|
+
return { username, name: name2, branch, filePath };
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function downloadAndExtractRepo(root, { username, name: name2, branch, filePath }) {
|
|
241
|
+
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}` : ""}`]));
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/create-tina-app/src/examples.ts
|
|
245
|
+
var import_chalk4 = __toModule(require("chalk"));
|
|
246
|
+
var import_fs_extra2 = __toModule(require("fs-extra"));
|
|
247
|
+
var import_path3 = __toModule(require("path"));
|
|
248
|
+
var EXAMPLES = [
|
|
249
|
+
{
|
|
250
|
+
title: "Bare bones starter",
|
|
251
|
+
value: "basic",
|
|
252
|
+
isInternal: false,
|
|
253
|
+
gitURL: "https://github.com/tinacms/tina-barebones-starter"
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
title: "Tailwind Starter",
|
|
257
|
+
value: "tina-cloud-starter",
|
|
258
|
+
isInternal: false,
|
|
259
|
+
gitURL: "https://github.com/tinacms/tina-cloud-starter"
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
title: "Documentation Starter",
|
|
263
|
+
value: "tina-docs-starter",
|
|
264
|
+
isInternal: false,
|
|
265
|
+
gitURL: "https://github.com/tinacms/tina-docs-starter"
|
|
266
|
+
}
|
|
267
|
+
];
|
|
268
|
+
var downloadExample = async (example, root) => {
|
|
269
|
+
if (example.isInternal === false) {
|
|
270
|
+
const repoURL = new URL(example.gitURL);
|
|
271
|
+
const repoInfo = await getRepoInfo(repoURL);
|
|
272
|
+
const repoInfo2 = repoInfo;
|
|
273
|
+
console.log(`Downloading files from repo ${import_chalk4.default.cyan(repoInfo.username + "/" + repoInfo.name)}. This might take a moment.`);
|
|
274
|
+
await downloadAndExtractRepo(root, repoInfo2);
|
|
275
|
+
} else {
|
|
276
|
+
const exampleFile = import_path3.default.join(__dirname, "..", "examples", example.value);
|
|
277
|
+
await (0, import_fs_extra2.copy)(`${exampleFile}/`, "./");
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/create-tina-app/src/index.ts
|
|
183
282
|
var program = new import_commander.Command(name);
|
|
184
283
|
var projectName = "";
|
|
185
|
-
program.version(version).option("-e, --example <example>", "Choose which example to start from").arguments("[project-directory]").usage(`${
|
|
284
|
+
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_chalk5.default.green("<project-directory>")} [options]`).action((name2) => {
|
|
186
285
|
projectName = name2;
|
|
187
286
|
});
|
|
188
287
|
var run = async () => {
|
|
189
288
|
program.parse(process.argv);
|
|
190
289
|
const opts = program.opts();
|
|
191
|
-
|
|
290
|
+
if (opts.dir) {
|
|
291
|
+
process.chdir(opts.dir);
|
|
292
|
+
}
|
|
293
|
+
let example = opts.example;
|
|
294
|
+
const res = await (0, import_prompts.default)({
|
|
295
|
+
message: "Which package manager would you like to use?",
|
|
296
|
+
name: "useYarn",
|
|
297
|
+
type: "select",
|
|
298
|
+
choices: [
|
|
299
|
+
{ title: "Yarn", value: "yarn" },
|
|
300
|
+
{ title: "NPM", value: "npm" }
|
|
301
|
+
]
|
|
302
|
+
});
|
|
303
|
+
const useYarn = res.useYarn === "yarn";
|
|
304
|
+
const displayedCommand = useYarn ? "yarn" : "npm";
|
|
192
305
|
if (!projectName) {
|
|
193
|
-
const
|
|
306
|
+
const res2 = await (0, import_prompts.default)({
|
|
194
307
|
name: "name",
|
|
195
308
|
type: "text",
|
|
196
309
|
message: "What is your project named?",
|
|
197
310
|
initial: "my-tina-app"
|
|
198
311
|
});
|
|
199
|
-
projectName =
|
|
312
|
+
projectName = res2.name;
|
|
200
313
|
}
|
|
201
314
|
const dirName = projectName;
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
315
|
+
if (!example) {
|
|
316
|
+
const res2 = await (0, import_prompts.default)({
|
|
317
|
+
name: "example",
|
|
318
|
+
type: "select",
|
|
319
|
+
message: "What starter code would you like to use?",
|
|
320
|
+
choices: EXAMPLES
|
|
321
|
+
});
|
|
322
|
+
if (typeof res2.example !== "string") {
|
|
323
|
+
console.error(import_chalk5.default.red("Input must be a string"));
|
|
324
|
+
(0, import_process.exit)(1);
|
|
325
|
+
}
|
|
326
|
+
example = res2.example;
|
|
327
|
+
}
|
|
328
|
+
const chosenExample = EXAMPLES.find((x) => x.value === example);
|
|
329
|
+
if (!chosenExample) {
|
|
330
|
+
console.error(`The example provided is not a valid example. Please provide one of the following; ${EXAMPLES.map((x) => x.value)}`);
|
|
331
|
+
}
|
|
332
|
+
const root = import_path4.default.join(process.cwd(), dirName);
|
|
333
|
+
if (!await isWriteable(import_path4.default.dirname(root))) {
|
|
205
334
|
console.error("The application path is not writable, please check folder permissions and try again.");
|
|
206
335
|
console.error("It is likely you do not have write permissions for this folder.");
|
|
207
336
|
process.exit(1);
|
|
208
337
|
}
|
|
209
|
-
const appName =
|
|
338
|
+
const appName = import_path4.default.basename(root);
|
|
210
339
|
await makeDir(root);
|
|
340
|
+
process.chdir(root);
|
|
211
341
|
if (!isFolderEmpty(root, appName)) {
|
|
212
342
|
process.exit(1);
|
|
213
343
|
}
|
|
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);
|
|
344
|
+
await downloadExample(chosenExample, root);
|
|
218
345
|
console.log("Installing packages. This might take a couple of minutes.");
|
|
219
346
|
console.log();
|
|
220
|
-
await install(root, null, { useYarn
|
|
347
|
+
await install(root, null, { useYarn, isOnline: true });
|
|
348
|
+
console.log(import_chalk5.default.green("Finished installing all packages"));
|
|
349
|
+
console.log();
|
|
350
|
+
if (tryGitInit(root)) {
|
|
351
|
+
console.log("Initialized a git repository.");
|
|
352
|
+
console.log();
|
|
353
|
+
}
|
|
354
|
+
console.log(`${import_chalk5.default.green("Success!")} Created ${appName} at ${root}`);
|
|
355
|
+
console.log(import_chalk5.default.bold(" To launch your app, run:"));
|
|
356
|
+
console.log();
|
|
357
|
+
console.log(import_chalk5.default.cyan(" cd"), appName);
|
|
358
|
+
console.log(` ${import_chalk5.default.cyan(`${displayedCommand} ${useYarn ? "" : "run "}dev`)}`);
|
|
359
|
+
console.log();
|
|
360
|
+
console.log(import_chalk5.default.bold(" Next steps:"));
|
|
221
361
|
console.log();
|
|
222
|
-
console.log(
|
|
223
|
-
console.log(
|
|
362
|
+
console.log("- Go to http://localhost:3000/admin to enter edit-mode");
|
|
363
|
+
console.log("- Edit some content on http://localhost:3000 (See https://tina.io/using-tina-editor )");
|
|
364
|
+
console.log("- Check out our concept docs, to learn how Tina powers the starters under the hood. (See https://tina.io/docs/schema/)");
|
|
365
|
+
console.log("- Learn how Tina can be extended to create new field components. (See https://tina.io/docs/advanced/extending-tina/) ");
|
|
366
|
+
console.log("- Make your site editable with Tina on production. (See https://tina.io/docs/tina-cloud/ ");
|
|
224
367
|
};
|
|
225
368
|
run();
|
|
226
369
|
// Annotate the CommonJS export names for ESM import in node:
|