@tinacms/cli 0.60.6 → 0.60.9

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 CHANGED
@@ -1,5 +1,31 @@
1
1
  # tinacms-cli
2
2
 
3
+ ## 0.60.9
4
+
5
+ ### Patch Changes
6
+
7
+ - 048538625: fix: return cms on cmsCallback codegen (to fix broken typing)
8
+ - Updated dependencies [e7b27ba3b]
9
+ - Updated dependencies [11d55f441]
10
+ - @tinacms/graphql@0.59.8
11
+
12
+ ## 0.60.8
13
+
14
+ ### Patch Changes
15
+
16
+ - 919f5cb6c: use standard next script names
17
+
18
+ ## 0.60.7
19
+
20
+ ### Patch Changes
21
+
22
+ - 9e436f145: Update CLI to use defineConfig
23
+ - 851e4be73: Update tina init to use the new way of laying out tina config
24
+ - cc99e4309: update admin file path to /pages/admin.js to support the hash router
25
+ - @tinacms/datalayer@0.0.2
26
+ - @tinacms/graphql@0.59.7
27
+ - @tinacms/metrics@0.0.2
28
+
3
29
  ## 0.60.6
4
30
 
5
31
  ### Patch Changes
@@ -10,4 +10,4 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  See the License for the specific language governing permissions and
11
11
  limitations under the License.
12
12
  */
13
- export declare const defaultSchema = "\nimport { defineSchema } from \"@tinacms/cli\";\n\nexport default defineSchema({\n collections: [\n {\n label: \"Blog Posts\",\n name: \"posts\",\n path: \"content/posts\",\n fields: [\n {\n type: \"string\",\n label: \"Title\",\n name: \"title\",\n },\n {\n type: \"string\",\n label: \"Blog Post Body\",\n name: \"body\",\n isBody: true,\n ui: {\n component: \"textarea\"\n },\n },\n ],\n },\n ],\n});\n";
13
+ export declare const defaultSchema = "\nimport { defineSchema, defineConfig } from \"tinacms\";\n\nexport default defineSchema({\n collections: [\n {\n label: \"Blog Posts\",\n name: \"posts\",\n path: \"content/posts\",\n fields: [\n {\n type: \"string\",\n label: \"Title\",\n name: \"title\",\n },\n {\n type: \"string\",\n label: \"Blog Post Body\",\n name: \"body\",\n isBody: true,\n ui: {\n component: \"textarea\"\n },\n },\n ],\n },\n ],\n});\n\n\n\n\n// Your tina config\n// ==============\nconst branch = 'main'\n// When working locally, hit our local filesystem.\n// On a Vercel deployment, hit the Tina Cloud API\nconst apiURL =\n process.env.NODE_ENV == 'development'\n ? 'http://localhost:4001/graphql'\n : `https://content.tinajs.io/content/${process.env.NEXT_PUBLIC_TINA_CLIENT_ID}/github/${branch}`\n\nexport const tinaConfig = defineConfig({\n apiURL,\n cmsCallback: (cms) => {\n // add your CMS callback code here (if you want)\n\n // The Route Mapper\n /**\n * 1. Import `tinacms` and `RouteMappingPlugin`\n **/\n import(\"tinacms\").then(({ RouteMappingPlugin }) => {\n /**\n * 2. Define the `RouteMappingPlugin` see https://tina.io/docs/tinacms-context/#the-routemappingplugin for more details\n **/\n const RouteMapping = new RouteMappingPlugin((collection, document) => {\n return undefined;\n });\n /**\n * 3. Add the `RouteMappingPlugin` to the `cms`.\n **/\n cms.plugins.add(RouteMapping);\n });\n\n return cms;\n },\n});\n";
@@ -1,4 +1,4 @@
1
1
  export declare function initTina(ctx: any, next: () => void, options: any): Promise<void>;
2
2
  export declare function installDeps(ctx: any, next: () => void, options: any): Promise<void>;
3
- export declare function tinaSetup(ctx: any, next: () => void, options: any): Promise<void>;
3
+ export declare function tinaSetup(_ctx: any, next: () => void, _options: any): Promise<void>;
4
4
  export declare function successMessage(ctx: any, next: () => void, options: any): Promise<void>;
@@ -13,4 +13,4 @@ limitations under the License.
13
13
  export declare const adminPage = "import { TinaAdmin } from 'tinacms';\nexport default TinaAdmin;\n";
