@tinacms/cli 0.60.21 → 0.60.24

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,49 @@
1
1
  # tinacms-cli
2
2
 
3
+ ## 0.60.24
4
+
5
+ ### Patch Changes
6
+
7
+ - 2ef5a1f33: Use media config from the schema in the local media server
8
+ - 2ef5a1f33: Uses new `schema.config` when resolving media/asset urls
9
+ - b348f8b6b: Experimental isomorphic git bridge implementation
10
+ - b46e9a481: Fixed issue where child process would start before parent
11
+ - fb73fb355: Renames syncFolder to a mediaRoot when configuring Repo-Based Media
12
+ - 7b77fe1b5: Add a default TinaMediaStore for repo-based media
13
+ - 3e4b3ea7e: media manage uses relieve dir paths
14
+ - 99a13024d: Enables paging for local media manager
15
+ - Updated dependencies [2ef5a1f33]
16
+ - Updated dependencies [2ef5a1f33]
17
+ - Updated dependencies [b348f8b6b]
18
+ - Updated dependencies [fb73fb355]
19
+ - Updated dependencies [4daf15b36]
20
+ - @tinacms/graphql@0.61.0
21
+ - @tinacms/datalayer@0.2.0
22
+ - @tinacms/schema-tools@0.0.6
23
+ - @tinacms/metrics@0.0.3
24
+
25
+ ## 0.60.23
26
+
27
+ ### Patch Changes
28
+
29
+ - Updated dependencies [3325cd226]
30
+ - @tinacms/graphql@0.60.8
31
+
32
+ ## 0.60.22
33
+
34
+ ### Patch Changes
35
+
36
+ - b1a4290e6: Use media config from the schema in the local media server
37
+ - 1955b8842: Uses new `schema.config` when resolving media/asset urls
38
+ - Updated dependencies [f6cb634c2]
39
+ - Updated dependencies [b1a4290e6]
40
+ - Updated dependencies [1955b8842]
41
+ - Updated dependencies [8b81c3cf3]
42
+ - @tinacms/graphql@0.60.7
43
+ - @tinacms/schema-tools@0.0.5
44
+ - @tinacms/datalayer@0.1.1
45
+ - @tinacms/metrics@0.0.3
46
+
3
47
  ## 0.60.21
4
48
 
5
49
  ### Patch Changes
@@ -1,26 +1,26 @@
1
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
- */
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
13
  interface Options {
14
14
  port?: number;
15
15
  command?: string;
16
16
  watchFolders?: string[];
17
17
  experimentalData?: boolean;
18
- tinaCloudMediaStore?: boolean;
18
+ isomorphicGitBridge?: boolean;
19
19
  noWatch?: boolean;
20
20
  noSDK: boolean;
21
21
  noTelemetry: boolean;
22
22
  verbose?: boolean;
23
23
  dev?: boolean;
24
24
  }
25
- export declare function startServer(_ctx: any, next: any, { port, noWatch, experimentalData, tinaCloudMediaStore, noSDK, noTelemetry, watchFolders, verbose, dev, }: Options): Promise<void>;
25
+ export declare function startServer(_ctx: any, next: any, { port, noWatch, experimentalData, isomorphicGitBridge, noSDK, noTelemetry, watchFolders, verbose, dev, }: Options): Promise<void>;
26
26
  export {};
