@tinacms/cli 0.60.16 → 0.60.19
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 +36 -0
- package/dist/cmds/baseCmds.d.ts +2 -0
- package/dist/cmds/compile/defaultSchema.d.ts +1 -1
- package/dist/cmds/compile/index.d.ts +6 -1
- package/dist/cmds/start-server/index.d.ts +3 -1
- package/dist/cmds/start-server/server.d.ts +1 -3
- package/dist/cmds/startSubprocess/index.d.ts +17 -0
- package/dist/cmds/waitForDB/index.d.ts +15 -0
- package/dist/index.js +547 -104
- package/dist/lib/{getSchemaPath.d.ts → getPath.d.ts} +3 -0
- package/dist/lib/index.d.ts +1 -1
- package/dist/server/index.d.ts +13 -0
- package/dist/server/models/media.d.ts +41 -0
- package/dist/server/routes/index.d.ts +13 -0
- package/dist/server/server.d.ts +15 -0
- package/package.json +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# tinacms-cli
|
|
2
2
|
|
|
3
|
+
## 0.60.19
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d103b27ad: Fix issue where new collections would not be added when CLI restarts
|
|
8
|
+
- e06dbb3ca: Adds `waitForDB` cmd to cli
|
|
9
|
+
- Updated dependencies [d103b27ad]
|
|
10
|
+
- @tinacms/graphql@0.60.4
|
|
11
|
+
|
|
12
|
+
## 0.60.18
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 79d112d79: Update cli to accept tinaCloudMediaStore flag and add to metadata during schema compilation
|
|
17
|
+
- 91d6e6758: revert platform aware paths in schema introduced in https://github.com/tinacms/tinacms/commit/558cc4368cd2a4b6e87dfb82bbfbb6f569f8a6f8
|
|
18
|
+
- b1240328d: Adds local server routes for handling media
|
|
19
|
+
- 91d6e6758: Fix issues with experimentalData on windows related to path separator inconsistency and interference with the .tina/**generated** folder
|
|
20
|
+
- Updated dependencies [79d112d79]
|
|
21
|
+
- Updated dependencies [3f46c6706]
|
|
22
|
+
- Updated dependencies [db9168578]
|
|
23
|
+
- Updated dependencies [91d6e6758]
|
|
24
|
+
- @tinacms/graphql@0.60.3
|
|
25
|
+
|
|
26
|
+
## 0.60.17
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- 08cdb672a: Adds `useRelativeMedia` support to local graphql client
|
|
31
|
+
- 646cad8da: Adds support for using the generated client on the frontend
|
|
32
|
+
- f857616f6: Rename sdk to queries
|
|
33
|
+
- Updated dependencies [08cdb672a]
|
|
34
|
+
- Updated dependencies [fdbfe9a16]
|
|
35
|
+
- Updated dependencies [6e2ed31a2]
|
|
36
|
+
- @tinacms/graphql@0.60.2
|
|
37
|
+
- @tinacms/schema-tools@0.0.4
|
|
38
|
+
|
|
3
39
|
## 0.60.16
|
|
4
40
|
|
|
5
41
|
### Patch Changes
|
package/dist/cmds/baseCmds.d.ts
CHANGED
|
@@ -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
|
|
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,7 +12,12 @@ 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
|
|
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;
|
|
18
23
|
}) => Promise<void>;
|
|
@@ -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,
|
|
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
|
-
|
|
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/
|
|
58
|
-
var
|
|
59
|
-
|
|
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
|
+
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
|
+
}
|
|
61
139
|
});
|
|
62
|
-
|
|
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
|
+
}
|
|
229
|
+
});
|
|
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/
|
|
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
|
-
|
|
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,
|
|
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());
|
|
@@ -92,15 +302,39 @@ var init_server = __esm({
|
|
|
92
302
|
}));
|
|
93
303
|
app.post("/graphql", async (req, res) => {
|
|
94
304
|
const { query, variables } = req.body;
|
|
305
|
+
const config = {
|
|
306
|
+
useRelativeMedia: true
|
|
307
|
+
};
|
|
95
308
|
const result = await gqlPackage.resolve({
|
|
309
|
+
config,
|
|
96
310
|
database,
|
|
97
311
|
query,
|
|
98
312
|
variables
|
|
99
313
|
});
|
|
100
314
|
return res.json(result);
|
|
101
315
|
});
|
|
316
|
+
app.use("/media", mediaRouter);
|
|
102
317
|
return server;
|
|
103
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();
|
|
104
338
|
server_default = gqlServer;
|
|
105
339
|
}
|
|
106
340
|
});
|
|
@@ -114,7 +348,7 @@ var commander = __toModule(require("commander"));
|
|
|
114
348
|
|
|
115
349
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/package.json
|
|
116
350
|
var name = "@tinacms/cli";
|
|
117
|
-
var version = "0.60.
|
|
351
|
+
var version = "0.60.19";
|
|
118
352
|
|
|
119
353
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/query-gen/attachSchema.ts
|
|
120
354
|
var import_graphql = __toModule(require("@tinacms/graphql"));
|
|
@@ -165,33 +399,45 @@ var import_graphql5 = __toModule(require("graphql"));
|
|
|
165
399
|
var AddGeneratedClientFunc = (_schema, _documents, _config, _info) => {
|
|
166
400
|
return `
|
|
167
401
|
// TinaSDK generated code
|
|
168
|
-
import { createClient } from
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
const requester: (
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
402
|
+
import { createClient, TinaClient } from "tinacms/dist/client";
|
|
403
|
+
|
|
404
|
+
const generateRequester = (client: TinaClient) => {
|
|
405
|
+
const requester: (
|
|
406
|
+
doc: any,
|
|
407
|
+
vars?: any,
|
|
408
|
+
options?: any,
|
|
409
|
+
client
|
|
410
|
+
) => Promise<any> = async (doc, vars, _options) => {
|
|
411
|
+
let data = {};
|
|
412
|
+
try {
|
|
413
|
+
data = await client.request({
|
|
414
|
+
query: doc,
|
|
415
|
+
variables: vars,
|
|
416
|
+
});
|
|
417
|
+
} catch (e) {
|
|
418
|
+
// swallow errors related to document creation
|
|
419
|
+
console.warn("Warning: There was an error when fetching data");
|
|
420
|
+
console.warn(e);
|
|
421
|
+
}
|
|
187
422
|
|
|
188
|
-
|
|
189
|
-
}
|
|
423
|
+
return { data: data?.data, query: doc, variables: vars || {} };
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
return requester;
|
|
427
|
+
};
|
|
190
428
|
|
|
191
429
|
/**
|
|
192
430
|
* @experimental this class can be used but may change in the future
|
|
193
431
|
**/
|
|
194
|
-
export const ExperimentalGetTinaClient = ()=>
|
|
432
|
+
export const ExperimentalGetTinaClient = () =>
|
|
433
|
+
getSdk(
|
|
434
|
+
generateRequester(createClient({ url: "http://localhost:4001/graphql" }))
|
|
435
|
+
);
|
|
436
|
+
|
|
437
|
+
export const queries = (client: TinaClient) => {
|
|
438
|
+
const requester = generateRequester(client);
|
|
439
|
+
return getSdk(requester);
|
|
440
|
+
};
|
|
195
441
|
`;
|
|
196
442
|
};
|
|
197
443
|
var AddGeneratedClient = {
|
|
@@ -1213,6 +1459,11 @@ async function successMessage(ctx, next, options) {
|
|
|
1213
1459
|
next();
|
|
1214
1460
|
}
|
|
1215
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
|
+
|
|
1216
1467
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/middleware.ts
|
|
1217
1468
|
var chain = async (cmds, options) => {
|
|
1218
1469
|
const ctx = {};
|
|
@@ -1273,7 +1524,7 @@ var import_path5 = __toModule(require("path"));
|
|
|
1273
1524
|
var import_esbuild = __toModule(require("esbuild"));
|
|
1274
1525
|
|
|
1275
1526
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/compile/defaultSchema.ts
|
|
1276
|
-
var defaultSchema =
|
|
1527
|
+
var defaultSchema = `
|
|
1277
1528
|
import { defineSchema, defineConfig } from "tinacms";
|
|
1278
1529
|
|
|
1279
1530
|
const schema = defineSchema({
|
|
@@ -1281,7 +1532,7 @@ const schema = defineSchema({
|
|
|
1281
1532
|
{
|
|
1282
1533
|
label: "Blog Posts",
|
|
1283
1534
|
name: "posts",
|
|
1284
|
-
path: "content
|
|
1535
|
+
path: "content/posts",
|
|
1285
1536
|
fields: [
|
|
1286
1537
|
{
|
|
1287
1538
|
type: "string",
|
|
@@ -1360,39 +1611,49 @@ export const tinaConfig = defineConfig({
|
|
|
1360
1611
|
});
|
|
1361
1612
|
`;
|
|
1362
1613
|
|
|
1363
|
-
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/lib/
|
|
1614
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/lib/getPath.ts
|
|
1364
1615
|
var import_path4 = __toModule(require("path"));
|
|
1365
1616
|
var import_fs_extra3 = __toModule(require("fs-extra"));
|
|
1366
|
-
var
|
|
1367
|
-
|
|
1617
|
+
var getPath = ({
|
|
1618
|
+
projectDir,
|
|
1619
|
+
filename,
|
|
1620
|
+
allowedTypes,
|
|
1621
|
+
errorMessage
|
|
1622
|
+
}) => {
|
|
1368
1623
|
if (!import_fs_extra3.default.existsSync(projectDir)) {
|
|
1369
|
-
throw new Error(
|
|
1370
|
-
}
|
|
1371
|
-
const inputPathTS = import_path4.default.join(projectDir, "schema.ts");
|
|
1372
|
-
const inputPathJS = import_path4.default.join(projectDir, "schema.js");
|
|
1373
|
-
const inputPathTSX = import_path4.default.join(projectDir, "schema.tsx");
|
|
1374
|
-
const inputPathJSX = import_path4.default.join(projectDir, "schema.jsx");
|
|
1375
|
-
let inputFile;
|
|
1376
|
-
if (import_fs_extra3.default.existsSync(inputPathTS)) {
|
|
1377
|
-
inputFile = inputPathTS;
|
|
1378
|
-
} else if (import_fs_extra3.default.existsSync(inputPathJS)) {
|
|
1379
|
-
inputFile = inputPathJS;
|
|
1380
|
-
} else if (import_fs_extra3.default.existsSync(inputPathTSX)) {
|
|
1381
|
-
inputFile = inputPathTSX;
|
|
1382
|
-
} else if (import_fs_extra3.default.existsSync(inputPathJSX)) {
|
|
1383
|
-
inputFile = inputPathJSX;
|
|
1624
|
+
throw new Error(errorMessage);
|
|
1384
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
|
+
});
|
|
1385
1635
|
if (!inputFile) {
|
|
1386
|
-
throw new Error(
|
|
1636
|
+
throw new Error(errorMessage);
|
|
1387
1637
|
}
|
|
1388
1638
|
return inputFile;
|
|
1389
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
|
+
};
|
|
1390
1652
|
|
|
1391
1653
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/compile/index.ts
|
|
1392
1654
|
var tinaPath = import_path5.default.join(process.cwd(), ".tina");
|
|
1393
1655
|
var packageJSONFilePath = import_path5.default.join(process.cwd(), "package.json");
|
|
1394
1656
|
var tinaGeneratedPath = import_path5.default.join(tinaPath, "__generated__");
|
|
1395
|
-
var tinaTempPath = import_path5.default.join(tinaGeneratedPath, "temp");
|
|
1396
1657
|
var tinaConfigPath = import_path5.default.join(tinaGeneratedPath, "config");
|
|
1397
1658
|
var resetGeneratedFolder = async () => {
|
|
1398
1659
|
try {
|
|
@@ -1403,16 +1664,78 @@ var resetGeneratedFolder = async () => {
|
|
|
1403
1664
|
console.log(e);
|
|
1404
1665
|
}
|
|
1405
1666
|
await import_fs_extra4.default.mkdir(tinaGeneratedPath);
|
|
1667
|
+
await import_fs_extra4.default.writeFile(import_path5.default.join(tinaGeneratedPath, "types.ts"), `
|
|
1668
|
+
export const queries = (client)=>({})
|
|
1669
|
+
`);
|
|
1406
1670
|
await import_fs_extra4.default.outputFile(import_path5.default.join(tinaGeneratedPath, ".gitignore"), "db");
|
|
1407
1671
|
};
|
|
1408
|
-
var cleanup = async ({ tinaTempPath
|
|
1409
|
-
await import_fs_extra4.default.remove(
|
|
1672
|
+
var cleanup = async ({ tinaTempPath }) => {
|
|
1673
|
+
await import_fs_extra4.default.remove(tinaTempPath);
|
|
1410
1674
|
};
|
|
1411
|
-
var
|
|
1675
|
+
var compileClient = async (ctx, next, options) => {
|
|
1676
|
+
if (!process.env.NODE_ENV) {
|
|
1677
|
+
process.env.NODE_ENV = options.dev ? "development" : "production";
|
|
1678
|
+
}
|
|
1679
|
+
const tinaTempPath = import_path5.default.join(tinaGeneratedPath, "temp_client");
|
|
1680
|
+
if (!options.clientFileType)
|
|
1681
|
+
options = __spreadProps(__spreadValues({}, options), { clientFileType: "ts" });
|
|
1682
|
+
if (options.verbose) {
|
|
1683
|
+
logger.info(logText("Compiling Client..."));
|
|
1684
|
+
}
|
|
1685
|
+
const { clientFileType: requestedClientFileType = "ts" } = options;
|
|
1686
|
+
const allowedFileTypes = ["ts", "js"];
|
|
1687
|
+
if (allowedFileTypes.includes(requestedClientFileType) === false) {
|
|
1688
|
+
throw new Error(`Requested schema file type '${requestedClientFileType}' is not valid. Supported schema file types: 'ts, js'`);
|
|
1689
|
+
}
|
|
1690
|
+
if (ctx) {
|
|
1691
|
+
ctx.clientFileType = requestedClientFileType;
|
|
1692
|
+
}
|
|
1693
|
+
let clientExists = true;
|
|
1694
|
+
try {
|
|
1695
|
+
getClientPath({ projectDir: tinaPath });
|
|
1696
|
+
} catch {
|
|
1697
|
+
clientExists = false;
|
|
1698
|
+
}
|
|
1699
|
+
if (!clientExists) {
|
|
1700
|
+
if (options.verbose) {
|
|
1701
|
+
logger.info(logText(`.tina/client.${requestedClientFileType} not found, skipping compile client...`));
|
|
1702
|
+
}
|
|
1703
|
+
return next();
|
|
1704
|
+
}
|
|
1705
|
+
try {
|
|
1706
|
+
const inputFile = getClientPath({ projectDir: tinaPath });
|
|
1707
|
+
await transpile(inputFile, "client.js", tinaTempPath, options.verbose);
|
|
1708
|
+
} catch (e) {
|
|
1709
|
+
await cleanup({ tinaTempPath });
|
|
1710
|
+
throw new BuildSchemaError(e);
|
|
1711
|
+
}
|
|
1712
|
+
Object.keys(require.cache).map((key) => {
|
|
1713
|
+
if (key.startsWith(tinaTempPath)) {
|
|
1714
|
+
delete require.cache[require.resolve(key)];
|
|
1715
|
+
}
|
|
1716
|
+
});
|
|
1717
|
+
try {
|
|
1718
|
+
const clientFunc = require(import_path5.default.join(tinaTempPath, "client.js"));
|
|
1719
|
+
const client = clientFunc.default;
|
|
1720
|
+
ctx.client = client;
|
|
1721
|
+
await cleanup({ tinaTempPath });
|
|
1722
|
+
} catch (e) {
|
|
1723
|
+
await cleanup({ tinaTempPath });
|
|
1724
|
+
if (e instanceof Error) {
|
|
1725
|
+
if (e.name === "TinaSchemaValidationError") {
|
|
1726
|
+
throw e;
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
throw new ExecuteSchemaError(e);
|
|
1730
|
+
}
|
|
1731
|
+
return next();
|
|
1732
|
+
};
|
|
1733
|
+
var compileSchema = async (_ctx, _next, options) => {
|
|
1734
|
+
const tinaTempPath = import_path5.default.join(tinaGeneratedPath, "temp_schema");
|
|
1412
1735
|
if (!options.schemaFileType)
|
|
1413
1736
|
options = __spreadProps(__spreadValues({}, options), { schemaFileType: "ts" });
|
|
1414
1737
|
if (options.verbose) {
|
|
1415
|
-
logger.info(logText("Compiling..."));
|
|
1738
|
+
logger.info(logText("Compiling Schema..."));
|
|
1416
1739
|
}
|
|
1417
1740
|
const { schemaFileType: requestedSchemaFileType = "ts" } = options;
|
|
1418
1741
|
const schemaFileType2 = (requestedSchemaFileType === "ts" || requestedSchemaFileType === "tsx") && "ts" || (requestedSchemaFileType === "js" || requestedSchemaFileType === "jsx") && "js";
|
|
@@ -1435,10 +1758,11 @@ var compile = async (_ctx, _next, options) => {
|
|
|
1435
1758
|
`));
|
|
1436
1759
|
const file = import_path5.default.join(tinaPath, `schema.${schemaFileType2}`);
|
|
1437
1760
|
await import_fs_extra4.default.ensureFile(file);
|
|
1438
|
-
await import_fs_extra4.default.writeFile(file, defaultSchema
|
|
1761
|
+
await import_fs_extra4.default.writeFile(file, defaultSchema);
|
|
1439
1762
|
}
|
|
1440
1763
|
try {
|
|
1441
|
-
|
|
1764
|
+
const inputFile = getSchemaPath({ projectDir: tinaPath });
|
|
1765
|
+
await transpile(inputFile, "schema.js", tinaTempPath, options.verbose);
|
|
1442
1766
|
} catch (e) {
|
|
1443
1767
|
await cleanup({ tinaTempPath });
|
|
1444
1768
|
throw new BuildSchemaError(e);
|
|
@@ -1463,7 +1787,7 @@ var compile = async (_ctx, _next, options) => {
|
|
|
1463
1787
|
throw new ExecuteSchemaError(e);
|
|
1464
1788
|
}
|
|
1465
1789
|
};
|
|
1466
|
-
var transpile = async (
|
|
1790
|
+
var transpile = async (inputFile, outputFile, tempDir, verbose) => {
|
|
1467
1791
|
if (verbose)
|
|
1468
1792
|
logger.info(logText("Building javascript..."));
|
|
1469
1793
|
const packageJSON = JSON.parse(import_fs_extra4.default.readFileSync(packageJSONFilePath).toString() || "{}");
|
|
@@ -1471,8 +1795,7 @@ var transpile = async (projectDir, tempDir, verbose) => {
|
|
|
1471
1795
|
const peerDeps = (packageJSON == null ? void 0 : packageJSON.peerDependencies) || [];
|
|
1472
1796
|
const devDeps = (packageJSON == null ? void 0 : packageJSON.devDependencies) || [];
|
|
1473
1797
|
const external = Object.keys(__spreadValues(__spreadValues(__spreadValues({}, deps), peerDeps), devDeps));
|
|
1474
|
-
const
|
|
1475
|
-
const outputPath = import_path5.default.join(tempDir, "schema.js");
|
|
1798
|
+
const outputPath = import_path5.default.join(tempDir, outputFile);
|
|
1476
1799
|
await (0, import_esbuild.build)({
|
|
1477
1800
|
bundle: true,
|
|
1478
1801
|
platform: "neutral",
|
|
@@ -1534,20 +1857,20 @@ var AsyncLock = class {
|
|
|
1534
1857
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/start-server/index.ts
|
|
1535
1858
|
var import_metrics3 = __toModule(require("@tinacms/metrics"));
|
|
1536
1859
|
var import_chalk6 = __toModule(require("chalk"));
|
|
1537
|
-
var import_child_process = __toModule(require("child_process"));
|
|
1538
1860
|
var import_chokidar = __toModule(require("chokidar"));
|
|
1539
|
-
var
|
|
1861
|
+
var import_path8 = __toModule(require("path"));
|
|
1540
1862
|
var lock = new AsyncLock();
|
|
1541
1863
|
var gqlPackageFile = require.resolve("@tinacms/graphql");
|
|
1542
|
-
async function startServer(_ctx,
|
|
1864
|
+
async function startServer(_ctx, next, {
|
|
1543
1865
|
port = 4001,
|
|
1544
|
-
command,
|
|
1545
1866
|
noWatch,
|
|
1546
1867
|
experimentalData,
|
|
1868
|
+
tinaCloudMediaStore: tinaCloudMediaStore2,
|
|
1547
1869
|
noSDK,
|
|
1548
1870
|
noTelemetry,
|
|
1549
1871
|
watchFolders,
|
|
1550
|
-
verbose
|
|
1872
|
+
verbose,
|
|
1873
|
+
dev
|
|
1551
1874
|
}) {
|
|
1552
1875
|
lock.disable();
|
|
1553
1876
|
const rootPath2 = process.cwd();
|
|
@@ -1560,43 +1883,31 @@ async function startServer(_ctx, _next, {
|
|
|
1560
1883
|
if (!process.env.CI && !noWatch) {
|
|
1561
1884
|
await resetGeneratedFolder();
|
|
1562
1885
|
}
|
|
1886
|
+
if (!process.env.NODE_ENV) {
|
|
1887
|
+
process.env.NODE_ENV = dev ? "development" : "production";
|
|
1888
|
+
}
|
|
1563
1889
|
const bridge = new import_datalayer3.FilesystemBridge(rootPath2);
|
|
1564
1890
|
const store = experimentalData ? new import_datalayer3.LevelStore(rootPath2) : new import_datalayer3.FilesystemStore({ rootPath: rootPath2 });
|
|
1565
1891
|
const shouldBuild = bridge.supportsBuilding();
|
|
1566
1892
|
const database = await (0, import_graphql10.createDatabase)({ store, bridge });
|
|
1567
|
-
const startSubprocess = () => {
|
|
1568
|
-
if (typeof command === "string") {
|
|
1569
|
-
const commands = command.split(" ");
|
|
1570
|
-
const firstCommand = commands[0];
|
|
1571
|
-
const args = commands.slice(1) || [];
|
|
1572
|
-
const ps = import_child_process.default.spawn(firstCommand, args, {
|
|
1573
|
-
stdio: "inherit",
|
|
1574
|
-
shell: true
|
|
1575
|
-
});
|
|
1576
|
-
ps.on("error", (code) => {
|
|
1577
|
-
logger.error(dangerText(`An error has occurred in the Next.js child process. Error message below`));
|
|
1578
|
-
logger.error(`name: ${code.name}
|
|
1579
|
-
message: ${code.message}
|
|
1580
|
-
|
|
1581
|
-
stack: ${code.stack || "No stack was provided"}`);
|
|
1582
|
-
});
|
|
1583
|
-
ps.on("close", (code) => {
|
|
1584
|
-
logger.info(`child process exited with code ${code}`);
|
|
1585
|
-
process.exit(code);
|
|
1586
|
-
});
|
|
1587
|
-
}
|
|
1588
|
-
};
|
|
1589
1893
|
let ready = false;
|
|
1590
1894
|
const build2 = async (noSDK2) => {
|
|
1895
|
+
database.clearCache();
|
|
1591
1896
|
await lock.promise;
|
|
1592
1897
|
lock.enable();
|
|
1593
1898
|
try {
|
|
1594
1899
|
if (!process.env.CI && !noWatch) {
|
|
1900
|
+
await store.close();
|
|
1595
1901
|
await resetGeneratedFolder();
|
|
1902
|
+
await store.open();
|
|
1903
|
+
}
|
|
1904
|
+
const cliFlags = [];
|
|
1905
|
+
if (tinaCloudMediaStore2) {
|
|
1906
|
+
cliFlags.push("tinaCloudMediaStore");
|
|
1596
1907
|
}
|
|
1597
1908
|
const database2 = await (0, import_graphql10.createDatabase)({ store, bridge });
|
|
1598
|
-
await
|
|
1599
|
-
const schema = await (0, import_graphql10.buildSchema)(rootPath2, database2);
|
|
1909
|
+
await compileSchema(null, null, { verbose });
|
|
1910
|
+
const schema = await (0, import_graphql10.buildSchema)(rootPath2, database2, cliFlags);
|
|
1600
1911
|
await genTypes({ schema }, () => {
|
|
1601
1912
|
}, { noSDK: noSDK2, verbose });
|
|
1602
1913
|
} catch (error) {
|
|
@@ -1605,7 +1916,7 @@ stack: ${code.stack || "No stack was provided"}`);
|
|
|
1605
1916
|
lock.disable();
|
|
1606
1917
|
}
|
|
1607
1918
|
};
|
|
1608
|
-
const foldersToWatch = (watchFolders || []).map((x) =>
|
|
1919
|
+
const foldersToWatch = (watchFolders || []).map((x) => import_path8.default.join(rootPath2, x));
|
|
1609
1920
|
if (!noWatch && !process.env.CI) {
|
|
1610
1921
|
import_chokidar.default.watch([
|
|
1611
1922
|
...foldersToWatch,
|
|
@@ -1614,7 +1925,7 @@ stack: ${code.stack || "No stack was provided"}`);
|
|
|
1614
1925
|
ignored: [
|
|
1615
1926
|
"**/node_modules/**/*",
|
|
1616
1927
|
"**/.next/**/*",
|
|
1617
|
-
`${
|
|
1928
|
+
`${import_path8.default.resolve(rootPath2)}/.tina/__generated__/**/*`
|
|
1618
1929
|
]
|
|
1619
1930
|
}).on("ready", async () => {
|
|
1620
1931
|
if (verbose)
|
|
@@ -1624,7 +1935,7 @@ stack: ${code.stack || "No stack was provided"}`);
|
|
|
1624
1935
|
await build2(noSDK);
|
|
1625
1936
|
}
|
|
1626
1937
|
ready = true;
|
|
1627
|
-
|
|
1938
|
+
next();
|
|
1628
1939
|
} catch (e) {
|
|
1629
1940
|
handleServerErrors(e);
|
|
1630
1941
|
console.log(e);
|
|
@@ -1659,7 +1970,7 @@ stack: ${code.stack || "No stack was provided"}`);
|
|
|
1659
1970
|
};
|
|
1660
1971
|
let isReady = false;
|
|
1661
1972
|
const start = async () => {
|
|
1662
|
-
const s = (
|
|
1973
|
+
const s = (init_server3(), server_exports);
|
|
1663
1974
|
state.server = await s.default(database);
|
|
1664
1975
|
state.server.listen(port, () => {
|
|
1665
1976
|
const altairUrl = `http://localhost:${port}/altair/`;
|
|
@@ -1710,14 +2021,114 @@ or`);
|
|
|
1710
2021
|
logger.info("Detected CI environment, omitting watch commands...");
|
|
1711
2022
|
}
|
|
1712
2023
|
start();
|
|
1713
|
-
|
|
2024
|
+
next();
|
|
1714
2025
|
}
|
|
1715
2026
|
}
|
|
1716
2027
|
|
|
2028
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/waitForDB/index.ts
|
|
2029
|
+
var POLLING_INTERVAL = 5e3;
|
|
2030
|
+
var STATUS_INPROGRESS = "inprogress";
|
|
2031
|
+
var STATUS_COMPLETE = "complete";
|
|
2032
|
+
var STATUS_FAILED = "failed";
|
|
2033
|
+
var IndexFailedError = class extends Error {
|
|
2034
|
+
constructor(message) {
|
|
2035
|
+
super(message);
|
|
2036
|
+
this.name = "IndexFailedError";
|
|
2037
|
+
}
|
|
2038
|
+
};
|
|
2039
|
+
var waitForDB = async (ctx, next, options) => {
|
|
2040
|
+
if (options.verbose) {
|
|
2041
|
+
logger.info(logText("Waiting for DB..."));
|
|
2042
|
+
}
|
|
2043
|
+
if (!ctx.client) {
|
|
2044
|
+
if (options.verbose) {
|
|
2045
|
+
logger.info(logText("client is unavailable, skipping..."));
|
|
2046
|
+
}
|
|
2047
|
+
return next();
|
|
2048
|
+
}
|
|
2049
|
+
const client = ctx.client;
|
|
2050
|
+
const { host, clientId, branch, isLocalClient } = client.parseURL();
|
|
2051
|
+
if (isLocalClient) {
|
|
2052
|
+
if (options.verbose) {
|
|
2053
|
+
logger.info(logText("client is local, skipping..."));
|
|
2054
|
+
}
|
|
2055
|
+
return next();
|
|
2056
|
+
}
|
|
2057
|
+
const pollForStatus = async () => {
|
|
2058
|
+
try {
|
|
2059
|
+
if (options.verbose) {
|
|
2060
|
+
logger.info(logText("Polling for status..."));
|
|
2061
|
+
}
|
|
2062
|
+
const headers = new Headers();
|
|
2063
|
+
headers.append("Content-Type", "application/json");
|
|
2064
|
+
if (client.readonlyToken) {
|
|
2065
|
+
headers.append("X-API-KEY", client.readonlyToken);
|
|
2066
|
+
}
|
|
2067
|
+
const response = await fetch(`https://${host}/db/${clientId}/status/${branch}`, {
|
|
2068
|
+
method: "GET",
|
|
2069
|
+
headers
|
|
2070
|
+
});
|
|
2071
|
+
const { status, error } = await response.json();
|
|
2072
|
+
const statusMessage = `DB responded with: '${status}'`;
|
|
2073
|
+
if (status === STATUS_COMPLETE) {
|
|
2074
|
+
if (options.verbose) {
|
|
2075
|
+
logger.info(logText(`${statusMessage}`));
|
|
2076
|
+
}
|
|
2077
|
+
return next();
|
|
2078
|
+
} else if (status === STATUS_INPROGRESS) {
|
|
2079
|
+
if (options.verbose) {
|
|
2080
|
+
logger.info(logText(`${statusMessage}, trying again in 5 seconds`));
|
|
2081
|
+
}
|
|
2082
|
+
setTimeout(pollForStatus, POLLING_INTERVAL);
|
|
2083
|
+
} else if (status === STATUS_FAILED) {
|
|
2084
|
+
throw new IndexFailedError(`Attempting to index DB responded with status 'failed', ${error}`);
|
|
2085
|
+
} else {
|
|
2086
|
+
if (options.verbose) {
|
|
2087
|
+
logger.info(logText(`${statusMessage}`));
|
|
2088
|
+
}
|
|
2089
|
+
return next();
|
|
2090
|
+
}
|
|
2091
|
+
} catch (e) {
|
|
2092
|
+
if (e instanceof IndexFailedError) {
|
|
2093
|
+
throw e;
|
|
2094
|
+
} else {
|
|
2095
|
+
throw new Error(`Unable to query DB for indexing status, encountered error: ${e.message}`);
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2098
|
+
};
|
|
2099
|
+
pollForStatus();
|
|
2100
|
+
};
|
|
2101
|
+
|
|
2102
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/startSubprocess/index.ts
|
|
2103
|
+
var import_child_process = __toModule(require("child_process"));
|
|
2104
|
+
var startSubprocess = async (_ctx, next, { command }) => {
|
|
2105
|
+
if (typeof command === "string") {
|
|
2106
|
+
const commands = command.split(" ");
|
|
2107
|
+
const firstCommand = commands[0];
|
|
2108
|
+
const args = commands.slice(1) || [];
|
|
2109
|
+
const ps = import_child_process.default.spawn(firstCommand, args, {
|
|
2110
|
+
stdio: "inherit",
|
|
2111
|
+
shell: true
|
|
2112
|
+
});
|
|
2113
|
+
ps.on("error", (code) => {
|
|
2114
|
+
logger.error(dangerText(`An error has occurred in the Next.js child process. Error message below`));
|
|
2115
|
+
logger.error(`name: ${code.name}
|
|
2116
|
+
message: ${code.message}
|
|
2117
|
+
|
|
2118
|
+
stack: ${code.stack || "No stack was provided"}`);
|
|
2119
|
+
});
|
|
2120
|
+
ps.on("close", (code) => {
|
|
2121
|
+
logger.info(`child process exited with code ${code}`);
|
|
2122
|
+
process.exit(code);
|
|
2123
|
+
});
|
|
2124
|
+
}
|
|
2125
|
+
};
|
|
2126
|
+
|
|
1717
2127
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/baseCmds.ts
|
|
1718
2128
|
var CMD_GEN_TYPES = "schema:types";
|
|
1719
2129
|
var CMD_START_SERVER = "server:start";
|
|
1720
2130
|
var CMD_COMPILE_MODELS = "schema:compile";
|
|
2131
|
+
var CMD_WAIT_FOR_DB = "server:waitForDB";
|
|
1721
2132
|
var INIT = "init";
|
|
1722
2133
|
var AUDIT = "audit";
|
|
1723
2134
|
var startServerPortOption = {
|
|
@@ -1764,6 +2175,14 @@ var verboseOption = {
|
|
|
1764
2175
|
name: "-v, --verbose",
|
|
1765
2176
|
description: "increase verbosity of logged output"
|
|
1766
2177
|
};
|
|
2178
|
+
var tinaCloudMediaStore = {
|
|
2179
|
+
name: "--tinaCloudMediaStore",
|
|
2180
|
+
description: "Automatically pushes updates from GitHub to the Tina Cloud Media Store"
|
|
2181
|
+
};
|
|
2182
|
+
var developmentOption = {
|
|
2183
|
+
name: "--dev",
|
|
2184
|
+
description: "Uses NODE_ENV=development when compiling client and schema"
|
|
2185
|
+
};
|
|
1767
2186
|
var baseCmds = [
|
|
1768
2187
|
{
|
|
1769
2188
|
command: CMD_START_SERVER,
|
|
@@ -1772,36 +2191,60 @@ var baseCmds = [
|
|
|
1772
2191
|
startServerPortOption,
|
|
1773
2192
|
subCommand,
|
|
1774
2193
|
experimentalDatalayer,
|
|
2194
|
+
tinaCloudMediaStore,
|
|
1775
2195
|
noWatchOption,
|
|
1776
2196
|
noSDKCodegenOption,
|
|
1777
2197
|
noTelemetryOption,
|
|
1778
2198
|
watchFileOption,
|
|
1779
|
-
verboseOption
|
|
2199
|
+
verboseOption,
|
|
2200
|
+
developmentOption
|
|
2201
|
+
],
|
|
2202
|
+
action: (options) => chain([compileClient, waitForDB, startServer, startSubprocess], options)
|
|
2203
|
+
},
|
|
2204
|
+
{
|
|
2205
|
+
command: CMD_WAIT_FOR_DB,
|
|
2206
|
+
description: "Wait for DB to finish indexing, start subprocess",
|
|
2207
|
+
options: [
|
|
2208
|
+
subCommand,
|
|
2209
|
+
experimentalDatalayer,
|
|
2210
|
+
noTelemetryOption,
|
|
2211
|
+
verboseOption,
|
|
2212
|
+
developmentOption
|
|
1780
2213
|
],
|
|
1781
|
-
action: (options) => chain([
|
|
2214
|
+
action: (options) => chain([compileClient, waitForDB, startSubprocess], options)
|
|
1782
2215
|
},
|
|
1783
2216
|
{
|
|
1784
2217
|
command: CMD_COMPILE_MODELS,
|
|
1785
2218
|
description: "Compile schema into static files for the server",
|
|
1786
|
-
options: [experimentalDatalayer, noTelemetryOption],
|
|
1787
|
-
action: (options) => chain([
|
|
2219
|
+
options: [experimentalDatalayer, tinaCloudMediaStore, noTelemetryOption],
|
|
2220
|
+
action: (options) => chain([compileSchema], options)
|
|
1788
2221
|
},
|
|
1789
2222
|
{
|
|
1790
2223
|
command: CMD_GEN_TYPES,
|
|
1791
2224
|
description: "Generate a GraphQL query for your site's schema, (and optionally Typescript types)",
|
|
1792
|
-
options: [
|
|
2225
|
+
options: [
|
|
2226
|
+
experimentalDatalayer,
|
|
2227
|
+
tinaCloudMediaStore,
|
|
2228
|
+
noSDKCodegenOption,
|
|
2229
|
+
noTelemetryOption
|
|
2230
|
+
],
|
|
1793
2231
|
action: (options) => chain([attachSchema, genTypes], options)
|
|
1794
2232
|
},
|
|
1795
2233
|
{
|
|
1796
2234
|
command: INIT,
|
|
1797
|
-
options: [
|
|
2235
|
+
options: [
|
|
2236
|
+
experimentalDatalayer,
|
|
2237
|
+
tinaCloudMediaStore,
|
|
2238
|
+
noTelemetryOption,
|
|
2239
|
+
schemaFileType
|
|
2240
|
+
],
|
|
1798
2241
|
description: "Add Tina Cloud to an existing project",
|
|
1799
2242
|
action: (options) => chain([
|
|
1800
2243
|
checkDeps,
|
|
1801
2244
|
initTina,
|
|
1802
2245
|
installDeps,
|
|
1803
2246
|
async (_ctx, next, options2) => {
|
|
1804
|
-
await
|
|
2247
|
+
await compileSchema(_ctx, next, options2);
|
|
1805
2248
|
next();
|
|
1806
2249
|
},
|
|
1807
2250
|
attachSchema,
|
|
@@ -1820,7 +2263,7 @@ var baseCmds = [
|
|
|
1820
2263
|
next();
|
|
1821
2264
|
},
|
|
1822
2265
|
async (_ctx, next) => {
|
|
1823
|
-
await
|
|
2266
|
+
await compileSchema(_ctx, next, options);
|
|
1824
2267
|
next();
|
|
1825
2268
|
},
|
|
1826
2269
|
attachSchema,
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "0.60.19",
|
|
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,9 +59,9 @@
|
|
|
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.
|
|
62
|
+
"@tinacms/graphql": "0.60.4",
|
|
62
63
|
"@tinacms/metrics": "0.0.3",
|
|
63
|
-
"@tinacms/schema-tools": "0.0.
|
|
64
|
+
"@tinacms/schema-tools": "0.0.4",
|
|
64
65
|
"@yarnpkg/esbuild-plugin-pnp": "^2.0.1-rc.3",
|
|
65
66
|
"add": "^2.0.6",
|
|
66
67
|
"ajv": "^6.12.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",
|