@tinacms/cli 0.60.17 → 0.60.20

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,36 @@
1
1
  # tinacms-cli
2
2
 
3
+ ## 0.60.20
4
+
5
+ ### Patch Changes
6
+
7
+ - f71f55ac3: Fixd issue where --dev caused a breaking change
8
+ - Updated dependencies [57f09bdd7]
9
+ - @tinacms/graphql@0.60.5
10
+
11
+ ## 0.60.19
12
+
13
+ ### Patch Changes
14
+
15
+ - d103b27ad: Fix issue where new collections would not be added when CLI restarts
16
+ - e06dbb3ca: Adds `waitForDB` cmd to cli
17
+ - Updated dependencies [d103b27ad]
18
+ - @tinacms/graphql@0.60.4
19
+
20
+ ## 0.60.18
21
+
22
+ ### Patch Changes
23
+
24
+ - 79d112d79: Update cli to accept tinaCloudMediaStore flag and add to metadata during schema compilation
25
+ - 91d6e6758: revert platform aware paths in schema introduced in https://github.com/tinacms/tinacms/commit/558cc4368cd2a4b6e87dfb82bbfbb6f569f8a6f8
26
+ - b1240328d: Adds local server routes for handling media
27
+ - 91d6e6758: Fix issues with experimentalData on windows related to path separator inconsistency and interference with the .tina/**generated** folder
28
+ - Updated dependencies [79d112d79]
29
+ - Updated dependencies [3f46c6706]
30
+ - Updated dependencies [db9168578]
31
+ - Updated dependencies [91d6e6758]
32
+ - @tinacms/graphql@0.60.3
33
+
3
34
  ## 0.60.17
4
35
 
5
36
  ### Patch Changes
@@ -10,10 +10,12 @@ 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
+ import 'dotenv/config';
13
14
  import { Command } from '../command';
14
15
  export declare const CMD_GEN_TYPES = "schema:types";
15
16
  export declare const CMD_START_SERVER = "server:start";
16
17
  export declare const CMD_COMPILE_MODELS = "schema:compile";
18
+ export declare const CMD_WAIT_FOR_DB = "server:waitForDB";
17
19
  export declare const INIT = "init";
18
20
  export declare const AUDIT = "audit";
19
21
  export declare const baseCmds: Command[];
@@ -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: (sep: string) => string;
13
+ export declare const defaultSchema = "\nimport { defineSchema, defineConfig } from \"tinacms\";\n\nconst schema = 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: \"rich-text\",\n label: \"Blog Post Body\",\n name: \"body\",\n isBody: true,\n templates: [\n {\n name: \"PageSection\",\n label: \"Page Section\",\n fields: [\n {\n type: \"string\",\n name: \"heading\",\n label: \"Heading\",\n },\n {\n type: \"string\",\n name: \"content\",\n label: \"Content\",\n ui: {\n component: \"textarea\"\n }\n }\n ],\n },\n ]\n },\n ],\n },\n ],\n});\n\nexport default schema\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 schema,\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";
@@ -12,8 +12,14 @@ limitations under the License.
12
12
  */
13
13
  import type { TinaCloudSchema } from '@tinacms/graphql';
14
14
  export declare const resetGeneratedFolder: () => Promise<void>;
