@tinacms/cli 0.60.18 → 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 +9 -0
- package/dist/cmds/baseCmds.d.ts +2 -0
- package/dist/cmds/compile/index.d.ts +6 -1
- package/dist/cmds/start-server/index.d.ts +2 -1
- package/dist/cmds/startSubprocess/index.d.ts +17 -0
- package/dist/cmds/waitForDB/index.d.ts +15 -0
- package/dist/index.js +355 -63
- package/dist/lib/{getSchemaPath.d.ts → getPath.d.ts} +3 -0
- package/dist/lib/index.d.ts +1 -1
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
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
|
+
|
|
3
12
|
## 0.60.18
|
|
4
13
|
|
|
5
14
|
### 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[];
|
|
@@ -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>;
|
|
@@ -20,6 +20,7 @@ interface Options {
|
|
|
20
20
|
noSDK: boolean;
|
|
21
21
|
noTelemetry: boolean;
|
|
22
22
|
verbose?: boolean;
|
|
23
|
+
dev?: boolean;
|
|
23
24
|
}
|
|
24
|
-
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>;
|
|
25
26
|
export {};
|
|
@@ -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,6 +57,123 @@ 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
|
|
|
60
|
+
// pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/dotenv-npm-16.0.1-d99e72bb95-e97e94476c.zip/node_modules/dotenv/lib/main.js
|
|
61
|
+
var require_main = __commonJS({
|
|
62
|
+
"pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/dotenv-npm-16.0.1-d99e72bb95-e97e94476c.zip/node_modules/dotenv/lib/main.js"(exports, module2) {
|
|
63
|
+
var fs6 = require("fs");
|
|
64
|
+
var path4 = require("path");
|
|
65
|
+
var os = require("os");
|
|
66
|
+
var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
|
67
|
+
function parse2(src) {
|
|
68
|
+
const obj = {};
|
|
69
|
+
let lines = src.toString();
|
|
70
|
+
lines = lines.replace(/\r\n?/mg, "\n");
|
|
71
|
+
let match;
|
|
72
|
+
while ((match = LINE.exec(lines)) != null) {
|
|
73
|
+
const key = match[1];
|
|
74
|
+
let value = match[2] || "";
|
|
75
|
+
value = value.trim();
|
|
76
|
+
const maybeQuote = value[0];
|
|
77
|
+
value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
|
|
78
|
+
if (maybeQuote === '"') {
|
|
79
|
+
value = value.replace(/\\n/g, "\n");
|
|
80
|
+
value = value.replace(/\\r/g, "\r");
|
|
81
|
+
}
|
|
82
|
+
obj[key] = value;
|
|
83
|
+
}
|
|
84
|
+
return obj;
|
|
85
|
+
}
|
|
86
|
+
function _log(message) {
|
|
87
|
+
console.log(`[dotenv][DEBUG] ${message}`);
|
|
88
|
+
}
|
|
89
|
+
function _resolveHome(envPath) {
|
|
90
|
+
return envPath[0] === "~" ? path4.join(os.homedir(), envPath.slice(1)) : envPath;
|
|
91
|
+
}
|
|
92
|
+
function config(options) {
|
|
93
|
+
let dotenvPath = path4.resolve(process.cwd(), ".env");
|
|
94
|
+
let encoding = "utf8";
|
|
95
|
+
const debug = Boolean(options && options.debug);
|
|
96
|
+
const override = Boolean(options && options.override);
|
|
97
|
+
if (options) {
|
|
98
|
+
if (options.path != null) {
|
|
99
|
+
dotenvPath = _resolveHome(options.path);
|
|
100
|
+
}
|
|
101
|
+
if (options.encoding != null) {
|
|
102
|
+
encoding = options.encoding;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
const parsed = DotenvModule.parse(fs6.readFileSync(dotenvPath, { encoding }));
|
|
107
|
+
Object.keys(parsed).forEach(function(key) {
|
|
108
|
+
if (!Object.prototype.hasOwnProperty.call(process.env, key)) {
|
|
109
|
+
process.env[key] = parsed[key];
|
|
110
|
+
} else {
|
|
111
|
+
if (override === true) {
|
|
112
|
+
process.env[key] = parsed[key];
|
|
113
|
+
}
|
|
114
|
+
if (debug) {
|
|
115
|
+
if (override === true) {
|
|
116
|
+
_log(`"${key}" is already defined in \`process.env\` and WAS overwritten`);
|
|
117
|
+
} else {
|
|
118
|
+
_log(`"${key}" is already defined in \`process.env\` and was NOT overwritten`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
return { parsed };
|
|
124
|
+
} catch (e) {
|
|
125
|
+
if (debug) {
|
|
126
|
+
_log(`Failed to load ${dotenvPath} ${e.message}`);
|
|
127
|
+
}
|
|
128
|
+
return { error: e };
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
var DotenvModule = {
|
|
132
|
+
config,
|
|
133
|
+
parse: parse2
|
|
134
|
+
};
|
|
135
|
+
module2.exports.config = DotenvModule.config;
|
|
136
|
+
module2.exports.parse = DotenvModule.parse;
|
|
137
|
+
module2.exports = DotenvModule;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/dotenv-npm-16.0.1-d99e72bb95-e97e94476c.zip/node_modules/dotenv/lib/env-options.js
|
|
142
|
+
var require_env_options = __commonJS({
|
|
143
|
+
"pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/dotenv-npm-16.0.1-d99e72bb95-e97e94476c.zip/node_modules/dotenv/lib/env-options.js"(exports, module2) {
|
|
144
|
+
var options = {};
|
|
145
|
+
if (process.env.DOTENV_CONFIG_ENCODING != null) {
|
|
146
|
+
options.encoding = process.env.DOTENV_CONFIG_ENCODING;
|
|
147
|
+
}
|
|
148
|
+
if (process.env.DOTENV_CONFIG_PATH != null) {
|
|
149
|
+
options.path = process.env.DOTENV_CONFIG_PATH;
|
|
150
|
+
}
|
|
151
|
+
if (process.env.DOTENV_CONFIG_DEBUG != null) {
|
|
152
|
+
options.debug = process.env.DOTENV_CONFIG_DEBUG;
|
|
153
|
+
}
|
|
154
|
+
if (process.env.DOTENV_CONFIG_OVERRIDE != null) {
|
|
155
|
+
options.override = process.env.DOTENV_CONFIG_OVERRIDE;
|
|
156
|
+
}
|
|
157
|
+
module2.exports = options;
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
// pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/dotenv-npm-16.0.1-d99e72bb95-e97e94476c.zip/node_modules/dotenv/lib/cli-options.js
|
|
162
|
+
var require_cli_options = __commonJS({
|
|
163
|
+
"pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/dotenv-npm-16.0.1-d99e72bb95-e97e94476c.zip/node_modules/dotenv/lib/cli-options.js"(exports, module2) {
|
|
164
|
+
var re = /^dotenv_config_(encoding|path|debug|override)=(.+)$/;
|
|
165
|
+
module2.exports = function optionMatcher(args) {
|
|
166
|
+
return args.reduce(function(acc, cur) {
|
|
167
|
+
const matches = cur.match(re);
|
|
168
|
+
if (matches) {
|
|
169
|
+
acc[matches[1]] = matches[2];
|
|
170
|
+
}
|
|
171
|
+
return acc;
|
|
172
|
+
}, {});
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
|
|
57
177
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/server/models/media.ts
|
|
58
178
|
var import_fs_extra5, import_path6, MediaModel;
|
|
59
179
|
var init_media = __esm({
|
|
@@ -228,7 +348,7 @@ var commander = __toModule(require("commander"));
|
|
|
228
348
|
|
|
229
349
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/package.json
|
|
230
350
|
var name = "@tinacms/cli";
|
|
231
|
-
var version = "0.60.
|
|
351
|
+
var version = "0.60.19";
|
|
232
352
|
|
|
233
353
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/query-gen/attachSchema.ts
|
|
234
354
|
var import_graphql = __toModule(require("@tinacms/graphql"));
|
|
@@ -1339,6 +1459,11 @@ async function successMessage(ctx, next, options) {
|
|
|
1339
1459
|
next();
|
|
1340
1460
|
}
|
|
1341
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
|
+
|
|
1342
1467
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/middleware.ts
|
|
1343
1468
|
var chain = async (cmds, options) => {
|
|
1344
1469
|
const ctx = {};
|
|
@@ -1486,39 +1611,49 @@ export const tinaConfig = defineConfig({
|
|
|
1486
1611
|
});
|
|
1487
1612
|
`;
|
|
1488
1613
|
|
|
1489
|
-
// 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
|
|
1490
1615
|
var import_path4 = __toModule(require("path"));
|
|
1491
1616
|
var import_fs_extra3 = __toModule(require("fs-extra"));
|
|
1492
|
-
var
|
|
1493
|
-
|
|
1617
|
+
var getPath = ({
|
|
1618
|
+
projectDir,
|
|
1619
|
+
filename,
|
|
1620
|
+
allowedTypes,
|
|
1621
|
+
errorMessage
|
|
1622
|
+
}) => {
|
|
1494
1623
|
if (!import_fs_extra3.default.existsSync(projectDir)) {
|
|
1495
|
-
throw new Error(
|
|
1496
|
-
}
|
|
1497
|
-
const inputPathTS = import_path4.default.join(projectDir, "schema.ts");
|
|
1498
|
-
const inputPathJS = import_path4.default.join(projectDir, "schema.js");
|
|
1499
|
-
const inputPathTSX = import_path4.default.join(projectDir, "schema.tsx");
|
|
1500
|
-
const inputPathJSX = import_path4.default.join(projectDir, "schema.jsx");
|
|
1501
|
-
let inputFile;
|
|
1502
|
-
if (import_fs_extra3.default.existsSync(inputPathTS)) {
|
|
1503
|
-
inputFile = inputPathTS;
|
|
1504
|
-
} else if (import_fs_extra3.default.existsSync(inputPathJS)) {
|
|
1505
|
-
inputFile = inputPathJS;
|
|
1506
|
-
} else if (import_fs_extra3.default.existsSync(inputPathTSX)) {
|
|
1507
|
-
inputFile = inputPathTSX;
|
|
1508
|
-
} else if (import_fs_extra3.default.existsSync(inputPathJSX)) {
|
|
1509
|
-
inputFile = inputPathJSX;
|
|
1624
|
+
throw new Error(errorMessage);
|
|
1510
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
|
+
});
|
|
1511
1635
|
if (!inputFile) {
|
|
1512
|
-
throw new Error(
|
|
1636
|
+
throw new Error(errorMessage);
|
|
1513
1637
|
}
|
|
1514
1638
|
return inputFile;
|
|
1515
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
|
+
};
|
|
1516
1652
|
|
|
1517
1653
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/compile/index.ts
|
|
1518
1654
|
var tinaPath = import_path5.default.join(process.cwd(), ".tina");
|
|
1519
1655
|
var packageJSONFilePath = import_path5.default.join(process.cwd(), "package.json");
|
|
1520
1656
|
var tinaGeneratedPath = import_path5.default.join(tinaPath, "__generated__");
|
|
1521
|
-
var tinaTempPath = import_path5.default.join(tinaGeneratedPath, "temp");
|
|
1522
1657
|
var tinaConfigPath = import_path5.default.join(tinaGeneratedPath, "config");
|
|
1523
1658
|
var resetGeneratedFolder = async () => {
|
|
1524
1659
|
try {
|
|
@@ -1534,14 +1669,73 @@ export const queries = (client)=>({})
|
|
|
1534
1669
|
`);
|
|
1535
1670
|
await import_fs_extra4.default.outputFile(import_path5.default.join(tinaGeneratedPath, ".gitignore"), "db");
|
|
1536
1671
|
};
|
|
1537
|
-
var cleanup = async ({ tinaTempPath
|
|
1538
|
-
await import_fs_extra4.default.remove(
|
|
1672
|
+
var cleanup = async ({ tinaTempPath }) => {
|
|
1673
|
+
await import_fs_extra4.default.remove(tinaTempPath);
|
|
1674
|
+
};
|
|
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();
|
|
1539
1732
|
};
|
|
1540
|
-
var
|
|
1733
|
+
var compileSchema = async (_ctx, _next, options) => {
|
|
1734
|
+
const tinaTempPath = import_path5.default.join(tinaGeneratedPath, "temp_schema");
|
|
1541
1735
|
if (!options.schemaFileType)
|
|
1542
1736
|
options = __spreadProps(__spreadValues({}, options), { schemaFileType: "ts" });
|
|
1543
1737
|
if (options.verbose) {
|
|
1544
|
-
logger.info(logText("Compiling..."));
|
|
1738
|
+
logger.info(logText("Compiling Schema..."));
|
|
1545
1739
|
}
|
|
1546
1740
|
const { schemaFileType: requestedSchemaFileType = "ts" } = options;
|
|
1547
1741
|
const schemaFileType2 = (requestedSchemaFileType === "ts" || requestedSchemaFileType === "tsx") && "ts" || (requestedSchemaFileType === "js" || requestedSchemaFileType === "jsx") && "js";
|
|
@@ -1567,7 +1761,8 @@ var compile = async (_ctx, _next, options) => {
|
|
|
1567
1761
|
await import_fs_extra4.default.writeFile(file, defaultSchema);
|
|
1568
1762
|
}
|
|
1569
1763
|
try {
|
|
1570
|
-
|
|
1764
|
+
const inputFile = getSchemaPath({ projectDir: tinaPath });
|
|
1765
|
+
await transpile(inputFile, "schema.js", tinaTempPath, options.verbose);
|
|
1571
1766
|
} catch (e) {
|
|
1572
1767
|
await cleanup({ tinaTempPath });
|
|
1573
1768
|
throw new BuildSchemaError(e);
|
|
@@ -1592,7 +1787,7 @@ var compile = async (_ctx, _next, options) => {
|
|
|
1592
1787
|
throw new ExecuteSchemaError(e);
|
|
1593
1788
|
}
|
|
1594
1789
|
};
|
|
1595
|
-
var transpile = async (
|
|
1790
|
+
var transpile = async (inputFile, outputFile, tempDir, verbose) => {
|
|
1596
1791
|
if (verbose)
|
|
1597
1792
|
logger.info(logText("Building javascript..."));
|
|
1598
1793
|
const packageJSON = JSON.parse(import_fs_extra4.default.readFileSync(packageJSONFilePath).toString() || "{}");
|
|
@@ -1600,8 +1795,7 @@ var transpile = async (projectDir, tempDir, verbose) => {
|
|
|
1600
1795
|
const peerDeps = (packageJSON == null ? void 0 : packageJSON.peerDependencies) || [];
|
|
1601
1796
|
const devDeps = (packageJSON == null ? void 0 : packageJSON.devDependencies) || [];
|
|
1602
1797
|
const external = Object.keys(__spreadValues(__spreadValues(__spreadValues({}, deps), peerDeps), devDeps));
|
|
1603
|
-
const
|
|
1604
|
-
const outputPath = import_path5.default.join(tempDir, "schema.js");
|
|
1798
|
+
const outputPath = import_path5.default.join(tempDir, outputFile);
|
|
1605
1799
|
await (0, import_esbuild.build)({
|
|
1606
1800
|
bundle: true,
|
|
1607
1801
|
platform: "neutral",
|
|
@@ -1663,21 +1857,20 @@ var AsyncLock = class {
|
|
|
1663
1857
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/start-server/index.ts
|
|
1664
1858
|
var import_metrics3 = __toModule(require("@tinacms/metrics"));
|
|
1665
1859
|
var import_chalk6 = __toModule(require("chalk"));
|
|
1666
|
-
var import_child_process = __toModule(require("child_process"));
|
|
1667
1860
|
var import_chokidar = __toModule(require("chokidar"));
|
|
1668
1861
|
var import_path8 = __toModule(require("path"));
|
|
1669
1862
|
var lock = new AsyncLock();
|
|
1670
1863
|
var gqlPackageFile = require.resolve("@tinacms/graphql");
|
|
1671
|
-
async function startServer(_ctx,
|
|
1864
|
+
async function startServer(_ctx, next, {
|
|
1672
1865
|
port = 4001,
|
|
1673
|
-
command,
|
|
1674
1866
|
noWatch,
|
|
1675
1867
|
experimentalData,
|
|
1676
1868
|
tinaCloudMediaStore: tinaCloudMediaStore2,
|
|
1677
1869
|
noSDK,
|
|
1678
1870
|
noTelemetry,
|
|
1679
1871
|
watchFolders,
|
|
1680
|
-
verbose
|
|
1872
|
+
verbose,
|
|
1873
|
+
dev
|
|
1681
1874
|
}) {
|
|
1682
1875
|
lock.disable();
|
|
1683
1876
|
const rootPath2 = process.cwd();
|
|
@@ -1690,34 +1883,16 @@ async function startServer(_ctx, _next, {
|
|
|
1690
1883
|
if (!process.env.CI && !noWatch) {
|
|
1691
1884
|
await resetGeneratedFolder();
|
|
1692
1885
|
}
|
|
1886
|
+
if (!process.env.NODE_ENV) {
|
|
1887
|
+
process.env.NODE_ENV = dev ? "development" : "production";
|
|
1888
|
+
}
|
|
1693
1889
|
const bridge = new import_datalayer3.FilesystemBridge(rootPath2);
|
|
1694
1890
|
const store = experimentalData ? new import_datalayer3.LevelStore(rootPath2) : new import_datalayer3.FilesystemStore({ rootPath: rootPath2 });
|
|
1695
1891
|
const shouldBuild = bridge.supportsBuilding();
|
|
1696
1892
|
const database = await (0, import_graphql10.createDatabase)({ store, bridge });
|
|
1697
|
-
const startSubprocess = () => {
|
|
1698
|
-
if (typeof command === "string") {
|
|
1699
|
-
const commands = command.split(" ");
|
|
1700
|
-
const firstCommand = commands[0];
|
|
1701
|
-
const args = commands.slice(1) || [];
|
|
1702
|
-
const ps = import_child_process.default.spawn(firstCommand, args, {
|
|
1703
|
-
stdio: "inherit",
|
|
1704
|
-
shell: true
|
|
1705
|
-
});
|
|
1706
|
-
ps.on("error", (code) => {
|
|
1707
|
-
logger.error(dangerText(`An error has occurred in the Next.js child process. Error message below`));
|
|
1708
|
-
logger.error(`name: ${code.name}
|
|
1709
|
-
message: ${code.message}
|
|
1710
|
-
|
|
1711
|
-
stack: ${code.stack || "No stack was provided"}`);
|
|
1712
|
-
});
|
|
1713
|
-
ps.on("close", (code) => {
|
|
1714
|
-
logger.info(`child process exited with code ${code}`);
|
|
1715
|
-
process.exit(code);
|
|
1716
|
-
});
|
|
1717
|
-
}
|
|
1718
|
-
};
|
|
1719
1893
|
let ready = false;
|
|
1720
1894
|
const build2 = async (noSDK2) => {
|
|
1895
|
+
database.clearCache();
|
|
1721
1896
|
await lock.promise;
|
|
1722
1897
|
lock.enable();
|
|
1723
1898
|
try {
|
|
@@ -1731,7 +1906,7 @@ stack: ${code.stack || "No stack was provided"}`);
|
|
|
1731
1906
|
cliFlags.push("tinaCloudMediaStore");
|
|
1732
1907
|
}
|
|
1733
1908
|
const database2 = await (0, import_graphql10.createDatabase)({ store, bridge });
|
|
1734
|
-
await
|
|
1909
|
+
await compileSchema(null, null, { verbose });
|
|
1735
1910
|
const schema = await (0, import_graphql10.buildSchema)(rootPath2, database2, cliFlags);
|
|
1736
1911
|
await genTypes({ schema }, () => {
|
|
1737
1912
|
}, { noSDK: noSDK2, verbose });
|
|
@@ -1760,7 +1935,7 @@ stack: ${code.stack || "No stack was provided"}`);
|
|
|
1760
1935
|
await build2(noSDK);
|
|
1761
1936
|
}
|
|
1762
1937
|
ready = true;
|
|
1763
|
-
|
|
1938
|
+
next();
|
|
1764
1939
|
} catch (e) {
|
|
1765
1940
|
handleServerErrors(e);
|
|
1766
1941
|
console.log(e);
|
|
@@ -1846,14 +2021,114 @@ or`);
|
|
|
1846
2021
|
logger.info("Detected CI environment, omitting watch commands...");
|
|
1847
2022
|
}
|
|
1848
2023
|
start();
|
|
1849
|
-
|
|
2024
|
+
next();
|
|
1850
2025
|
}
|
|
1851
2026
|
}
|
|
1852
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
|
+
|
|
1853
2127
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/baseCmds.ts
|
|
1854
2128
|
var CMD_GEN_TYPES = "schema:types";
|
|
1855
2129
|
var CMD_START_SERVER = "server:start";
|
|
1856
2130
|
var CMD_COMPILE_MODELS = "schema:compile";
|
|
2131
|
+
var CMD_WAIT_FOR_DB = "server:waitForDB";
|
|
1857
2132
|
var INIT = "init";
|
|
1858
2133
|
var AUDIT = "audit";
|
|
1859
2134
|
var startServerPortOption = {
|
|
@@ -1904,6 +2179,10 @@ var tinaCloudMediaStore = {
|
|
|
1904
2179
|
name: "--tinaCloudMediaStore",
|
|
1905
2180
|
description: "Automatically pushes updates from GitHub to the Tina Cloud Media Store"
|
|
1906
2181
|
};
|
|
2182
|
+
var developmentOption = {
|
|
2183
|
+
name: "--dev",
|
|
2184
|
+
description: "Uses NODE_ENV=development when compiling client and schema"
|
|
2185
|
+
};
|
|
1907
2186
|
var baseCmds = [
|
|
1908
2187
|
{
|
|
1909
2188
|
command: CMD_START_SERVER,
|
|
@@ -1917,15 +2196,28 @@ var baseCmds = [
|
|
|
1917
2196
|
noSDKCodegenOption,
|
|
1918
2197
|
noTelemetryOption,
|
|
1919
2198
|
watchFileOption,
|
|
1920
|
-
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
|
|
1921
2213
|
],
|
|
1922
|
-
action: (options) => chain([
|
|
2214
|
+
action: (options) => chain([compileClient, waitForDB, startSubprocess], options)
|
|
1923
2215
|
},
|
|
1924
2216
|
{
|
|
1925
2217
|
command: CMD_COMPILE_MODELS,
|
|
1926
2218
|
description: "Compile schema into static files for the server",
|
|
1927
2219
|
options: [experimentalDatalayer, tinaCloudMediaStore, noTelemetryOption],
|
|
1928
|
-
action: (options) => chain([
|
|
2220
|
+
action: (options) => chain([compileSchema], options)
|
|
1929
2221
|
},
|
|
1930
2222
|
{
|
|
1931
2223
|
command: CMD_GEN_TYPES,
|
|
@@ -1952,7 +2244,7 @@ var baseCmds = [
|
|
|
1952
2244
|
initTina,
|
|
1953
2245
|
installDeps,
|
|
1954
2246
|
async (_ctx, next, options2) => {
|
|
1955
|
-
await
|
|
2247
|
+
await compileSchema(_ctx, next, options2);
|
|
1956
2248
|
next();
|
|
1957
2249
|
},
|
|
1958
2250
|
attachSchema,
|
|
@@ -1971,7 +2263,7 @@ var baseCmds = [
|
|
|
1971
2263
|
next();
|
|
1972
2264
|
},
|
|
1973
2265
|
async (_ctx, next) => {
|
|
1974
|
-
await
|
|
2266
|
+
await compileSchema(_ctx, next, options);
|
|
1975
2267
|
next();
|
|
1976
2268
|
},
|
|
1977
2269
|
attachSchema,
|
package/dist/lib/index.d.ts
CHANGED
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": [
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"@graphql-tools/graphql-file-loader": "^7.2.0",
|
|
60
60
|
"@graphql-tools/load": "^7.3.2",
|
|
61
61
|
"@tinacms/datalayer": "0.1.1",
|
|
62
|
-
"@tinacms/graphql": "0.60.
|
|
62
|
+
"@tinacms/graphql": "0.60.4",
|
|
63
63
|
"@tinacms/metrics": "0.0.3",
|
|
64
64
|
"@tinacms/schema-tools": "0.0.4",
|
|
65
65
|
"@yarnpkg/esbuild-plugin-pnp": "^2.0.1-rc.3",
|
|
@@ -73,6 +73,7 @@
|
|
|
73
73
|
"chokidar": "^3.5.1",
|
|
74
74
|
"commander": "^9.0.0",
|
|
75
75
|
"cors": "^2.8.5",
|
|
76
|
+
"dotenv": "^16.0.1",
|
|
76
77
|
"esbuild": "^0.14.20",
|
|
77
78
|
"esm": "3.2.25",
|
|
78
79
|
"express": "^4.17.1",
|