14
14
  export declare const blogPost = "---\ntitle: Vote For Pedro\n---\n# Welcome to the blog.\n\n> To edit this site head over to the [`/admin`](/admin) route. Then click the pencil icon in the bottom lefthand corner to start editing \uD83E\uDD99. \n\n# Dixi gaude Arethusa\n\n## Oscula mihi\n\nLorem markdownum numerabilis armentorum platanus, cultros coniunx sibi per\nsilvas, nostris clausit sequemur diverso scopulosque. Fecit tum alta sed non\nfalcato murmura, geminas donata Amyntore, quoque Nox. Invitam inquit, modo\nnocte; ut ignis faciemque manes in imagine sinistra ut mucrone non ramos\nsepulcro supplex. Crescentesque populos motura, fit cumque. Verumque est; retro\nsibi tristia bracchia Aetola telae caruerunt et.\n\n\n## Mutato fefellimus sit demisit aut alterius sollicito\n\nPhaethonteos vestes quem involvite iuvenca; furiali anne: sati totumque,\n**corpora** cum rapacibus nunc! Nervis repetatne, miserabile doleas, deprensum\nhunc, fluctus Threicio, ad urbes, magicaeque, quid. Per credensque series adicis\npoteram [quidem](#)! Iam uni mensas victrix\nvittas ut flumina Satyri adulter; bellum iacet domitae repercusso truncis urnis\nmille rigidi sub taurum.\n\n\n";
15
15
  export declare const nextPostPage: () => string;
16
- export declare const AppJsContent: (extraImports?: string) => string;
16
+ export declare const AppJsContent: (usingSrc: boolean, extraImports?: string) => string;
@@ -0,0 +1,14 @@
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
+ export declare const TinaProvider = "import TinaCMS from 'tinacms'\nimport { tinaConfig } from '../schema.ts'\n\n// Importing the TinaProvider directly into your page will cause Tina to be added to the production bundle.\n// Instead, import the tina/provider/index default export to have it dynamially imported in edit-moode\n/**\n *\n * @private Do not import this directly, please import the dynamic provider instead\n */\nconst TinaProvider = ({ children }) => {\n return <TinaCMS {...tinaConfig}>{children}</TinaCMS>\n}\n\nexport default TinaProvider\n";
14
+ export declare const TinaProviderDynamic = "import dynamic from 'next/dynamic'\nconst TinaProvider = dynamic(() => import('./TinaProvider'), { ssr: false })\nimport { TinaEditProvider } from 'tinacms/dist/edit-state'\n\nconst DynamicTina = ({ children }) => {\n return (\n <>\n <TinaEditProvider editMode={<TinaProvider>{children}</TinaProvider>}>\n {children}\n </TinaEditProvider>\n </>\n )\n}\n\nexport default DynamicTina\n";
package/dist/index.js CHANGED
@@ -114,7 +114,7 @@ var commander = __toModule(require("commander"));
114
114
 
115
115
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/package.json
116
116
  var name = "@tinacms/cli";
117
- var version = "0.60.6";
117
+ var version = "0.60.9";
118
118
 
119
119
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/utils/theme.ts
120
120
  var import_chalk = __toModule(require("chalk"));
@@ -402,7 +402,7 @@ var import_esbuild = __toModule(require("esbuild"));
402
402
 