15
- export declare const compile: (_ctx: any, _next: any, options: {
15
+ export declare const compileClient: (ctx: any, next: any, options: {
16
+ clientFileType?: string;
17
+ verbose?: boolean;
18
+ dev?: boolean;
19
+ }) => Promise<any>;
20
+ export declare const compileSchema: (_ctx: any, _next: any, options: {
16
21
  schemaFileType?: string;
17
22
  verbose?: boolean;
23
+ dev?: boolean;
18
24
  }) => Promise<void>;
19
25
  export declare const defineSchema: (config: TinaCloudSchema) => TinaCloudSchema;
@@ -15,10 +15,12 @@ interface Options {
15
15
  command?: string;
16
16
  watchFolders?: string[];
17
17
  experimentalData?: boolean;
18
+ tinaCloudMediaStore?: boolean;
18
19
  noWatch?: boolean;
19
20
  noSDK: boolean;
20
21
  noTelemetry: boolean;
21
22
  verbose?: boolean;
23
+ dev?: boolean;
22
24
  }
23
- export declare function startServer(_ctx: any, _next: any, { port, command, noWatch, experimentalData, noSDK, noTelemetry, watchFolders, verbose, }: Options): Promise<void>;
25
+ export declare function startServer(_ctx: any, next: any, { port, noWatch, experimentalData, tinaCloudMediaStore, noSDK, noTelemetry, watchFolders, verbose, dev, }: Options): Promise<void>;
24
26
  export {};
@@ -10,7 +10,5 @@ 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
- /// <reference types="node" />
14
- import http from 'http';
15
- declare const gqlServer: (database: any) => Promise<http.Server>;
13
+ import { gqlServer } from '../../server';
16
14
  export default gqlServer;
@@ -0,0 +1,17 @@
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
+ interface Options {
14
+ command?: string;
15
+ }
16
+ export declare const startSubprocess: (_ctx: any, next: any, { command }: Options) => Promise<void>;
17
+ export {};
@@ -0,0 +1,15 @@
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 waitForDB: (ctx: any, next: any, options: {
14
+ verbose?: boolean;
15
+ }) => Promise<any>;
package/dist/index.js CHANGED
@@ -37,6 +37,9 @@ var __objRest = (source, exclude) => {
37
37
  var __esm = (fn, res) => function __init() {
38
38
  return fn && (res = (0, fn[Object.keys(fn)[0]])(fn = 0)), res;
39
39
  };
40
+ var __commonJS = (cb, mod) => function __require() {
41
+ return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
42
+ };
40
43
  var __export = (target, all) => {
41
44
  __markAsModule(target);
42
45
  for (var name2 in all)
@@ -54,22 +57,229 @@ var __toModule = (module2) => {
54
57
  return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
55
58
  };
56
59
 
57
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/start-server/server.ts
58
- var server_exports = {};
59
- __export(server_exports, {
60
- default: () => server_default
60
+ // pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/dotenv-npm-16.0.1-d99e72bb95-e97e94476c.zip/node_modules/dotenv/lib/main.js
61
+ var require_main = __commonJS({
62
+ "pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/dotenv-npm-16.0.1-d99e72bb95-e97e94476c.zip/node_modules/dotenv/lib/main.js"(exports, module2) {
63
+ var fs6 = require("fs");
64
+ var path4 = require("path");
65
+ var os = require("os");
66
+ var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
67
+ function parse2(src) {
68
+ const obj = {};
69
+ let lines = src.toString();
70
+ lines = lines.replace(/\r\n?/mg, "\n");
71
+ let match;
72
+ while ((match = LINE.exec(lines)) != null) {
73
+ const key = match[1];
74
+ let value = match[2] || "";
75
+ value = value.trim();
76
+ const maybeQuote = value[0];
77
+ value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
78
+ if (maybeQuote === '"') {
79
+ value = value.replace(/\\n/g, "\n");
80
+ value = value.replace(/\\r/g, "\r");
81
+ }
82
+ obj[key] = value;
83
+ }
84
+ return obj;
85
+ }
86
+ function _log(message) {
87
+ console.log(`[dotenv][DEBUG] ${message}`);
88
+ }
89
+ function _resolveHome(envPath) {
90
+ return envPath[0] === "~" ? path4.join(os.homedir(), envPath.slice(1)) : envPath;
91
+ }
92
+ function config(options) {
93
+ let dotenvPath = path4.resolve(process.cwd(), ".env");
94
+ let encoding = "utf8";
95
+ const debug = Boolean(options && options.debug);
96
+ const override = Boolean(options && options.override);
97
+ if (options) {
98
+ if (options.path != null) {
99
+ dotenvPath = _resolveHome(options.path);
100
+ }
101
+ if (options.encoding != null) {
102
+ encoding = options.encoding;
103
+ }
104
+ }
105
+ try {
106
+ const parsed = DotenvModule.parse(fs6.readFileSync(dotenvPath, { encoding }));
107
+ Object.keys(parsed).forEach(function(key) {
108
+ if (!Object.prototype.hasOwnProperty.call(process.env, key)) {
109
+ process.env[key] = parsed[key];
110
+ } else {
111
+ if (override === true) {
112
+ process.env[key] = parsed[key];
113
+ }
114
+ if (debug) {
115
+ if (override === true) {
116
+ _log(`"${key}" is already defined in \`process.env\` and WAS overwritten`);
117
+ } else {
118
+ _log(`"${key}" is already defined in \`process.env\` and was NOT overwritten`);
119
+ }
120
+ }
121
+ }
122
+ });
123
+ return { parsed };
124
+ } catch (e) {
125
+ if (debug) {
126
+ _log(`Failed to load ${dotenvPath} ${e.message}`);
127
+ }
128
+ return { error: e };
129
+ }
130
+ }
131
+ var DotenvModule = {
132
+ config,
133
+ parse: parse2
134
+ };
135
+ module2.exports.config = DotenvModule.config;
136
+ module2.exports.parse = DotenvModule.parse;
137
+ module2.exports = DotenvModule;
138
+ }
139
+ });
140
+
141
+ // pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/dotenv-npm-16.0.1-d99e72bb95-e97e94476c.zip/node_modules/dotenv/lib/env-options.js
142
+ var require_env_options = __commonJS({
143
+ "pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/dotenv-npm-16.0.1-d99e72bb95-e97e94476c.zip/node_modules/dotenv/lib/env-options.js"(exports, module2) {
144
+ var options = {};
145
+ if (process.env.DOTENV_CONFIG_ENCODING != null) {
146
+ options.encoding = process.env.DOTENV_CONFIG_ENCODING;
147
+ }
148
+ if (process.env.DOTENV_CONFIG_PATH != null) {
149
+ options.path = process.env.DOTENV_CONFIG_PATH;
150
+ }
151
+ if (process.env.DOTENV_CONFIG_DEBUG != null) {
152
+ options.debug = process.env.DOTENV_CONFIG_DEBUG;
153
+ }
154
+ if (process.env.DOTENV_CONFIG_OVERRIDE != null) {
155
+ options.override = process.env.DOTENV_CONFIG_OVERRIDE;
156
+ }
157
+ module2.exports = options;
158
+ }
159
+ });
160
+
161
+ // pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/dotenv-npm-16.0.1-d99e72bb95-e97e94476c.zip/node_modules/dotenv/lib/cli-options.js
162
+ var require_cli_options = __commonJS({
163
+ "pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/dotenv-npm-16.0.1-d99e72bb95-e97e94476c.zip/node_modules/dotenv/lib/cli-options.js"(exports, module2) {
164
+ var re = /^dotenv_config_(encoding|path|debug|override)=(.+)$/;
165
+ module2.exports = function optionMatcher(args) {
166
+ return args.reduce(function(acc, cur) {
167
+ const matches = cur.match(re);
168
+ if (matches) {
169
+ acc[matches[1]] = matches[2];
170
+ }
171
+ return acc;
172
+ }, {});
173
+ };
174
+ }
175
+ });
176
+
177
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/server/models/media.ts
178
+ var import_fs_extra5, import_path6, MediaModel;
179
+ var init_media = __esm({
180
+ "pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/server/models/media.ts"() {
181
+ import_fs_extra5 = __toModule(require("fs-extra"));
182
+ import_path6 = __toModule(require("path"));
183
+ MediaModel = class {
184
+ constructor({ basePath }) {
185
+ this.basePath = basePath;
186
+ }
187
+ async listMedia(args) {
188
+ try {
189
+ const folderPath = (0, import_path6.join)(this.basePath, args.searchPath);
190
+ const filesStr = await import_fs_extra5.default.readdir(folderPath);
191
+ const filesProm = filesStr.map(async (x) => {
192
+ const filePath = (0, import_path6.join)(folderPath, x);
193
+ const stat = await import_fs_extra5.default.stat(filePath);
194
+ const src = (0, import_path6.join)(args.searchPath, x);
195
+ return {
196
+ size: stat.size,
197
+ fileName: x,
198
+ src: "/" + src,
199
+ isFile: stat.isFile()
200
+ };
201
+ });
202
+ const files = await Promise.all(filesProm);
203
+ return {
204
+ files: files.filter((x) => x.isFile),
205
+ directories: files.filter((x) => !x.isFile).map((x) => x.src)
206
+ };
207
+ } catch (error) {
208
+ console.error(error);
209
+ return {
210
+ files: [],
211
+ directories: [],
212
+ error: error == null ? void 0 : error.toString()
213
+ };
214
+ }
215
+ }
216
+ async deleteMedia(args) {
217
+ try {
218
+ const file = (0, import_path6.join)(this.basePath, args.searchPath);
219
+ await import_fs_extra5.default.stat(file);
220
+ await import_fs_extra5.default.remove(file);
221
+ return { ok: true };
222
+ } catch (error) {
223
+ console.error(error);
224
+ return { ok: false, message: error == null ? void 0 : error.toString() };
225
+ }
226
+ }
227
+ };
228
+ }
61
229
  });
62
- var import_cors, import_http, import_express, import_altair_express_middleware, import_body_parser, gqlServer, server_default;
230
+
231
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/server/routes/index.ts
232
+ var import_express, import_path7, import_multer, mediaFolder, storage, upload, mediaModel, mediaRouter;
233
+ var init_routes = __esm({
234
+ "pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/server/routes/index.ts"() {
235
+ import_express = __toModule(require("express"));
236
+ import_path7 = __toModule(require("path"));
237
+ import_multer = __toModule(require("multer"));
238
+ init_media();
239
+ mediaFolder = (0, import_path7.join)(process.cwd(), "public");
240
+ storage = import_multer.default.diskStorage({
241
+ destination: function(req, file, cb) {
242
+ cb(null, mediaFolder);
243
+ },
244
+ filename: function(req, _file, cb) {
245
+ const file = req.params[0];
246
+ cb(null, file);
247
+ }
248
+ });
249
+ upload = (0, import_multer.default)({ storage });
250
+ mediaModel = new MediaModel({ basePath: mediaFolder });
251
+ mediaRouter = (0, import_express.Router)();
252
+ mediaRouter.get("/list/*", async (req, res) => {
253
+ const folder = req.params[0];
254
+ const media = await mediaModel.listMedia({
255
+ searchPath: folder
256
+ });
257
+ res.json(media);
258
+ });
259
+ mediaRouter.delete("/delete/*", async (req, res) => {
260
+ const file = req.params[0];
261
+ const didDelete = await mediaModel.deleteMedia({ searchPath: file });
262
+ res.json(didDelete);
263
+ });
264
+ mediaRouter.post("/upload/*", upload.single("file"), function(req, res, next) {
265
+ res.json({ ok: true });
266
+ });
267
+ }
268
+ });
269
+
270
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/server/server.ts
271
+ var import_cors, import_http, import_express2, import_altair_express_middleware, import_body_parser, gqlServer;
63
272
  var init_server = __esm({
64
- "pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/start-server/server.ts"() {
273
+ "pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/server/server.ts"() {
65
274
  import_cors = __toModule(require("cors"));
66
275
  import_http = __toModule(require("http"));
67
- import_express = __toModule(require("express"));
276
+ import_express2 = __toModule(require("express"));
68
277
  import_altair_express_middleware = __toModule(require("altair-express-middleware"));
69
278
  import_body_parser = __toModule(require("body-parser"));
279
+ init_routes();
70
280
  gqlServer = async (database) => {
71
281
  const gqlPackage = require("@tinacms/graphql");
72
- const app = (0, import_express.default)();
282
+ const app = (0, import_express2.default)();
73
283
  const server = import_http.default.createServer(app);
74
284
  app.use((0, import_cors.default)());
75
285
  app.use(import_body_parser.default.json());
@@ -103,8 +313,28 @@ var init_server = __esm({
103
313
  });
104
314
  return res.json(result);
105
315
  });
316
+ app.use("/media", mediaRouter);
106
317
  return server;
107
318
  };
319
+ }
320
+ });
321
+
322
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/server/index.ts
323
+ var init_server2 = __esm({
324
+ "pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/server/index.ts"() {
325
+ init_server();
326
+ }
327
+ });
328
+
329
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/start-server/server.ts
330
+ var server_exports = {};
331
+ __export(server_exports, {
332
+ default: () => server_default
333
+ });
334
+ var server_default;
335
+ var init_server3 = __esm({
336
+ "pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/start-server/server.ts"() {
337
+ init_server2();
108
338
  server_default = gqlServer;
109
339
  }
110
340
  });
@@ -118,7 +348,7 @@ var commander = __toModule(require("commander"));
118
348
 
119
349
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/package.json
120
350
  var name = "@tinacms/cli";
121
- var version = "0.60.17";
351
+ var version = "0.60.20";
122
352
 
123
353
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/query-gen/attachSchema.ts
124
354
  var import_graphql = __toModule(require("@tinacms/graphql"));
@@ -1229,6 +1459,11 @@ async function successMessage(ctx, next, options) {
1229
1459
  next();
1230
1460
  }
1231
1461
 
1462
+ // pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/dotenv-npm-16.0.1-d99e72bb95-e97e94476c.zip/node_modules/dotenv/config.js
1463
+ (function() {
1464
+ require_main().config(Object.assign({}, require_env_options(), require_cli_options()(process.argv)));
1465
+ })();
1466
+
1232
1467
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/middleware.ts
1233
1468
  var chain = async (cmds, options) => {
1234
1469
  const ctx = {};
@@ -1289,7 +1524,7 @@ var import_path5 = __toModule(require("path"));
1289
1524
  var import_esbuild = __toModule(require("esbuild"));
1290
1525
 
1291
1526
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/compile/defaultSchema.ts
1292
- var defaultSchema = (sep) => `
1527
+ var defaultSchema = `
1293
1528
  import { defineSchema, defineConfig } from "tinacms";
1294
1529
 
1295
1530
  const schema = defineSchema({
@@ -1297,7 +1532,7 @@ const schema = defineSchema({
1297
1532
  {
1298
1533
  label: "Blog Posts",
1299
1534
  name: "posts",
1300
- path: "content${sep}posts",
1535
+ path: "content/posts",
1301
1536
  fields: [
1302
1537
  {
1303
1538
  type: "string",
@@ -1376,39 +1611,49 @@ export const tinaConfig = defineConfig({
1376
1611
  });
1377
1612
  `;
1378
1613
 
1379
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/lib/getSchemaPath.ts
1614
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/lib/getPath.ts
1380
1615
  var import_path4 = __toModule(require("path"));
1381
1616
  var import_fs_extra3 = __toModule(require("fs-extra"));
1382
- var ErrorMessage = "Must provide a `.tina/schema.{ts,js,tsx,jsx}`";
1383
- var getSchemaPath = ({ projectDir }) => {
1617
+ var getPath = ({
1618
+ projectDir,
1619
+ filename,
1620
+ allowedTypes,
1621
+ errorMessage
1622
+ }) => {
1384
1623
  if (!import_fs_extra3.default.existsSync(projectDir)) {
1385
- throw new Error(ErrorMessage);
1386
- }
1387
- const inputPathTS = import_path4.default.join(projectDir, "schema.ts");
1388
- const inputPathJS = import_path4.default.join(projectDir, "schema.js");
1389
- const inputPathTSX = import_path4.default.join(projectDir, "schema.tsx");
1390
- const inputPathJSX = import_path4.default.join(projectDir, "schema.jsx");
1391
- let inputFile;
1392
- if (import_fs_extra3.default.existsSync(inputPathTS)) {
1393
- inputFile = inputPathTS;
1394
- } else if (import_fs_extra3.default.existsSync(inputPathJS)) {
1395
- inputFile = inputPathJS;
1396
- } else if (import_fs_extra3.default.existsSync(inputPathTSX)) {
1397
- inputFile = inputPathTSX;
1398
- } else if (import_fs_extra3.default.existsSync(inputPathJSX)) {
1399
- inputFile = inputPathJSX;
1624
+ throw new Error(errorMessage);
1400
1625
  }
1626
+ const filePaths = allowedTypes.map((ext) => import_path4.default.join(projectDir, `${filename}.${ext}`));
1627
+ let inputFile = void 0;
1628
+ filePaths.every((path4) => {
1629
+ if (import_fs_extra3.default.existsSync(path4)) {
1630
+ inputFile = path4;
1631
+ return false;
1632
+ }
1633
+ return true;
1634
+ });
1401
1635
  if (!inputFile) {
1402
- throw new Error(ErrorMessage);
1636
+ throw new Error(errorMessage);
1403
1637
  }
1404
1638
  return inputFile;
1405
1639
  };
1640
+ var getSchemaPath = ({ projectDir }) => {
1641
+ const filename = "schema";
1642
+ const allowedTypes = ["js", "jsx", "ts", "tsx"];
1643
+ const errorMessage = "Must provide a `.tina/schema.{ts,js,tsx,jsx}`";
1644
+ return getPath({ projectDir, filename, allowedTypes, errorMessage });
1645
+ };
1646
+ var getClientPath = ({ projectDir }) => {
1647
+ const filename = "client";
1648
+ const allowedTypes = ["js", "ts"];
1649
+ const errorMessage = "Must provide a `.tina/client.{ts,js}`";
1650
+ return getPath({ projectDir, filename, allowedTypes, errorMessage });
1651
+ };
1406
1652
 
1407
1653
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/compile/index.ts
1408
1654
  var tinaPath = import_path5.default.join(process.cwd(), ".tina");
1409
1655
  var packageJSONFilePath = import_path5.default.join(process.cwd(), "package.json");
1410
1656
  var tinaGeneratedPath = import_path5.default.join(tinaPath, "__generated__");
1411
- var tinaTempPath = import_path5.default.join(tinaGeneratedPath, "temp");
1412
1657
  var tinaConfigPath = import_path5.default.join(tinaGeneratedPath, "config");
1413
1658
  var resetGeneratedFolder = async () => {
1414
1659
  try {
@@ -1424,14 +1669,74 @@ export const queries = (client)=>({})
1424
1669
  `);
1425
1670
  await import_fs_extra4.default.outputFile(import_path5.default.join(tinaGeneratedPath, ".gitignore"), "db");
1426
1671
  };
1427
- var cleanup = async ({ tinaTempPath: tinaTempPath2 }) => {
1428
- await import_fs_extra4.default.remove(tinaTempPath2);
1672
+ var cleanup = async ({ tinaTempPath }) => {
1673
+ await import_fs_extra4.default.remove(tinaTempPath);
1674
+ };
1675
+ var compileClient = async (ctx, next, options) => {
1676
+ const tinaTempPath = import_path5.default.join(tinaGeneratedPath, "temp_client");
1677
+ if (!options.clientFileType)
1678
+ options = __spreadProps(__spreadValues({}, options), { clientFileType: "ts" });
1679
+ if (options.verbose) {
1680
+ logger.info(logText("Compiling Client..."));
1681
+ }
1682
+ const { clientFileType: requestedClientFileType = "ts" } = options;
1683
+ const allowedFileTypes = ["ts", "js"];
1684
+ if (allowedFileTypes.includes(requestedClientFileType) === false) {
1685
+ throw new Error(`Requested schema file type '${requestedClientFileType}' is not valid. Supported schema file types: 'ts, js'`);
1686
+ }
1687
+ if (ctx) {
1688
+ ctx.clientFileType = requestedClientFileType;
1689
+ }
1690
+ let clientExists = true;
1691
+ try {
1692
+ getClientPath({ projectDir: tinaPath });
1693
+ } catch {
1694
+ clientExists = false;
1695
+ }
1696
+ if (!clientExists) {
1697
+ if (options.verbose) {
1698
+ logger.info(logText(`.tina/client.${requestedClientFileType} not found, skipping compile client...`));
1699
+ }
1700
+ return next();
1701
+ }
1702
+ try {
1703
+ const define = {};
1704
+ if (!process.env.NODE_ENV) {
1705
+ define["process.env.NODE_ENV"] = options.dev ? '"development"' : '"production"';
1706
+ }
1707
+ const inputFile = getClientPath({ projectDir: tinaPath });
1708
+ await transpile(inputFile, "client.js", tinaTempPath, options.verbose, define);
1709
+ } catch (e) {
1710
+ await cleanup({ tinaTempPath });
1711
+ throw new BuildSchemaError(e);
1712
+ }
1713
+ Object.keys(require.cache).map((key) => {
1714
+ if (key.startsWith(tinaTempPath)) {
1715
+ delete require.cache[require.resolve(key)];
1716
+ }
1717
+ });
1718
+ try {
1719
+ const clientFunc = require(import_path5.default.join(tinaTempPath, "client.js"));
1720
+ const client = clientFunc.default;
1721
+ ctx.client = client;
1722
+ await cleanup({ tinaTempPath });
1723
+ } catch (e) {
1724
+ await cleanup({ tinaTempPath });
1725
+ if (e instanceof Error) {
1726
+ if (e.name === "TinaSchemaValidationError") {
1727
+ throw e;
1728
+ }
1729
+ }
1730
+ throw new ExecuteSchemaError(e);
1731
+ }
1732
+ return next();
1429
1733
  };
1430
- var compile = async (_ctx, _next, options) => {
1734
+ var compileSchema = async (_ctx, _next, options) => {
1735
+ const tinaTempPath = import_path5.default.join(tinaGeneratedPath, "temp_schema");
1431
1736
  if (!options.schemaFileType)
1432
1737
  options = __spreadProps(__spreadValues({}, options), { schemaFileType: "ts" });
1433
1738
  if (options.verbose) {
1434
- logger.info(logText("Compiling..."));
1739
+ logger.info(logText("Compiling Schema..."));
1435
1740
  }
1436
1741
  const { schemaFileType: requestedSchemaFileType = "ts" } = options;
1437
1742
  const schemaFileType2 = (requestedSchemaFileType === "ts" || requestedSchemaFileType === "tsx") && "ts" || (requestedSchemaFileType === "js" || requestedSchemaFileType === "jsx") && "js";
@@ -1454,10 +1759,15 @@ var compile = async (_ctx, _next, options) => {
1454
1759
  `));
1455
1760
  const file = import_path5.default.join(tinaPath, `schema.${schemaFileType2}`);
1456
1761
  await import_fs_extra4.default.ensureFile(file);
1457
- await import_fs_extra4.default.writeFile(file, defaultSchema(import_path5.default.sep));
1762
+ await import_fs_extra4.default.writeFile(file, defaultSchema);
1458
1763
  }
1459
1764
  try {
1460
- await transpile(tinaPath, tinaTempPath, options.verbose);
1765
+ const define = {};
1766
+ if (!process.env.NODE_ENV) {
1767
+ define["process.env.NODE_ENV"] = options.dev ? '"development"' : '"production"';
1768
+ }
1769
+ const inputFile = getSchemaPath({ projectDir: tinaPath });
1770
+ await transpile(inputFile, "schema.js", tinaTempPath, options.verbose, define);
1461
1771
  } catch (e) {
1462
1772
  await cleanup({ tinaTempPath });
1463
1773
  throw new BuildSchemaError(e);
@@ -1482,7 +1792,7 @@ var compile = async (_ctx, _next, options) => {
1482
1792
  throw new ExecuteSchemaError(e);
1483
1793
  }
1484
1794
  };
1485
- var transpile = async (projectDir, tempDir, verbose) => {
1795
+ var transpile = async (inputFile, outputFile, tempDir, verbose, define) => {
1486
1796
  if (verbose)
1487
1797
  logger.info(logText("Building javascript..."));
1488
1798
  const packageJSON = JSON.parse(import_fs_extra4.default.readFileSync(packageJSONFilePath).toString() || "{}");
@@ -1490,8 +1800,7 @@ var transpile = async (projectDir, tempDir, verbose) => {
1490
1800
  const peerDeps = (packageJSON == null ? void 0 : packageJSON.peerDependencies) || [];
1491
1801
  const devDeps = (packageJSON == null ? void 0 : packageJSON.devDependencies) || [];
1492
1802
  const external = Object.keys(__spreadValues(__spreadValues(__spreadValues({}, deps), peerDeps), devDeps));
1493
- const inputFile = getSchemaPath({ projectDir });
1494
- const outputPath = import_path5.default.join(tempDir, "schema.js");
1803
+ const outputPath = import_path5.default.join(tempDir, outputFile);
1495
1804
  await (0, import_esbuild.build)({
1496
1805
  bundle: true,
1497
1806
  platform: "neutral",
@@ -1500,7 +1809,8 @@ var transpile = async (projectDir, tempDir, verbose) => {
1500
1809
  treeShaking: true,
1501
1810
  external: [...external, "./node_modules/*"],
1502
1811
  loader: loaders,
1503
- outfile: outputPath
1812
+ outfile: outputPath,
1813
+ define
1504
1814
  });
1505
1815
  if (verbose)
1506
1816
  logger.info(logText(`Javascript built`));
@@ -1553,20 +1863,20 @@ var AsyncLock = class {
1553
1863
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/start-server/index.ts
1554
1864
  var import_metrics3 = __toModule(require("@tinacms/metrics"));
1555
1865
  var import_chalk6 = __toModule(require("chalk"));
1556
- var import_child_process = __toModule(require("child_process"));
1557
1866
  var import_chokidar = __toModule(require("chokidar"));
1558
- var import_path6 = __toModule(require("path"));
1867
+ var import_path8 = __toModule(require("path"));
1559
1868
  var lock = new AsyncLock();
1560
1869
  var gqlPackageFile = require.resolve("@tinacms/graphql");
1561
- async function startServer(_ctx, _next, {
1870
+ async function startServer(_ctx, next, {
1562
1871
  port = 4001,
1563
- command,
1564
1872
  noWatch,
1565
1873
  experimentalData,
1874
+ tinaCloudMediaStore: tinaCloudMediaStore2,
1566
1875
  noSDK,
1567
1876
  noTelemetry,
1568
1877
  watchFolders,
1569
- verbose
1878
+ verbose,
1879
+ dev
1570
1880
  }) {
1571
1881
  lock.disable();
1572
1882
  const rootPath2 = process.cwd();
@@ -1583,39 +1893,24 @@ async function startServer(_ctx, _next, {
1583
1893
  const store = experimentalData ? new import_datalayer3.LevelStore(rootPath2) : new import_datalayer3.FilesystemStore({ rootPath: rootPath2 });
1584
1894
  const shouldBuild = bridge.supportsBuilding();
1585
1895
  const database = await (0, import_graphql10.createDatabase)({ store, bridge });
1586
- const startSubprocess = () => {
1587
- if (typeof command === "string") {
1588
- const commands = command.split(" ");
1589
- const firstCommand = commands[0];
1590
- const args = commands.slice(1) || [];
1591
- const ps = import_child_process.default.spawn(firstCommand, args, {
1592
- stdio: "inherit",
1593
- shell: true
1594
- });
1595
- ps.on("error", (code) => {
1596
- logger.error(dangerText(`An error has occurred in the Next.js child process. Error message below`));
1597
- logger.error(`name: ${code.name}
1598
- message: ${code.message}
1599
-
1600
- stack: ${code.stack || "No stack was provided"}`);
1601
- });
1602
- ps.on("close", (code) => {
1603
- logger.info(`child process exited with code ${code}`);
1604
- process.exit(code);
1605
- });
1606
- }
1607
- };
1608
1896
  let ready = false;
1609
1897
  const build2 = async (noSDK2) => {
1898
+ database.clearCache();
1610
1899
  await lock.promise;
1611
1900
  lock.enable();
1612
1901
  try {
1613
1902
  if (!process.env.CI && !noWatch) {
1903
+ await store.close();
1614
1904
  await resetGeneratedFolder();
1905
+ await store.open();
1906
+ }
1907
+ const cliFlags = [];
1908
+ if (tinaCloudMediaStore2) {
1909
+ cliFlags.push("tinaCloudMediaStore");
1615
1910
  }
1616
1911
  const database2 = await (0, import_graphql10.createDatabase)({ store, bridge });
1617
- await compile(null, null, { verbose });
1618
- const schema = await (0, import_graphql10.buildSchema)(rootPath2, database2);
1912
+ await compileSchema(null, null, { verbose, dev });
1913
+ const schema = await (0, import_graphql10.buildSchema)(rootPath2, database2, cliFlags);
1619
1914
  await genTypes({ schema }, () => {
1620
1915
  }, { noSDK: noSDK2, verbose });
1621
1916
  } catch (error) {
@@ -1624,7 +1919,7 @@ stack: ${code.stack || "No stack was provided"}`);
1624
1919
  lock.disable();
1625
1920
  }
1626
1921
  };
1627
- const foldersToWatch = (watchFolders || []).map((x) => import_path6.default.join(rootPath2, x));
1922
+ const foldersToWatch = (watchFolders || []).map((x) => import_path8.default.join(rootPath2, x));
1628
1923
  if (!noWatch && !process.env.CI) {
1629
1924
  import_chokidar.default.watch([
1630
1925
  ...foldersToWatch,
@@ -1633,7 +1928,7 @@ stack: ${code.stack || "No stack was provided"}`);
1633
1928
  ignored: [
1634
1929
  "**/node_modules/**/*",
1635
1930
  "**/.next/**/*",
1636
- `${import_path6.default.resolve(rootPath2)}/.tina/__generated__/**/*`
1931
+ `${import_path8.default.resolve(rootPath2)}/.tina/__generated__/**/*`
1637
1932
  ]
1638
1933
  }).on("ready", async () => {
1639
1934
  if (verbose)
@@ -1643,7 +1938,7 @@ stack: ${code.stack || "No stack was provided"}`);
1643
1938
  await build2(noSDK);
1644
1939
  }
1645
1940
  ready = true;
1646
- startSubprocess();
1941
+ next();
1647
1942
  } catch (e) {
1648
1943
  handleServerErrors(e);
1649
1944
  console.log(e);
@@ -1678,7 +1973,7 @@ stack: ${code.stack || "No stack was provided"}`);
1678
1973
  };
1679
1974
  let isReady = false;
1680
1975
  const start = async () => {
1681
- const s = (init_server(), server_exports);
1976
+ const s = (init_server3(), server_exports);
1682
1977
  state.server = await s.default(database);
1683
1978
  state.server.listen(port, () => {
1684
1979
  const altairUrl = `http://localhost:${port}/altair/`;
@@ -1729,14 +2024,114 @@ or`);
1729
2024
  logger.info("Detected CI environment, omitting watch commands...");
1730
2025
  }
1731
2026
  start();
1732
- startSubprocess();
2027
+ next();
1733
2028
  }
1734
2029
  }
1735
2030
 
2031
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/waitForDB/index.ts
2032
+ var POLLING_INTERVAL = 5e3;
2033
+ var STATUS_INPROGRESS = "inprogress";
2034
+ var STATUS_COMPLETE = "complete";
2035
+ var STATUS_FAILED = "failed";
2036
+ var IndexFailedError = class extends Error {
2037
+ constructor(message) {
2038
+ super(message);
2039
+ this.name = "IndexFailedError";
2040
+ }
2041
+ };
2042
+ var waitForDB = async (ctx, next, options) => {
2043
+ if (options.verbose) {
2044
+ logger.info(logText("Waiting for DB..."));
2045
+ }
2046
+ if (!ctx.client) {
2047
+ if (options.verbose) {
2048
+ logger.info(logText("client is unavailable, skipping..."));
2049
+ }
2050
+ return next();
2051
+ }
2052
+ const client = ctx.client;
2053
+ const { host, clientId, branch, isLocalClient } = client.parseURL();
2054
+ if (isLocalClient) {
2055
+ if (options.verbose) {
2056
+ logger.info(logText("client is local, skipping..."));
2057
+ }
2058
+ return next();
2059
+ }
2060
+ const pollForStatus = async () => {
2061
+ try {
2062
+ if (options.verbose) {
2063
+ logger.info(logText("Polling for status..."));
2064
+ }
2065
+ const headers = new Headers();
2066
+ headers.append("Content-Type", "application/json");
2067
+ if (client.readonlyToken) {
2068
+ headers.append("X-API-KEY", client.readonlyToken);
2069
+ }
2070
+ const response = await fetch(`https://${host}/db/${clientId}/status/${branch}`, {
2071
+ method: "GET",
2072
+ headers
2073
+ });
2074
+ const { status, error } = await response.json();
2075
+ const statusMessage = `DB responded with: '${status}'`;
2076
+ if (status === STATUS_COMPLETE) {
2077
+ if (options.verbose) {
2078
+ logger.info(logText(`${statusMessage}`));
2079
+ }
2080
+ return next();
2081
+ } else if (status === STATUS_INPROGRESS) {
2082
+ if (options.verbose) {
2083
+ logger.info(logText(`${statusMessage}, trying again in 5 seconds`));
2084
+ }
2085
+ setTimeout(pollForStatus, POLLING_INTERVAL);
2086
+ } else if (status === STATUS_FAILED) {
2087
+ throw new IndexFailedError(`Attempting to index DB responded with status 'failed', ${error}`);
2088
+ } else {
2089
+ if (options.verbose) {
2090
+ logger.info(logText(`${statusMessage}`));
2091
+ }
2092
+ return next();
2093
+ }
2094
+ } catch (e) {
2095
+ if (e instanceof IndexFailedError) {
2096
+ throw e;
2097
+ } else {
2098
+ throw new Error(`Unable to query DB for indexing status, encountered error: ${e.message}`);
2099
+ }
2100
+ }
2101
+ };
2102
+ pollForStatus();
2103
+ };
2104
+
2105
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/startSubprocess/index.ts
2106
+ var import_child_process = __toModule(require("child_process"));
2107
+ var startSubprocess = async (_ctx, next, { command }) => {
2108
+ if (typeof command === "string") {
2109
+ const commands = command.split(" ");
2110
+ const firstCommand = commands[0];
2111
+ const args = commands.slice(1) || [];
2112
+ const ps = import_child_process.default.spawn(firstCommand, args, {
2113
+ stdio: "inherit",
2114
+ shell: true
2115
+ });
2116
+ ps.on("error", (code) => {
2117
+ logger.error(dangerText(`An error has occurred in the Next.js child process. Error message below`));
2118
+ logger.error(`name: ${code.name}
2119
+ message: ${code.message}
2120
+
2121
+ stack: ${code.stack || "No stack was provided"}`);
2122
+ });
2123
+ ps.on("close", (code) => {
2124
+ logger.info(`child process exited with code ${code}`);
2125
+ process.exit(code);
2126
+ });
2127
+ }
2128
+ };
2129
+
1736
2130
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/baseCmds.ts
1737
2131
  var CMD_GEN_TYPES = "schema:types";
1738
2132
  var CMD_START_SERVER = "server:start";
1739
2133
  var CMD_COMPILE_MODELS = "schema:compile";
2134
+ var CMD_WAIT_FOR_DB = "server:waitForDB";
1740
2135
  var INIT = "init";
1741
2136
  var AUDIT = "audit";
1742
2137
  var startServerPortOption = {
@@ -1783,6 +2178,14 @@ var verboseOption = {
1783
2178
  name: "-v, --verbose",
1784
2179
  description: "increase verbosity of logged output"
1785
2180
  };
2181
+ var tinaCloudMediaStore = {
2182
+ name: "--tinaCloudMediaStore",
2183
+ description: "Automatically pushes updates from GitHub to the Tina Cloud Media Store"
2184
+ };
2185
+ var developmentOption = {
2186
+ name: "--dev",
2187
+ description: "Uses NODE_ENV=development when compiling client and schema"
2188
+ };
1786
2189
  var baseCmds = [
1787
2190
  {
1788
2191
  command: CMD_START_SERVER,
@@ -1791,36 +2194,60 @@ var baseCmds = [
1791
2194
  startServerPortOption,
1792
2195
  subCommand,
1793
2196
  experimentalDatalayer,
2197
+ tinaCloudMediaStore,
1794
2198
  noWatchOption,
1795
2199
  noSDKCodegenOption,
1796
2200
  noTelemetryOption,
1797
2201
  watchFileOption,
1798
- verboseOption
2202
+ verboseOption,
2203
+ developmentOption
1799
2204
  ],
1800
- action: (options) => chain([startServer], options)
2205
+ action: (options) => chain([startServer, startSubprocess], options)
2206
+ },
2207
+ {
2208
+ command: CMD_WAIT_FOR_DB,
2209
+ description: "Wait for DB to finish indexing, start subprocess",
2210
+ options: [
2211
+ subCommand,
2212
+ experimentalDatalayer,
2213
+ noTelemetryOption,
2214
+ verboseOption,
2215
+ developmentOption
2216
+ ],
2217
+ action: (options) => chain([compileClient, waitForDB, startSubprocess], options)
1801
2218
  },
1802
2219
  {
1803
2220
  command: CMD_COMPILE_MODELS,
1804
2221
  description: "Compile schema into static files for the server",
1805
- options: [experimentalDatalayer, noTelemetryOption],
1806
- action: (options) => chain([compile], options)
2222
+ options: [experimentalDatalayer, tinaCloudMediaStore, noTelemetryOption],
2223
+ action: (options) => chain([compileSchema], options)
1807
2224
  },
1808
2225
  {
1809
2226
  command: CMD_GEN_TYPES,
1810
2227
  description: "Generate a GraphQL query for your site's schema, (and optionally Typescript types)",
1811
- options: [experimentalDatalayer, noSDKCodegenOption, noTelemetryOption],
2228
+ options: [
2229
+ experimentalDatalayer,
2230
+ tinaCloudMediaStore,
2231
+ noSDKCodegenOption,
2232
+ noTelemetryOption
2233
+ ],
1812
2234
  action: (options) => chain([attachSchema, genTypes], options)
1813
2235
  },
1814
2236
  {
1815
2237
  command: INIT,
1816
- options: [experimentalDatalayer, noTelemetryOption, schemaFileType],
2238
+ options: [
2239
+ experimentalDatalayer,
2240
+ tinaCloudMediaStore,
2241
+ noTelemetryOption,
2242
+ schemaFileType
2243
+ ],
1817
2244
  description: "Add Tina Cloud to an existing project",
1818
2245
  action: (options) => chain([
1819
2246
  checkDeps,
1820
2247
  initTina,
1821
2248
  installDeps,
1822
2249
  async (_ctx, next, options2) => {
1823
- await compile(_ctx, next, options2);
2250
+ await compileSchema(_ctx, next, options2);
1824
2251
  next();
1825
2252
  },
1826
2253
  attachSchema,
@@ -1839,7 +2266,7 @@ var baseCmds = [
1839
2266
  next();
1840
2267
  },
1841
2268
  async (_ctx, next) => {
1842
- await compile(_ctx, next, options);
2269
+ await compileSchema(_ctx, next, options);
1843
2270
  next();
1844
2271
  },
1845
2272
  attachSchema,
@@ -13,3 +13,6 @@ limitations under the License.
13
13
  export declare const getSchemaPath: ({ projectDir }: {
14
14
  projectDir: string;
15
15
  }) => any;
16
+ export declare const getClientPath: ({ projectDir }: {
17
+ projectDir: string;
18
+ }) => any;
@@ -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 * from './getSchemaPath';
13
+ export * from './getPath';
@@ -0,0 +1,13 @@
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 * from './server';
@@ -0,0 +1,41 @@
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
+ interface MediaArgs {
14
+ searchPath: string;
15
+ }
16
+ interface File {
17
+ src: string;
18
+ fileName: string;
19
+ size: number;
20
+ }
21
+ interface ListMediaRes {
22
+ directories: string[];
23
+ files: File[];
24
+ cursor?: string;
25
+ error?: string;
26
+ }
27
+ declare type SuccessRecord = {
28
+ ok: true;
29
+ } | {
30
+ ok: false;
31
+ message: string;
32
+ };
33
+ export declare class MediaModel {
34
+ readonly basePath: string;
35
+ constructor({ basePath }: {
36
+ basePath: string;
37
+ });
38
+ listMedia(args: MediaArgs): Promise<ListMediaRes>;
39
+ deleteMedia(args: MediaArgs): Promise<SuccessRecord>;
40
+ }
41
+ export {};
@@ -0,0 +1,13 @@
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 mediaRouter: import("express-serve-static-core").Router;
@@ -0,0 +1,15 @@
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
+ /// <reference types="node" />
14
+ import http from 'http';
15
+ export declare const gqlServer: (database: any) => Promise<http.Server>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/cli",
3
- "version": "0.60.17",
3
+ "version": "0.60.20",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "files": [
@@ -35,6 +35,7 @@
35
35
  "@types/lodash": "^4.14.157",
36
36
  "@types/lodash.get": "^4.4.6",
37
37
  "@types/log4js": "^2.3.5",
38
+ "@types/multer": "^1.4.7",
38
39
  "@types/progress": "^2.0.3",
39
40
  "@types/prompts": "^2.0.13",
40
41
  "@types/yup": "^0.29.11",
@@ -58,7 +59,7 @@
58
59
  "@graphql-tools/graphql-file-loader": "^7.2.0",
59
60
  "@graphql-tools/load": "^7.3.2",
60
61
  "@tinacms/datalayer": "0.1.1",
61
- "@tinacms/graphql": "0.60.2",
62
+ "@tinacms/graphql": "0.60.5",
62
63
  "@tinacms/metrics": "0.0.3",
63
64
  "@tinacms/schema-tools": "0.0.4",
64
65
  "@yarnpkg/esbuild-plugin-pnp": "^2.0.1-rc.3",
@@ -72,6 +73,7 @@
72
73
  "chokidar": "^3.5.1",
73
74
  "commander": "^9.0.0",
74
75
  "cors": "^2.8.5",
76
+ "dotenv": "^16.0.1",
75
77
  "esbuild": "^0.14.20",
76
78
  "esm": "3.2.25",
77
79
  "express": "^4.17.1",
@@ -82,6 +84,7 @@
82
84
  "lodash": "^4.17.19",
83
85
  "lodash.get": "^4.4.2",
84
86
  "log4js": "^6.4.0",
87
+ "multer": "^1.4.4",
85
88
  "normalize-path": "^3.0.0",
86
89
  "progress": "^2.0.3",
87
90
  "prompts": "^2.4.1",