@tinacms/cli 0.60.23 → 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 +22 -0
- package/dist/cmds/start-server/index.d.ts +13 -12
- package/dist/index.js +187 -73
- package/dist/server/models/media.d.ts +6 -4
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
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
|
+
|
|
3
25
|
## 0.60.23
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -1,25 +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
|
-
|
|
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
|
+
isomorphicGitBridge?: boolean;
|
|
18
19
|
noWatch?: boolean;
|
|
19
20
|
noSDK: boolean;
|
|
20
21
|
noTelemetry: boolean;
|
|
21
22
|
verbose?: boolean;
|
|
22
23
|
dev?: boolean;
|
|
23
24
|
}
|
|
24
|
-
export declare function startServer(_ctx: any, next: any, { port, noWatch, experimentalData, 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>;
|
|
25
26
|
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
|
|
63
|
+
var fs7 = require("fs");
|
|
64
64
|
var path4 = require("path");
|
|
65
|
-
var
|
|
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(
|
|
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(
|
|
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];
|
|
@@ -197,36 +197,61 @@ var init_media = __esm({
|
|
|
197
197
|
import_path6 = __toModule(require("path"));
|
|
198
198
|
init_utils();
|
|
199
199
|
MediaModel = class {
|
|
200
|
-
constructor({ publicFolder,
|
|
201
|
-
this.
|
|
200
|
+
constructor({ publicFolder, mediaRoot }) {
|
|
201
|
+
this.mediaRoot = mediaRoot;
|
|
202
202
|
this.publicFolder = publicFolder;
|
|
203
203
|
}
|
|
204
204
|
async listMedia(args) {
|
|
205
205
|
try {
|
|
206
|
-
const folderPath = (0, import_path6.join)(this.publicFolder, this.
|
|
206
|
+
const folderPath = (0, import_path6.join)(this.publicFolder, this.mediaRoot, args.searchPath);
|
|
207
207
|
const searchPath = parseMediaFolder(args.searchPath);
|
|
208
208
|
const filesStr = await import_fs_extra5.default.readdir(folderPath);
|
|
209
209
|
const filesProm = filesStr.map(async (file) => {
|
|
210
210
|
const filePath = (0, import_path6.join)(folderPath, file);
|
|
211
211
|
const stat = await import_fs_extra5.default.stat(filePath);
|
|
212
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
|
+
}
|
|
213
222
|
if (searchPath) {
|
|
214
223
|
src = `/${searchPath}${src}`;
|
|
215
224
|
}
|
|
216
|
-
if (this.
|
|
217
|
-
src = `/${this.
|
|
225
|
+
if (this.mediaRoot) {
|
|
226
|
+
src = `/${this.mediaRoot}${src}`;
|
|
218
227
|
}
|
|
219
228
|
return {
|
|
229
|
+
isFile,
|
|
220
230
|
size: stat.size,
|
|
221
|
-
fileName: file,
|
|
222
231
|
src,
|
|
223
|
-
|
|
232
|
+
filename: file
|
|
224
233
|
};
|
|
225
234
|
});
|
|
226
|
-
const
|
|
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;
|
|
227
251
|
return {
|
|
228
|
-
files
|
|
229
|
-
directories
|
|
252
|
+
files,
|
|
253
|
+
directories,
|
|
254
|
+
cursor
|
|
230
255
|
};
|
|
231
256
|
} catch (error) {
|
|
232
257
|
console.error(error);
|
|
@@ -239,7 +264,7 @@ var init_media = __esm({
|
|
|
239
264
|
}
|
|
240
265
|
async deleteMedia(args) {
|
|
241
266
|
try {
|
|
242
|
-
const file = (0, import_path6.join)(this.publicFolder, this.
|
|
267
|
+
const file = (0, import_path6.join)(this.publicFolder, this.mediaRoot, args.searchPath);
|
|
243
268
|
await import_fs_extra5.default.stat(file);
|
|
244
269
|
await import_fs_extra5.default.remove(file);
|
|
245
270
|
return { ok: true };
|
|
@@ -261,7 +286,7 @@ var init_routes = __esm({
|
|
|
261
286
|
import_multer = __toModule(require("multer"));
|
|
262
287
|
init_media();
|
|
263
288
|
createMediaRouter = (config) => {
|
|
264
|
-
const mediaFolder = (0, import_path7.join)(process.cwd(), config.publicFolder, config.
|
|
289
|
+
const mediaFolder = (0, import_path7.join)(process.cwd(), config.publicFolder, config.mediaRoot);
|
|
265
290
|
const storage = import_multer.default.diskStorage({
|
|
266
291
|
destination: function(req, file, cb) {
|
|
267
292
|
cb(null, mediaFolder);
|
|
@@ -276,18 +301,22 @@ var init_routes = __esm({
|
|
|
276
301
|
const mediaRouter = (0, import_express.Router)();
|
|
277
302
|
mediaRouter.get("/list/*", async (req, res) => {
|
|
278
303
|
const folder = req.params[0];
|
|
304
|
+
const cursor = req.query.cursor;
|
|
305
|
+
const limit = req.query.limit;
|
|
279
306
|
const media = await mediaModel.listMedia({
|
|
280
|
-
searchPath: folder
|
|
307
|
+
searchPath: folder,
|
|
308
|
+
cursor,
|
|
309
|
+
limit
|
|
281
310
|
});
|
|
282
311
|
res.json(media);
|
|
283
312
|
});
|
|
284
|
-
mediaRouter.delete("
|
|
313
|
+
mediaRouter.delete("/*", async (req, res) => {
|
|
285
314
|
const file = req.params[0];
|
|
286
315
|
const didDelete = await mediaModel.deleteMedia({ searchPath: file });
|
|
287
316
|
res.json(didDelete);
|
|
288
317
|
});
|
|
289
|
-
mediaRouter.post("/upload/*", upload.single("file"), function(req, res
|
|
290
|
-
res.json({
|
|
318
|
+
mediaRouter.post("/upload/*", upload.single("file"), function(req, res) {
|
|
319
|
+
res.json({ success: true });
|
|
291
320
|
});
|
|
292
321
|
return mediaRouter;
|
|
293
322
|
};
|
|
@@ -348,7 +377,7 @@ var init_server = __esm({
|
|
|
348
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) || {};
|
|
349
378
|
app.use("/media", createMediaRouter({
|
|
350
379
|
publicFolder: parseMediaFolder((mediaPaths == null ? void 0 : mediaPaths.publicFolder) || ""),
|
|
351
|
-
|
|
380
|
+
mediaRoot: parseMediaFolder((mediaPaths == null ? void 0 : mediaPaths.mediaRoot) || "")
|
|
352
381
|
}));
|
|
353
382
|
return server;
|
|
354
383
|
};
|
|
@@ -384,7 +413,7 @@ var commander = __toModule(require("commander"));
|
|
|
384
413
|
|
|
385
414
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/package.json
|
|
386
415
|
var name = "@tinacms/cli";
|
|
387
|
-
var version = "0.60.
|
|
416
|
+
var version = "0.60.24";
|
|
388
417
|
|
|
389
418
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/query-gen/attachSchema.ts
|
|
390
419
|
var import_graphql = __toModule(require("@tinacms/graphql"));
|
|
@@ -1904,13 +1933,77 @@ var AsyncLock = class {
|
|
|
1904
1933
|
var import_metrics3 = __toModule(require("@tinacms/metrics"));
|
|
1905
1934
|
var import_chalk6 = __toModule(require("chalk"));
|
|
1906
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"));
|
|
1907
1939
|
var import_path8 = __toModule(require("path"));
|
|
1908
1940
|
var lock = new AsyncLock();
|
|
1909
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
|
+
}
|
|
1910
2002
|
async function startServer(_ctx, next, {
|
|
1911
2003
|
port = 4001,
|
|
1912
2004
|
noWatch,
|
|
1913
2005
|
experimentalData,
|
|
2006
|
+
isomorphicGitBridge: isomorphicGitBridge2,
|
|
1914
2007
|
noSDK,
|
|
1915
2008
|
noTelemetry,
|
|
1916
2009
|
watchFolders,
|
|
@@ -1925,10 +2018,12 @@ async function startServer(_ctx, next, {
|
|
|
1925
2018
|
name: "tinacms:cli:server:start:invoke"
|
|
1926
2019
|
}
|
|
1927
2020
|
});
|
|
2021
|
+
const fsBridge = new import_datalayer3.FilesystemBridge(rootPath2);
|
|
2022
|
+
const isomorphicOptions = isomorphicGitBridge2 && await makeIsomorphicOptions(fsBridge);
|
|
1928
2023
|
if (!process.env.CI && !noWatch) {
|
|
1929
2024
|
await resetGeneratedFolder();
|
|
1930
2025
|
}
|
|
1931
|
-
const bridge = new import_datalayer3.
|
|
2026
|
+
const bridge = isomorphicGitBridge2 ? new import_datalayer3.IsomorphicBridge(rootPath2, isomorphicOptions) : fsBridge;
|
|
1932
2027
|
const store = experimentalData ? new import_datalayer3.LevelStore(rootPath2) : new import_datalayer3.FilesystemStore({ rootPath: rootPath2 });
|
|
1933
2028
|
const shouldBuild = bridge.supportsBuilding();
|
|
1934
2029
|
const database = await (0, import_graphql11.createDatabase)({ store, bridge });
|
|
@@ -1944,6 +2039,9 @@ async function startServer(_ctx, next, {
|
|
|
1944
2039
|
await store.open();
|
|
1945
2040
|
}
|
|
1946
2041
|
const cliFlags = [];
|
|
2042
|
+
if (isomorphicGitBridge2) {
|
|
2043
|
+
cliFlags.push("isomorphicGitBridge");
|
|
2044
|
+
}
|
|
1947
2045
|
const database2 = await (0, import_graphql11.createDatabase)({ store, bridge });
|
|
1948
2046
|
await compileSchema(null, null, { verbose, dev });
|
|
1949
2047
|
const schema = await (0, import_graphql11.buildSchema)(rootPath2, database2, cliFlags);
|
|
@@ -1955,50 +2053,6 @@ async function startServer(_ctx, next, {
|
|
|
1955
2053
|
lock.disable();
|
|
1956
2054
|
}
|
|
1957
2055
|
};
|
|
1958
|
-
const state = {
|
|
1959
|
-
server: null,
|
|
1960
|
-
sockets: []
|
|
1961
|
-
};
|
|
1962
|
-
let isReady = false;
|
|
1963
|
-
const start = async () => {
|
|
1964
|
-
await lock.promise;
|
|
1965
|
-
const s = (init_server3(), server_exports);
|
|
1966
|
-
state.server = await s.default(database);
|
|
1967
|
-
state.server.listen(port, () => {
|
|
1968
|
-
const altairUrl = `http://localhost:${port}/altair/`;
|
|
1969
|
-
const cmsUrl = `[your-development-url]/admin`;
|
|
1970
|
-
if (verbose)
|
|
1971
|
-
logger.info(`Started Filesystem GraphQL server on port: ${port}`);
|
|
1972
|
-
logger.info(`Visit the GraphQL playground at ${import_chalk6.default.underline.blueBright(altairUrl)}
|
|
1973
|
-
or`);
|
|
1974
|
-
logger.info(`Enter the CMS at ${import_chalk6.default.underline.blueBright(cmsUrl)}
|
|
1975
|
-
`);
|
|
1976
|
-
});
|
|
1977
|
-
state.server.on("error", function(e) {
|
|
1978
|
-
if (e.code === "EADDRINUSE") {
|
|
1979
|
-
logger.error(dangerText(`Port 4001 already in use`));
|
|
1980
|
-
process.exit();
|
|
1981
|
-
}
|
|
1982
|
-
throw e;
|
|
1983
|
-
});
|
|
1984
|
-
state.server.on("connection", (socket) => {
|
|
1985
|
-
state.sockets.push(socket);
|
|
1986
|
-
});
|
|
1987
|
-
};
|
|
1988
|
-
const restart = async () => {
|
|
1989
|
-
logger.info("restarting local server...");
|
|
1990
|
-
delete require.cache[gqlPackageFile];
|
|
1991
|
-
state.sockets.forEach((socket) => {
|
|
1992
|
-
if (socket.destroyed === false) {
|
|
1993
|
-
socket.destroy();
|
|
1994
|
-
}
|
|
1995
|
-
});
|
|
1996
|
-
state.sockets = [];
|
|
1997
|
-
state.server.close(() => {
|
|
1998
|
-
logger.info("Server closed");
|
|
1999
|
-
start();
|
|
2000
|
-
});
|
|
2001
|
-
};
|
|
2002
2056
|
const foldersToWatch = (watchFolders || []).map((x) => import_path8.default.join(rootPath2, x));
|
|
2003
2057
|
if (!noWatch && !process.env.CI) {
|
|
2004
2058
|
import_chokidar.default.watch([
|
|
@@ -2030,9 +2084,9 @@ or`);
|
|
|
2030
2084
|
try {
|
|
2031
2085
|
if (shouldBuild) {
|
|
2032
2086
|
await build2(noSDK);
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2087
|
+
}
|
|
2088
|
+
if (isReady) {
|
|
2089
|
+
await restart();
|
|
2036
2090
|
}
|
|
2037
2091
|
} catch (e) {
|
|
2038
2092
|
handleServerErrors(e);
|
|
@@ -2050,6 +2104,50 @@ or`);
|
|
|
2050
2104
|
await build2(noSDK);
|
|
2051
2105
|
}
|
|
2052
2106
|
}
|
|
2107
|
+
const state = {
|
|
2108
|
+
server: null,
|
|
2109
|
+
sockets: []
|
|
2110
|
+
};
|
|
2111
|
+
let isReady = false;
|
|
2112
|
+
const start = async () => {
|
|
2113
|
+
await lock.promise;
|
|
2114
|
+
const s = (init_server3(), server_exports);
|
|
2115
|
+
state.server = await s.default(database);
|
|
2116
|
+
state.server.listen(port, () => {
|
|
2117
|
+
const altairUrl = `http://localhost:${port}/altair/`;
|
|
2118
|
+
const cmsUrl = `[your-development-url]/admin`;
|
|
2119
|
+
if (verbose)
|
|
2120
|
+
logger.info(`Started Filesystem GraphQL server on port: ${port}`);
|
|
2121
|
+
logger.info(`Visit the GraphQL playground at ${import_chalk6.default.underline.blueBright(altairUrl)}
|
|
2122
|
+
or`);
|
|
2123
|
+
logger.info(`Enter the CMS at ${import_chalk6.default.underline.blueBright(cmsUrl)}
|
|
2124
|
+
`);
|
|
2125
|
+
});
|
|
2126
|
+
state.server.on("error", function(e) {
|
|
2127
|
+
if (e.code === "EADDRINUSE") {
|
|
2128
|
+
logger.error(dangerText(`Port 4001 already in use`));
|
|
2129
|
+
process.exit();
|
|
2130
|
+
}
|
|
2131
|
+
throw e;
|
|
2132
|
+
});
|
|
2133
|
+
state.server.on("connection", (socket) => {
|
|
2134
|
+
state.sockets.push(socket);
|
|
2135
|
+
});
|
|
2136
|
+
};
|
|
2137
|
+
const restart = async () => {
|
|
2138
|
+
logger.info("restarting local server...");
|
|
2139
|
+
delete require.cache[gqlPackageFile];
|
|
2140
|
+
state.sockets.forEach((socket) => {
|
|
2141
|
+
if (socket.destroyed === false) {
|
|
2142
|
+
socket.destroy();
|
|
2143
|
+
}
|
|
2144
|
+
});
|
|
2145
|
+
state.sockets = [];
|
|
2146
|
+
state.server.close(() => {
|
|
2147
|
+
logger.info("Server closed");
|
|
2148
|
+
start();
|
|
2149
|
+
});
|
|
2150
|
+
};
|
|
2053
2151
|
if (!noWatch && !process.env.CI) {
|
|
2054
2152
|
import_chokidar.default.watch([gqlPackageFile]).on("ready", async () => {
|
|
2055
2153
|
isReady = true;
|
|
@@ -2182,6 +2280,10 @@ var experimentalDatalayer = {
|
|
|
2182
2280
|
name: "--experimentalData",
|
|
2183
2281
|
description: "Build the server with additional data querying capabilities"
|
|
2184
2282
|
};
|
|
2283
|
+
var isomorphicGitBridge = {
|
|
2284
|
+
name: "--isomorphicGitBridge",
|
|
2285
|
+
description: "Enable Isomorphic Git Bridge Implementation"
|
|
2286
|
+
};
|
|
2185
2287
|
var schemaFileType = {
|
|
2186
2288
|
name: "--schemaFileType [fileType]",
|
|
2187
2289
|
description: "The file type to use for the Tina schema"
|
|
@@ -2231,6 +2333,7 @@ var baseCmds = [
|
|
|
2231
2333
|
startServerPortOption,
|
|
2232
2334
|
subCommand,
|
|
2233
2335
|
experimentalDatalayer,
|
|
2336
|
+
isomorphicGitBridge,
|
|
2234
2337
|
noWatchOption,
|
|
2235
2338
|
noSDKCodegenOption,
|
|
2236
2339
|
noTelemetryOption,
|
|
@@ -2246,6 +2349,7 @@ var baseCmds = [
|
|
|
2246
2349
|
options: [
|
|
2247
2350
|
subCommand,
|
|
2248
2351
|
experimentalDatalayer,
|
|
2352
|
+
isomorphicGitBridge,
|
|
2249
2353
|
noTelemetryOption,
|
|
2250
2354
|
verboseOption,
|
|
2251
2355
|
developmentOption
|
|
@@ -2255,18 +2359,28 @@ var baseCmds = [
|
|
|
2255
2359
|
{
|
|
2256
2360
|
command: CMD_COMPILE_MODELS,
|
|
2257
2361
|
description: "Compile schema into static files for the server",
|
|
2258
|
-
options: [experimentalDatalayer, noTelemetryOption],
|
|
2362
|
+
options: [experimentalDatalayer, isomorphicGitBridge, noTelemetryOption],
|
|
2259
2363
|
action: (options) => chain([compileSchema], options)
|
|
2260
2364
|
},
|
|
2261
2365
|
{
|
|
2262
2366
|
command: CMD_GEN_TYPES,
|
|
2263
2367
|
description: "Generate a GraphQL query for your site's schema, (and optionally Typescript types)",
|
|
2264
|
-
options: [
|
|
2368
|
+
options: [
|
|
2369
|
+
experimentalDatalayer,
|
|
2370
|
+
isomorphicGitBridge,
|
|
2371
|
+
noSDKCodegenOption,
|
|
2372
|
+
noTelemetryOption
|
|
2373
|
+
],
|
|
2265
2374
|
action: (options) => chain([attachSchema, genTypes], options)
|
|
2266
2375
|
},
|
|
2267
2376
|
{
|
|
2268
2377
|
command: INIT,
|
|
2269
|
-
options: [
|
|
2378
|
+
options: [
|
|
2379
|
+
experimentalDatalayer,
|
|
2380
|
+
isomorphicGitBridge,
|
|
2381
|
+
noTelemetryOption,
|
|
2382
|
+
schemaFileType
|
|
2383
|
+
],
|
|
2270
2384
|
description: "Add Tina Cloud to an existing project",
|
|
2271
2385
|
action: (options) => chain([
|
|
2272
2386
|
checkDeps,
|
|
@@ -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
|
-
|
|
20
|
+
filename: string;
|
|
19
21
|
size: number;
|
|
20
22
|
}
|
|
21
23
|
interface ListMediaRes {
|
|
@@ -26,7 +28,7 @@ interface ListMediaRes {
|
|
|
26
28
|
}
|
|
27
29
|
export interface PathConfig {
|
|
28
30
|
publicFolder: string;
|
|
29
|
-
|
|
31
|
+
mediaRoot: string;
|
|
30
32
|
}
|
|
31
33
|
declare type SuccessRecord = {
|
|
32
34
|
ok: true;
|
|
@@ -36,8 +38,8 @@ declare type SuccessRecord = {
|
|
|
36
38
|
};
|
|
37
39
|
export declare class MediaModel {
|
|
38
40
|
readonly publicFolder: string;
|
|
39
|
-
readonly
|
|
40
|
-
constructor({ publicFolder,
|
|
41
|
+
readonly mediaRoot: string;
|
|
42
|
+
constructor({ publicFolder, mediaRoot }: PathConfig);
|
|
41
43
|
listMedia(args: MediaArgs): Promise<ListMediaRes>;
|
|
42
44
|
deleteMedia(args: MediaArgs): Promise<SuccessRecord>;
|
|
43
45
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/cli",
|
|
3
|
-
"version": "0.60.
|
|
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.
|
|
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.
|
|
62
|
-
"@tinacms/graphql": "0.
|
|
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.
|
|
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",
|