package/dist/command.d.ts CHANGED
@@ -23,5 +23,6 @@ export interface Command {
23
23
  interface Option {
24
24
  name: string;
25
25
  description: string;
26
+ defaultValue?: any;
26
27
  }
27
28
  export {};
package/dist/index.js CHANGED
@@ -60,9 +60,9 @@ var __toModule = (module2) => {
60
60
  // pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/dotenv-npm-16.0.1-d99e72bb95-e97e94476c.zip/node_modules/dotenv/lib/main.js
61
61
  var require_main = __commonJS({
62
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");
63
+ var fs7 = require("fs");
64
64
  var path4 = require("path");
65
- var os = require("os");
65
+ var os2 = require("os");
66
66
  var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
67
67
  function parse2(src) {
68
68
  const obj = {};
@@ -87,7 +87,7 @@ var require_main = __commonJS({
87
87
  console.log(`[dotenv][DEBUG] ${message}`);
88
88
  }
89
89
  function _resolveHome(envPath) {
90
- return envPath[0] === "~" ? path4.join(os.homedir(), envPath.slice(1)) : envPath;
90
+ return envPath[0] === "~" ? path4.join(os2.homedir(), envPath.slice(1)) : envPath;
91
91
  }
92
92
  function config(options) {
93
93
  let dotenvPath = path4.resolve(process.cwd(), ".env");
@@ -103,7 +103,7 @@ var require_main = __commonJS({
103
103
  }
104
104
  }
105
105
  try {
106
- const parsed = DotenvModule.parse(fs6.readFileSync(dotenvPath, { encoding }));
106
+ const parsed = DotenvModule.parse(fs7.readFileSync(dotenvPath, { encoding }));
107
107
  Object.keys(parsed).forEach(function(key) {
108
108
  if (!Object.prototype.hasOwnProperty.call(process.env, key)) {
109
109
  process.env[key] = parsed[key];
@@ -174,35 +174,84 @@ var require_cli_options = __commonJS({
174
174
  }
175
175
  });
176
176
 
177
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/utils/index.ts
178
+ var parseMediaFolder;
179
+ var init_utils = __esm({
180
+ "pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/utils/index.ts"() {
181
+ parseMediaFolder = (str) => {
182
+ let returnString = str;
183
+ if (returnString.startsWith("/"))
184
+ returnString = returnString.substr(1);
185
+ if (returnString.endsWith("/"))
186
+ returnString = returnString.substr(0, returnString.length - 1);
187
+ return returnString;
188
+ };
189
+ }
190
+ });
191
+
177
192
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/server/models/media.ts
178
193
  var import_fs_extra5, import_path6, MediaModel;
179
194
  var init_media = __esm({
180
195
  "pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/server/models/media.ts"() {
181
196
  import_fs_extra5 = __toModule(require("fs-extra"));
182
197
  import_path6 = __toModule(require("path"));
198
+ init_utils();
183
199
  MediaModel = class {
184
- constructor({ basePath }) {
185
- this.basePath = basePath;
200
+ constructor({ publicFolder, mediaRoot }) {
201
+ this.mediaRoot = mediaRoot;
202
+ this.publicFolder = publicFolder;
186
203
  }
187
204
  async listMedia(args) {
188
205
  try {
189
- const folderPath = (0, import_path6.join)(this.basePath, args.searchPath);
206
+ const folderPath = (0, import_path6.join)(this.publicFolder, this.mediaRoot, args.searchPath);
207
+ const searchPath = parseMediaFolder(args.searchPath);
190
208
  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);
209
+ const filesProm = filesStr.map(async (file) => {
210
+ const filePath = (0, import_path6.join)(folderPath, file);
193
211
  const stat = await import_fs_extra5.default.stat(filePath);
194
- const src = (0, import_path6.join)(args.searchPath, x);
212
+ let src = `/${file}`;
213
+ const isFile = stat.isFile();
214
+ if (!isFile) {
215
+ return {
216
+ isFile,
217
+ size: stat.size,
218
+ src,
219
+ filename: file
220
+ };
221
+ }
222
+ if (searchPath) {
223
+ src = `/${searchPath}${src}`;
224
+ }
225
+ if (this.mediaRoot) {
226
+ src = `/${this.mediaRoot}${src}`;
227
+ }
195
228
  return {
229
+ isFile,
196
230
  size: stat.size,
197
- fileName: x,
198
- src: "/" + src,
199
- isFile: stat.isFile()
231
+ src,
232
+ filename: file
200
233
  };
201
234
  });
202
- const files = await Promise.all(filesProm);
235
+ const offset = Number(args.cursor) || 0;
236
+ const limit = Number(args.limit) || 20;
237
+ const rawItems = await Promise.all(filesProm);
238
+ const sortedItems = rawItems.sort((a, b) => {
239
+ if (a.isFile && !b.isFile) {
240
+ return 1;
241
+ }
242
+ if (!a.isFile && b.isFile) {
243
+ return -1;
244
+ }
245
+ return 0;
246
+ });
247
+ const limitItems = sortedItems.slice(offset, offset + limit);
248
+ const files = limitItems.filter((x) => x.isFile);
249
+ const directories = limitItems.filter((x) => !x.isFile).map((x) => x.src);
250
+ const cursor = rawItems.length > offset + limit ? String(offset + limit) : null;
203
251
  return {
204
- files: files.filter((x) => x.isFile),
205
- directories: files.filter((x) => !x.isFile).map((x) => x.src)
252
+ files,
253
+ directories,
254
+ cursor
206
255
  };
207
256
  } catch (error) {
208
257
  console.error(error);
@@ -215,7 +264,7 @@ var init_media = __esm({
215
264
  }
216
265
  async deleteMedia(args) {
217
266
  try {
218
- const file = (0, import_path6.join)(this.basePath, args.searchPath);
267
+ const file = (0, import_path6.join)(this.publicFolder, this.mediaRoot, args.searchPath);
219
268
  await import_fs_extra5.default.stat(file);
220
269
  await import_fs_extra5.default.remove(file);
221
270
  return { ok: true };
@@ -229,41 +278,48 @@ var init_media = __esm({
229
278
  });
230
279
 
231
280
  // 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;
281
+ var import_express, import_path7, import_multer, createMediaRouter;
233
282
  var init_routes = __esm({
234
283
  "pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/server/routes/index.ts"() {
235
284
  import_express = __toModule(require("express"));
236
285
  import_path7 = __toModule(require("path"));
237
286
  import_multer = __toModule(require("multer"));
238
287
  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) {
288
+ createMediaRouter = (config) => {
289
+ const mediaFolder = (0, import_path7.join)(process.cwd(), config.publicFolder, config.mediaRoot);
290
+ const storage = import_multer.default.diskStorage({
291
+ destination: function(req, file, cb) {
292
+ cb(null, mediaFolder);
293
+ },
294
+ filename: function(req, _file, cb) {
295
+ const file = req.params[0];
296
+ cb(null, file);
297
+ }
298
+ });
299
+ const upload = (0, import_multer.default)({ storage });
300
+ const mediaModel = new MediaModel(config);
301
+ const mediaRouter = (0, import_express.Router)();
302
+ mediaRouter.get("/list/*", async (req, res) => {
303
+ const folder = req.params[0];
304
+ const cursor = req.query.cursor;
305
+ const limit = req.query.limit;
306
+ const media = await mediaModel.listMedia({
307
+ searchPath: folder,
308
+ cursor,
309
+ limit
310
+ });
311
+ res.json(media);
312
+ });
313
+ mediaRouter.delete("/*", async (req, res) => {
245
314
  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
315
+ const didDelete = await mediaModel.deleteMedia({ searchPath: file });
316
+ res.json(didDelete);
256
317
  });
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
- });
318
+ mediaRouter.post("/upload/*", upload.single("file"), function(req, res) {
319
+ res.json({ success: true });
320
+ });
321
+ return mediaRouter;
322
+ };
267
323
  }
268
324
  });
269
325
 
@@ -277,7 +333,9 @@ var init_server = __esm({
277
333
  import_altair_express_middleware = __toModule(require("altair-express-middleware"));
278
334
  import_body_parser = __toModule(require("body-parser"));
279
335
  init_routes();
280
- gqlServer = async (database) => {
336
+ init_utils();
337
+ gqlServer = async (database, verbose) => {
338
+ var _a, _b, _c;
281
339
  const gqlPackage = require("@tinacms/graphql");
282
340
  const app = (0, import_express2.default)();
283
341
  const server = import_http.default.createServer(app);
@@ -309,11 +367,18 @@ var init_server = __esm({
309
367
  config,
310
368
  database,
311
369
  query,
312
- variables
370
+ variables,
371
+ verbose
313
372
  });
314
373
  return res.json(result);
315
374
  });
316
- app.use("/media", mediaRouter);
375
+ const db = database;
376
+ const schema = await db.getSchema();
377
+ const mediaPaths = ((_c = (_b = (_a = schema == null ? void 0 : schema.schema) == null ? void 0 : _a.config) == null ? void 0 : _b.media) == null ? void 0 : _c.tina) || {};
378
+ app.use("/media", createMediaRouter({
379
+ publicFolder: parseMediaFolder((mediaPaths == null ? void 0 : mediaPaths.publicFolder) || ""),
380
+ mediaRoot: parseMediaFolder((mediaPaths == null ? void 0 : mediaPaths.mediaRoot) || "")
381
+ }));
317
382
  return server;
318
383
  };
319
384
  }
@@ -348,7 +413,7 @@ var commander = __toModule(require("commander"));
348
413
 
349
414
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/package.json
350
415
  var name = "@tinacms/cli";
351
- var version = "0.60.21";
416
+ var version = "0.60.24";
352
417
 
353
418
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/query-gen/attachSchema.ts
354
419
  var import_graphql = __toModule(require("@tinacms/graphql"));
@@ -753,7 +818,8 @@ var auditDocuments = async (args) => {
753
818
  collection: collection.name,
754
819
  relativePath: node._sys.relativePath
755
820
  },
756
- silenceErrors: true
821
+ silenceErrors: true,
822
+ verbose: true
757
823
  });
758
824
  if (mutationRes.errors) {
759
825
  mutationRes.errors.forEach((err) => {
@@ -1487,6 +1553,7 @@ var chain = async (cmds, options) => {
1487
1553
  var import_chalk7 = __toModule(require("chalk"));
1488
1554
 
1489
1555
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/start-server/errors/index.ts
1556
+ var import_graphql10 = __toModule(require("@tinacms/graphql"));
1490
1557
  var BuildSchemaError = class extends Error {
1491
1558
  constructor(message) {
1492
1559
  super(message);
@@ -1512,6 +1579,8 @@ var handleServerErrors = (e) => {
1512
1579
  logger.error(`${dangerText("ERROR: your schema was not successfully validated: see https://tina.io/docs/schema/ for instructions on how to setup a schema")}
1513
1580
  Error Message Below
1514
1581
  ${e}`);
1582
+ } else if (e instanceof import_graphql10.TinaFetchError) {
1583
+ (0, import_graphql10.handleFetchErrorError)(e, true);
1515
1584
  } else {
1516
1585
  logger.info(dangerText("Compilation failed with errors. Server has not been restarted.") + ` see error below
1517
1586
  ${e.message}`);
@@ -1846,7 +1915,7 @@ var loaders = {
1846
1915
 
1847
1916
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/start-server/index.ts
1848
1917
  var import_datalayer3 = __toModule(require("@tinacms/datalayer"));
1849
- var import_graphql10 = __toModule(require("@tinacms/graphql"));
1918
+ var import_graphql11 = __toModule(require("@tinacms/graphql"));
1850
1919
 
1851
1920
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/start-server/lock.ts
1852
1921
  var AsyncLock = class {
@@ -1864,14 +1933,77 @@ var AsyncLock = class {
1864
1933
  var import_metrics3 = __toModule(require("@tinacms/metrics"));
1865
1934
  var import_chalk6 = __toModule(require("chalk"));
1866
1935
  var import_chokidar = __toModule(require("chokidar"));
1936
+ var import_fs_extra6 = __toModule(require("fs-extra"));
1937
+ var import_ini = __toModule(require("ini"));
1938
+ var import_os = __toModule(require("os"));
1867
1939
  var import_path8 = __toModule(require("path"));
1868
1940
  var lock = new AsyncLock();
1869
1941
  var gqlPackageFile = require.resolve("@tinacms/graphql");
1942
+ var resolveGitRoot = async () => {
1943
+ const pathParts = process.cwd().split(import_path8.default.sep);
1944
+ while (true) {
1945
+ const pathToGit = pathParts.join(import_path8.default.sep);
1946
+ if (await import_fs_extra6.default.pathExists(import_path8.default.join(pathToGit, ".git"))) {
1947
+ return pathToGit;
1948
+ }
1949
+ if (!pathParts.length) {
1950
+ throw new Error("Unable to locate your .git folder (required for isomorphicGitBridge)");
1951
+ }
1952
+ pathParts.pop();
1953
+ }
1954
+ };
1955
+ async function makeIsomorphicOptions(fsBridge) {
1956
+ var _a, _b, _c, _d;
1957
+ const gitRoot = await resolveGitRoot();
1958
+ const options = {
1959
+ gitRoot,
1960
+ author: {
1961
+ name: "",
1962
+ email: ""
1963
+ },
1964
+ onPut: async (filepath, data) => {
1965
+ await fsBridge.put(filepath, data);
1966
+ },
1967
+ onDelete: async (filepath) => {
1968
+ await fsBridge.delete(filepath);
1969
+ }
1970
+ };
1971
+ const userGitConfig = `${import_os.default.homedir()}${import_path8.default.sep}.gitconfig`;
1972
+ if (await import_fs_extra6.default.pathExists(userGitConfig)) {
1973
+ const config = import_ini.default.parse(await import_fs_extra6.default.readFile(userGitConfig, "utf-8"));
1974
+ if ((_a = config["user"]) == null ? void 0 : _a["name"]) {
1975
+ options.author.name = config["user"]["name"];
1976
+ }
1977
+ if ((_b = config["user"]) == null ? void 0 : _b["email"]) {
1978
+ options.author.email = config["user"]["email"];
1979
+ }
1980
+ }
1981
+ let repoGitConfig = void 0;
1982
+ if (!options.author.name) {
1983
+ repoGitConfig = import_ini.default.parse(await import_fs_extra6.default.readFile(`${gitRoot}/.git/config`, "utf-8"));
1984
+ if ((_c = repoGitConfig["user"]) == null ? void 0 : _c["name"]) {
1985
+ options.author.name = repoGitConfig["user"]["name"];
1986
+ }
1987
+ if (!options.author.name) {
1988
+ throw new Error('Unable to determine user.name from git config. Hint: `git config --global user.name "John Doe"`');
1989
+ }
1990
+ }
1991
+ if (!options.author.email) {
1992
+ repoGitConfig = repoGitConfig || import_ini.default.parse(await import_fs_extra6.default.readFile(`${gitRoot}/.git/config`, "utf-8"));
1993
+ if ((_d = repoGitConfig["user"]) == null ? void 0 : _d["email"]) {
1994
+ options.author.email = repoGitConfig["user"]["email"];
1995
+ }
1996
+ if (!options.author.email) {
1997
+ throw new Error("Unable to determine user.email from git config. Hint: `git config --global user.email johndoe@example.com`");
1998
+ }
1999
+ }
2000
+ return options;
2001
+ }
1870
2002
  async function startServer(_ctx, next, {
1871
2003
  port = 4001,
1872
2004
  noWatch,
1873
2005
  experimentalData,
1874
- tinaCloudMediaStore: tinaCloudMediaStore2,
2006
+ isomorphicGitBridge: isomorphicGitBridge2,
1875
2007
  noSDK,
1876
2008
  noTelemetry,
1877
2009
  watchFolders,
@@ -1886,13 +2018,15 @@ async function startServer(_ctx, next, {
1886
2018
  name: "tinacms:cli:server:start:invoke"
1887
2019
  }
1888
2020
  });
2021
+ const fsBridge = new import_datalayer3.FilesystemBridge(rootPath2);
2022
+ const isomorphicOptions = isomorphicGitBridge2 && await makeIsomorphicOptions(fsBridge);
1889
2023
  if (!process.env.CI && !noWatch) {
1890
2024
  await resetGeneratedFolder();
1891
2025
  }
1892
- const bridge = new import_datalayer3.FilesystemBridge(rootPath2);
2026
+ const bridge = isomorphicGitBridge2 ? new import_datalayer3.IsomorphicBridge(rootPath2, isomorphicOptions) : fsBridge;
1893
2027
  const store = experimentalData ? new import_datalayer3.LevelStore(rootPath2) : new import_datalayer3.FilesystemStore({ rootPath: rootPath2 });
1894
2028
  const shouldBuild = bridge.supportsBuilding();
1895
- const database = await (0, import_graphql10.createDatabase)({ store, bridge });
2029
+ const database = await (0, import_graphql11.createDatabase)({ store, bridge });
1896
2030
  let ready = false;
1897
2031
  const build2 = async (noSDK2) => {
1898
2032
  database.clearCache();
@@ -1905,12 +2039,12 @@ async function startServer(_ctx, next, {
1905
2039
  await store.open();
1906
2040
  }
1907
2041
  const cliFlags = [];
1908
- if (tinaCloudMediaStore2) {
1909
- cliFlags.push("tinaCloudMediaStore");
2042
+ if (isomorphicGitBridge2) {
2043
+ cliFlags.push("isomorphicGitBridge");
1910
2044
  }
1911
- const database2 = await (0, import_graphql10.createDatabase)({ store, bridge });
2045
+ const database2 = await (0, import_graphql11.createDatabase)({ store, bridge });
1912
2046
  await compileSchema(null, null, { verbose, dev });
1913
- const schema = await (0, import_graphql10.buildSchema)(rootPath2, database2, cliFlags);
2047
+ const schema = await (0, import_graphql11.buildSchema)(rootPath2, database2, cliFlags);
1914
2048
  await genTypes({ schema }, () => {
1915
2049
  }, { noSDK: noSDK2, verbose });
1916
2050
  } catch (error) {
@@ -1951,6 +2085,9 @@ async function startServer(_ctx, next, {
1951
2085
  if (shouldBuild) {
1952
2086
  await build2(noSDK);
1953
2087
  }
2088
+ if (isReady) {
2089
+ await restart();
2090
+ }
1954
2091
  } catch (e) {
1955
2092
  handleServerErrors(e);
1956
2093
  t.submitRecord({
@@ -1973,6 +2110,7 @@ async function startServer(_ctx, next, {
1973
2110
  };
1974
2111
  let isReady = false;
1975
2112
  const start = async () => {
2113
+ await lock.promise;
1976
2114
  const s = (init_server3(), server_exports);
1977
2115
  state.server = await s.default(database);
1978
2116
  state.server.listen(port, () => {
@@ -1997,7 +2135,7 @@ or`);
1997
2135
  });
1998
2136
  };
1999
2137
  const restart = async () => {
2000
- logger.info("Detected change to gql package, restarting...");
2138
+ logger.info("restarting local server...");
2001
2139
  delete require.cache[gqlPackageFile];
2002
2140
  state.sockets.forEach((socket) => {
2003
2141
  if (socket.destroyed === false) {
@@ -2142,6 +2280,10 @@ var experimentalDatalayer = {
2142
2280
  name: "--experimentalData",
2143
2281
  description: "Build the server with additional data querying capabilities"
2144
2282
  };
2283
+ var isomorphicGitBridge = {
2284
+ name: "--isomorphicGitBridge",
2285
+ description: "Enable Isomorphic Git Bridge Implementation"
2286
+ };
2145
2287
  var schemaFileType = {
2146
2288
  name: "--schemaFileType [fileType]",
2147
2289
  description: "The file type to use for the Tina schema"
@@ -2176,11 +2318,8 @@ var watchFileOption = {
2176
2318
  };
2177
2319
  var verboseOption = {
2178
2320
  name: "-v, --verbose",
2179
- description: "increase verbosity of logged output"
2180
- };
2181
- var tinaCloudMediaStore = {
2182
- name: "--tinaCloudMediaStore",
2183
- description: "Automatically pushes updates from GitHub to the Tina Cloud Media Store"
2321
+ description: "increase verbosity of logged output",
2322
+ defaultValue: false
2184
2323
  };
2185
2324
  var developmentOption = {
2186
2325
  name: "--dev",
@@ -2194,7 +2333,7 @@ var baseCmds = [
2194
2333
  startServerPortOption,
2195
2334
  subCommand,
2196
2335
  experimentalDatalayer,
2197
- tinaCloudMediaStore,
2336
+ isomorphicGitBridge,
2198
2337
  noWatchOption,
2199
2338
  noSDKCodegenOption,
2200
2339
  noTelemetryOption,
@@ -2210,6 +2349,7 @@ var baseCmds = [
2210
2349
  options: [
2211
2350
  subCommand,
2212
2351
  experimentalDatalayer,
2352
+ isomorphicGitBridge,
2213
2353
  noTelemetryOption,
2214
2354
  verboseOption,
2215
2355
  developmentOption
@@ -2219,7 +2359,7 @@ var baseCmds = [
2219
2359
  {
2220
2360
  command: CMD_COMPILE_MODELS,
2221
2361
  description: "Compile schema into static files for the server",
2222
- options: [experimentalDatalayer, tinaCloudMediaStore, noTelemetryOption],
2362
+ options: [experimentalDatalayer, isomorphicGitBridge, noTelemetryOption],
2223
2363
  action: (options) => chain([compileSchema], options)
2224
2364
  },
2225
2365
  {
@@ -2227,7 +2367,7 @@ var baseCmds = [
2227
2367
  description: "Generate a GraphQL query for your site's schema, (and optionally Typescript types)",
2228
2368
  options: [
2229
2369
  experimentalDatalayer,
2230
- tinaCloudMediaStore,
2370
+ isomorphicGitBridge,
2231
2371
  noSDKCodegenOption,
2232
2372
  noTelemetryOption
2233
2373
  ],
@@ -2237,7 +2377,7 @@ var baseCmds = [
2237
2377
  command: INIT,
2238
2378
  options: [
2239
2379
  experimentalDatalayer,
2240
- tinaCloudMediaStore,
2380
+ isomorphicGitBridge,
2241
2381
  noTelemetryOption,
2242
2382
  schemaFileType
2243
2383
  ],
@@ -2311,7 +2451,7 @@ Examples:
2311
2451
  logger.info("");
2312
2452
  });
2313
2453
  (command.options || []).forEach((option) => {
2314
- newCmd.option(option.name, option.description);
2454
+ newCmd.option(option.name, option.description, option == null ? void 0 : option.defaultValue);
2315
2455
  });
2316
2456
  if (command.subCommands) {
2317
2457
  registerCommands(command.subCommands, true);
@@ -12,10 +12,12 @@ limitations under the License.
12
12
  */
13
13
  interface MediaArgs {
14
14
  searchPath: string;
15
+ cursor?: string;
16
+ limit?: string;
15
17
  }
16
18
  interface File {
17
19
  src: string;
18
- fileName: string;
20
+ filename: string;
19
21
  size: number;
20
22
  }
21
23
  interface ListMediaRes {
@@ -24,6 +26,10 @@ interface ListMediaRes {
24
26
  cursor?: string;
25
27
  error?: string;
26
28
  }
29
+ export interface PathConfig {
30
+ publicFolder: string;
31
+ mediaRoot: string;
32
+ }
27
33
  declare type SuccessRecord = {
28
34
  ok: true;
29
35
  } | {
@@ -31,10 +37,9 @@ declare type SuccessRecord = {
31
37
  message: string;
32
38
  };
33
39
  export declare class MediaModel {
34
- readonly basePath: string;
35
- constructor({ basePath }: {
36
- basePath: string;
37
- });
40
+ readonly publicFolder: string;
41
+ readonly mediaRoot: string;
42
+ constructor({ publicFolder, mediaRoot }: PathConfig);
38
43
  listMedia(args: MediaArgs): Promise<ListMediaRes>;
39
44
  deleteMedia(args: MediaArgs): Promise<SuccessRecord>;
40
45
  }
@@ -10,4 +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
- export declare const mediaRouter: import("express-serve-static-core").Router;
13
+ import { PathConfig } from '../models/media';
14
+ export declare const createMediaRouter: (config: PathConfig) => import("express-serve-static-core").Router;
@@ -12,4 +12,4 @@ limitations under the License.
12
12
  */
13
13
  /// <reference types="node" />
14
14
  import http from 'http';
15
- export declare const gqlServer: (database: any) => Promise<http.Server>;
15
+ export declare const gqlServer: (database: any, verbose: boolean) => Promise<http.Server>;
@@ -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 parseMediaFolder: (str: string) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/cli",
3
- "version": "0.60.21",
3
+ "version": "0.60.24",
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.7",
24
+ "@tinacms/scripts": "0.50.9",
25
25
  "@types/clear": "0.1.0",
26
26
  "@types/cors": "2.8.5",
27
27
  "@types/express": "^4.17.7",
@@ -58,10 +58,10 @@
58
58
  "@graphql-codegen/visitor-plugin-common": "^2.4.0",
59
59
  "@graphql-tools/graphql-file-loader": "^7.2.0",
60
60
  "@graphql-tools/load": "^7.3.2",
61
- "@tinacms/datalayer": "0.1.1",
62
- "@tinacms/graphql": "0.60.6",
61
+ "@tinacms/datalayer": "0.2.0",
62
+ "@tinacms/graphql": "0.61.0",
63
63
  "@tinacms/metrics": "0.0.3",
64
- "@tinacms/schema-tools": "0.0.4",
64
+ "@tinacms/schema-tools": "0.0.6",
65
65
  "@yarnpkg/esbuild-plugin-pnp": "^2.0.1-rc.3",
66
66
  "add": "^2.0.6",
67
67
  "ajv": "^6.12.3",
@@ -80,6 +80,7 @@
80
80
  "fast-glob": "^3.2.4",
81
81
  "fs-extra": "^9.0.1",
82
82
  "graphql": "^15.1.0",
83
+ "ini": "^3.0.0",
83
84
  "js-yaml": "^4.0.0",
84
85
  "lodash": "^4.17.19",
85
86
  "lodash.get": "^4.4.2",