403
403
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/compile/defaultSchema.ts
404
404
  var defaultSchema = `
405
- import { defineSchema } from "@tinacms/cli";
405
+ import { defineSchema, defineConfig } from "tinacms";
406
406
 
407
407
  export default defineSchema({
408
408
  collections: [
@@ -429,6 +429,45 @@ export default defineSchema({
429
429
  },
430
430
  ],
431
431
  });
432
+
433
+
434
+
435
+
436
+ // Your tina config
437
+ // ==============
438
+ const branch = 'main'
439
+ // When working locally, hit our local filesystem.
440
+ // On a Vercel deployment, hit the Tina Cloud API
441
+ const apiURL =
442
+ process.env.NODE_ENV == 'development'
443
+ ? 'http://localhost:4001/graphql'
444
+ : \`https://content.tinajs.io/content/\${process.env.NEXT_PUBLIC_TINA_CLIENT_ID}/github/\${branch}\`
445
+
446
+ export const tinaConfig = defineConfig({
447
+ apiURL,
448
+ cmsCallback: (cms) => {
449
+ // add your CMS callback code here (if you want)
450
+
451
+ // The Route Mapper
452
+ /**
453
+ * 1. Import \`tinacms\` and \`RouteMappingPlugin\`
454
+ **/
455
+ import("tinacms").then(({ RouteMappingPlugin }) => {
456
+ /**
457
+ * 2. Define the \`RouteMappingPlugin\` see https://tina.io/docs/tinacms-context/#the-routemappingplugin for more details
458
+ **/
459
+ const RouteMapping = new RouteMappingPlugin((collection, document) => {
460
+ return undefined;
461
+ });
462
+ /**
463
+ * 3. Add the \`RouteMappingPlugin\` to the \`cms\`.
464
+ **/
465
+ cms.plugins.add(RouteMapping);
466
+ });
467
+
468
+ return cms;
469
+ },
470
+ });
432
471
  `;
433
472
 
434
473
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/lib/getSchemaPath.ts
@@ -1098,41 +1137,70 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
1098
1137
  };
1099
1138
 
1100
1139
  `;
1101
- var AppJsContent = (extraImports) => `import dynamic from 'next/dynamic'
1102
- import { TinaEditProvider } from 'tinacms/dist/edit-state'
1103
- const TinaCMS = dynamic(() => import('tinacms'), { ssr: false })
1140
+ var AppJsContent = (usingSrc, extraImports) => `import Tina from '${usingSrc ? "../" : ""}../.tina/components/TinaDynamicProvider.js'
1141
+
1104
1142
  ${extraImports || ""}
1143
+ const App = ({ Component, pageProps }) => {
1144
+ return (
1145
+ <Tina>
1146
+ <Component {...pageProps} />
1147
+ </Tina>
1148
+ )
1149
+ }
1105
1150
 
1106
- const branch = process.env.NEXT_PUBLIC_EDIT_BRANCH || "main";
1107
- const apiURL =
1108
- process.env.NODE_ENV == "development"
1109
- ? "http://localhost:4001/graphql"
1110
- : \`https://content.tinajs.io/content/\${process.env.NEXT_PUBLIC_TINA_CLIENT_ID}/github/\${branch}\`;
1151
+ export default App
1111
1152
 
1112
- const App = ({ Component, pageProps }) => {
1153
+ `;
1154
+
1155
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/init/index.ts
1156
+ var import_chalk2 = __toModule(require("chalk"));
1157
+
1158
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/init/setup-files/tinaProvider.ts
1159
+ var TinaProvider = `import TinaCMS from 'tinacms'
1160
+ import { tinaConfig } from '../schema.ts'
1161
+
1162
+ // Importing the TinaProvider directly into your page will cause Tina to be added to the production bundle.
1163
+ // Instead, import the tina/provider/index default export to have it dynamially imported in edit-moode
1164
+ /**
1165
+ *
1166
+ * @private Do not import this directly, please import the dynamic provider instead
1167
+ */
1168
+ const TinaProvider = ({ children }) => {
1169
+ return <TinaCMS {...tinaConfig}>{children}</TinaCMS>
1170
+ }
1171
+
1172
+ export default TinaProvider
1173
+ `;
1174
+ var TinaProviderDynamic = `import dynamic from 'next/dynamic'
1175
+ const TinaProvider = dynamic(() => import('./TinaProvider'), { ssr: false })
1176
+ import { TinaEditProvider } from 'tinacms/dist/edit-state'
1177
+
1178
+ const DynamicTina = ({ children }) => {
1113
1179
  return (
1114
1180
  <>
1115
- <TinaEditProvider
1116
- editMode={
1117
- <TinaCMS
1118
- apiURL={apiURL}
1119
-
1120
- >
1121
- <Component {...pageProps} />
1122
- </TinaCMS>
1123
- }
1124
- >
1125
- <Component {...pageProps} />
1181
+ <TinaEditProvider editMode={<TinaProvider>{children}</TinaProvider>}>
1182
+ {children}
1126
1183
  </TinaEditProvider>
1127
1184
  </>
1128
1185
  )
1129
1186
  }
1130
1187
 
1131
- export default App
1188
+ export default DynamicTina
1132
1189
  `;
1133
1190
 
1191
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/utils/script-helpers.ts
1192
+ function generateGqlScript(scriptValue) {
1193
+ return `tinacms server:start -c "${scriptValue}"`;
1194
+ }
1195
+ function extendNextScripts(scripts) {
1196
+ return __spreadProps(__spreadValues({}, scripts), {
1197
+ dev: generateGqlScript(scripts.dev || "next dev"),
1198
+ build: generateGqlScript(scripts.build || "next build"),
1199
+ start: generateGqlScript(scripts.start || "next start")
1200
+ });
1201
+ }
1202
+
1134
1203
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/init/index.ts
1135
- var import_chalk2 = __toModule(require("chalk"));
1136
1204
  function execShellCommand(cmd) {
1137
1205
  const exec = require("child_process").exec;
1138
1206
  return new Promise((resolve2, _reject) => {
@@ -1165,26 +1233,32 @@ async function installDeps(ctx, next, options) {
1165
1233
  next();
1166
1234
  }
1167
1235
  var baseDir = process.cwd();
1168
- var TinaWrapperPathDir = import_path5.default.join(baseDir, "components");
1169
- var TinaWrapperPath = import_path5.default.join(TinaWrapperPathDir, "tina-wrapper.tsx");
1170
1236
  var blogContentPath = import_path5.default.join(baseDir, "content", "posts");
1171
1237
  var blogPostPath = import_path5.default.join(blogContentPath, "HelloWorld.md");
1172
- async function tinaSetup(ctx, next, options) {
1238
+ var TinaFolder = import_path5.default.join(baseDir, ".tina");
1239
+ var componentFolder = import_path5.default.join(TinaFolder, "components");
1240
+ var TinaProviderPath = import_path5.default.join(componentFolder, "TinaProvider.js");
1241
+ var TinaDynamicProvider = import_path5.default.join(componentFolder, "TinaDynamicProvider.js");
1242
+ async function tinaSetup(_ctx, next, _options) {
1173
1243
  const useingSrc = import_fs_extra4.default.pathExistsSync(import_path5.default.join(baseDir, "src"));
1174
1244
  if (!import_fs_extra4.default.pathExistsSync(blogPostPath)) {
1175
1245
  logger.info(logText("Adding a content folder..."));
1176
1246
  import_fs_extra4.default.mkdirpSync(blogContentPath);
1177
1247
  import_fs_extra4.default.writeFileSync(blogPostPath, blogPost);
1178
1248
  }
1249
+ if (!import_fs_extra4.default.existsSync(TinaProviderPath) && !import_fs_extra4.default.existsSync(TinaDynamicProvider)) {
1250
+ import_fs_extra4.default.mkdirpSync(componentFolder);
1251
+ import_fs_extra4.default.writeFileSync(TinaProviderPath, TinaProvider);
1252
+ import_fs_extra4.default.writeFileSync(TinaDynamicProvider, TinaProviderDynamic);
1253
+ }
1179
1254
  logger.level = "info";
1180
1255
  const pagesPath = import_path5.default.join(baseDir, useingSrc ? "src" : "", "pages");
1181
1256
  const appPath = import_path5.default.join(pagesPath, "_app.js");
1182
1257
  const appPathTS = import_path5.default.join(pagesPath, "_app.tsx");
1183
1258
  const appExtension = import_fs_extra4.default.existsSync(appPath) ? ".js" : ".tsx";
1184
- let wrapper = false;
1185
1259
  if (!import_fs_extra4.default.pathExistsSync(appPath) && !import_fs_extra4.default.pathExistsSync(appPathTS)) {
1186
1260
  logger.info(logText("Adding _app.js ... \u2705"));
1187
- import_fs_extra4.default.writeFileSync(appPath, AppJsContent());
1261
+ import_fs_extra4.default.writeFileSync(appPath, AppJsContent(useingSrc));
1188
1262
  } else {
1189
1263
  const override = await (0, import_prompts.default)({
1190
1264
  name: "res",
@@ -1199,11 +1273,10 @@ async function tinaSetup(ctx, next, options) {
1199
1273
  ...fileContent.toString().matchAll(/^.*import.*\.css("|').*$/gm)
1200
1274
  ];
1201
1275
  const primaryMatches = matches.map((x) => x[0]);
1202
- import_fs_extra4.default.writeFileSync(appPathWithExtension, AppJsContent(primaryMatches.join("\n")));
1276
+ import_fs_extra4.default.writeFileSync(appPathWithExtension, AppJsContent(useingSrc, primaryMatches.join("\n")));
1203
1277
  } else {
1204
- wrapper = true;
1205
1278
  logger.info(dangerText(`Heads up, to enable live-editing you'll need to wrap your page or site in Tina:
1206
- `, warnText(AppJsContent())));
1279
+ `, warnText(AppJsContent(useingSrc))));
1207
1280
  }
1208
1281
  }
1209
1282
  const tinaBlogPagePath = import_path5.default.join(pagesPath, "demo", "blog");
@@ -1217,16 +1290,12 @@ async function tinaSetup(ctx, next, options) {
1217
1290
  const pack = JSON.parse((0, import_fs_extra4.readFileSync)(packagePath).toString());
1218
1291
  const oldScripts = pack.scripts || {};
1219
1292
  const newPack = JSON.stringify(__spreadProps(__spreadValues({}, pack), {
1220
- scripts: __spreadProps(__spreadValues({}, oldScripts), {
1221
- "tina-dev": 'yarn tinacms server:start -c "next dev"',
1222
- "tina-build": 'yarn tinacms server:start -c "next build"',
1223
- "tina-start": 'yarn tinacms server:start -c "next start"'
1224
- })
1293
+ scripts: extendNextScripts(oldScripts)
1225
1294
  }), null, 2);
1226
1295
  (0, import_fs_extra4.writeFileSync)(packagePath, newPack);
1227
- const adminPath = import_path5.default.join(pagesPath, "admin", "[[...tina]].js");
1296
+ const adminPath = import_path5.default.join(pagesPath, "admin.js");
1228
1297
  if (import_fs_extra4.default.pathExistsSync(import_path5.default.join(pagesPath, "admin"))) {
1229
- logger.warn(`Unable to add /pages/admin/[[...tina]].js, this path already exists.
1298
+ logger.warn(`Unable to add /pages/admin.js, this path already exists.
1230
1299
  Learn more about toggling edit-mode at https://tina.io/docs/tinacms-context/#manually-toggling-edit-mode`);
1231
1300
  return next();
1232
1301
  }
@@ -1235,7 +1304,7 @@ async function tinaSetup(ctx, next, options) {
1235
1304
  }
1236
1305
  async function successMessage(ctx, next, options) {
1237
1306
  logger.info(`Tina setup ${import_chalk2.default.underline.green("done")} \u2705
1238
- Start your dev server with ${successText(`yarn tina-dev`)} and go to http://localhost:3000/demo/blog/HelloWorld to ${successText("check it out the page that was created for you")}
1307
+ Start your dev server with ${successText(`yarn dev`)} and go to http://localhost:3000/demo/blog/HelloWorld to ${successText("check it out the page that was created for you")}
1239
1308
  Enjoy Tina \u{1F999} !
1240
1309
  `);
1241
1310
  next();
@@ -0,0 +1,19 @@
1
+ /**
2
+
3
+ Copyright 2021 Forestry.io Holdings, Inc.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+
17
+ */
18
+ export declare function generateGqlScript(scriptValue: any): string;
19
+ export declare function extendNextScripts(scripts: any): any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/cli",
3
- "version": "0.60.6",
3
+ "version": "0.60.9",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "files": [
@@ -21,7 +21,7 @@
21
21
  ]
22
22
  },
23
23
  "devDependencies": {
24
- "@tinacms/scripts": "0.50.6",
24
+ "@tinacms/scripts": "0.50.7",
25
25
  "@types/clear": "0.1.0",
26
26
  "@types/cors": "2.8.5",
27
27
  "@types/express": "^4.17.7",
@@ -58,7 +58,7 @@
58
58
  "@graphql-tools/graphql-file-loader": "^7.2.0",
59
59
  "@graphql-tools/load": "^7.3.2",
60
60
  "@tinacms/datalayer": "0.0.2",
61
- "@tinacms/graphql": "0.59.7",
61
+ "@tinacms/graphql": "0.59.8",
62
62
  "@tinacms/metrics": "0.0.2",
63
63
  "@yarnpkg/esbuild-plugin-pnp": "^2.0.1-rc.3",
64
64
  "add": "^2.0.6",