@tinacms/cli 0.62.1 → 0.62.3
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/bin/tinacms
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const version = process.version.slice(1)
|
|
4
|
+
const [major, minor] = version.split('.')
|
|
5
|
+
if (major < 14 || (major == 14 && minor < 18)) {
|
|
6
|
+
console.error(
|
|
7
|
+
'ERROR: Node.js version lower than 14.18 is not supported in tinacms, please update to the latest LTS version. See https://nodejs.org/en/download/ for more details'
|
|
8
|
+
)
|
|
9
|
+
} else {
|
|
10
|
+
require('../dist/index.js').init(process.argv)
|
|
11
|
+
}
|
|
@@ -38,6 +38,7 @@ export declare const buildCmdBuild: (ctx: {
|
|
|
38
38
|
rootPath: string;
|
|
39
39
|
usingTs: boolean;
|
|
40
40
|
schema: unknown;
|
|
41
|
+
apiUrl: string;
|
|
41
42
|
}, next: () => void, options: Omit<BuildOptions & BuildSetupOptions & ClientGenOptions, 'bridge' | 'database' | 'store'>) => Promise<void>;
|
|
42
43
|
export declare const auditCmdBuild: (ctx: {
|
|
43
44
|
builder: ConfigBuilder;
|
|
@@ -16,11 +16,6 @@ export declare const resetGeneratedFolder: ({ tinaGeneratedPath, usingTs, isBuil
|
|
|
16
16
|
usingTs: boolean;
|
|
17
17
|
isBuild: boolean;
|
|
18
18
|
}) => Promise<void>;
|
|
19
|
-
export declare const compileClient: (ctx: any, next: any, options: {
|
|
20
|
-
clientFileType?: string;
|
|
21
|
-
verbose?: boolean;
|
|
22
|
-
dev?: boolean;
|
|
23
|
-
}) => Promise<any>;
|
|
24
19
|
export declare const compileFile: (options: {
|
|
25
20
|
schemaFileType?: string;
|
|
26
21
|
verbose?: boolean;
|
|
@@ -10,6 +10,23 @@ 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
|
-
|
|
13
|
+
import { TinaCloudSchema } from '@tinacms/schema-tools';
|
|
14
|
+
import { Database, Bridge } from '@tinacms/graphql';
|
|
15
|
+
import { ConfigBuilder } from '../../buildTina';
|
|
16
|
+
export declare const waitForDB: (ctx: {
|
|
17
|
+
builder: ConfigBuilder;
|
|
18
|
+
rootPath: string;
|
|
19
|
+
database: Database;
|
|
20
|
+
bridge: Bridge;
|
|
21
|
+
usingTs: boolean;
|
|
22
|
+
schema?: TinaCloudSchema<true>;
|
|
23
|
+
apiUrl: string;
|
|
24
|
+
}, next: any, options: {
|
|
14
25
|
verbose?: boolean;
|
|
15
26
|
}) => Promise<any>;
|
|
27
|
+
export declare const parseURL: (url: string) => {
|
|
28
|
+
branch: string;
|
|
29
|
+
isLocalClient: boolean;
|
|
30
|
+
clientId: string;
|
|
31
|
+
host: string;
|
|
32
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -302,7 +302,7 @@ var commander = __toModule(require("commander"));
|
|
|
302
302
|
|
|
303
303
|
// package.json
|
|
304
304
|
var name = "@tinacms/cli";
|
|
305
|
-
var version = "0.62.
|
|
305
|
+
var version = "0.62.3";
|
|
306
306
|
|
|
307
307
|
// src/cmds/audit/audit.ts
|
|
308
308
|
var import_graphql = __toModule(require("@tinacms/graphql"));
|
|
@@ -543,8 +543,23 @@ var chain = async (cmds, options) => {
|
|
|
543
543
|
// src/cmds/baseCmds.ts
|
|
544
544
|
var import_chalk5 = __toModule(require("chalk"));
|
|
545
545
|
|
|
546
|
-
// src/cmds/
|
|
547
|
-
var
|
|
546
|
+
// src/cmds/start-server/index.ts
|
|
547
|
+
var import_path11 = __toModule(require("path"));
|
|
548
|
+
var import_chalk4 = __toModule(require("chalk"));
|
|
549
|
+
var import_chokidar = __toModule(require("chokidar"));
|
|
550
|
+
var import_metrics2 = __toModule(require("@tinacms/metrics"));
|
|
551
|
+
|
|
552
|
+
// src/cmds/start-server/lock.ts
|
|
553
|
+
var AsyncLock = class {
|
|
554
|
+
constructor() {
|
|
555
|
+
this.disable = () => {
|
|
556
|
+
};
|
|
557
|
+
this.promise = Promise.resolve();
|
|
558
|
+
}
|
|
559
|
+
enable() {
|
|
560
|
+
this.promise = new Promise((resolve2) => this.disable = resolve2);
|
|
561
|
+
}
|
|
562
|
+
};
|
|
548
563
|
|
|
549
564
|
// src/cmds/start-server/errors/index.ts
|
|
550
565
|
var import_graphql3 = __toModule(require("@tinacms/graphql"));
|
|
@@ -581,7 +596,14 @@ var handleServerErrors = (e) => {
|
|
|
581
596
|
}
|
|
582
597
|
};
|
|
583
598
|
|
|
599
|
+
// src/buildTina/index.ts
|
|
600
|
+
var import_fs_extra6 = __toModule(require("fs-extra"));
|
|
601
|
+
var import_graphql9 = __toModule(require("@tinacms/graphql"));
|
|
602
|
+
var import_datalayer = __toModule(require("@tinacms/datalayer"));
|
|
603
|
+
var import_path8 = __toModule(require("path"));
|
|
604
|
+
|
|
584
605
|
// src/cmds/compile/index.ts
|
|
606
|
+
var _ = __toModule(require("lodash"));
|
|
585
607
|
var import_fs_extra2 = __toModule(require("fs-extra"));
|
|
586
608
|
var import_path3 = __toModule(require("path"));
|
|
587
609
|
var import_esbuild = __toModule(require("esbuild"));
|
|
@@ -631,12 +653,6 @@ var getPath = ({
|
|
|
631
653
|
}
|
|
632
654
|
return inputFile;
|
|
633
655
|
};
|
|
634
|
-
var getClientPath = ({ projectDir }) => {
|
|
635
|
-
const filename = "client";
|
|
636
|
-
const allowedTypes = ["js", "ts"];
|
|
637
|
-
const errorMessage = "Must provide a `.tina/client.{ts,js}`";
|
|
638
|
-
return getPath({ projectDir, filename, allowedTypes, errorMessage });
|
|
639
|
-
};
|
|
640
656
|
|
|
641
657
|
// src/cmds/compile/index.ts
|
|
642
658
|
var generatedFilesToRemove = [
|
|
@@ -702,75 +718,6 @@ out.jsx
|
|
|
702
718
|
var cleanup = async ({ tinaTempPath }) => {
|
|
703
719
|
await import_fs_extra2.default.remove(tinaTempPath);
|
|
704
720
|
};
|
|
705
|
-
var compileClient = async (ctx, next, options) => {
|
|
706
|
-
const root2 = ctx.rootPath;
|
|
707
|
-
if (!root2) {
|
|
708
|
-
throw new Error("ctx.rootPath has not been attached");
|
|
709
|
-
}
|
|
710
|
-
const tinaPath = import_path3.default.join(root2, ".tina");
|
|
711
|
-
const tinaGeneratedPath = import_path3.default.join(tinaPath, "__generated__");
|
|
712
|
-
const packageJSONFilePath = import_path3.default.join(root2, "package.json");
|
|
713
|
-
const tinaTempPath = import_path3.default.join(tinaGeneratedPath, "temp_client");
|
|
714
|
-
if (!options.clientFileType)
|
|
715
|
-
options = __spreadProps(__spreadValues({}, options), { clientFileType: "ts" });
|
|
716
|
-
if (options.verbose) {
|
|
717
|
-
logger.info(logText("Compiling Client..."));
|
|
718
|
-
}
|
|
719
|
-
const { clientFileType: requestedClientFileType = "ts" } = options;
|
|
720
|
-
const allowedFileTypes = ["ts", "js"];
|
|
721
|
-
if (allowedFileTypes.includes(requestedClientFileType) === false) {
|
|
722
|
-
throw new Error(`Requested schema file type '${requestedClientFileType}' is not valid. Supported schema file types: 'ts, js'`);
|
|
723
|
-
}
|
|
724
|
-
if (ctx) {
|
|
725
|
-
ctx.clientFileType = requestedClientFileType;
|
|
726
|
-
}
|
|
727
|
-
let clientExists = true;
|
|
728
|
-
const projectDir = import_path3.default.join(tinaPath, "__generated__");
|
|
729
|
-
try {
|
|
730
|
-
getClientPath({ projectDir });
|
|
731
|
-
} catch {
|
|
732
|
-
clientExists = false;
|
|
733
|
-
}
|
|
734
|
-
if (!clientExists) {
|
|
735
|
-
if (options.verbose) {
|
|
736
|
-
logger.info(logText(`.tina/client.${requestedClientFileType} not found, skipping compile client...`));
|
|
737
|
-
}
|
|
738
|
-
return next();
|
|
739
|
-
}
|
|
740
|
-
try {
|
|
741
|
-
const define = {};
|
|
742
|
-
if (!process.env.NODE_ENV) {
|
|
743
|
-
define["process.env.NODE_ENV"] = options.dev ? '"development"' : '"production"';
|
|
744
|
-
}
|
|
745
|
-
const inputFile = getClientPath({
|
|
746
|
-
projectDir
|
|
747
|
-
});
|
|
748
|
-
await transpile(inputFile, "client.js", tinaTempPath, options.verbose, define, packageJSONFilePath);
|
|
749
|
-
} catch (e) {
|
|
750
|
-
await cleanup({ tinaTempPath });
|
|
751
|
-
throw new BuildSchemaError(e);
|
|
752
|
-
}
|
|
753
|
-
Object.keys(require.cache).map((key) => {
|
|
754
|
-
if (key.startsWith(tinaTempPath)) {
|
|
755
|
-
delete require.cache[require.resolve(key)];
|
|
756
|
-
}
|
|
757
|
-
});
|
|
758
|
-
try {
|
|
759
|
-
const clientFunc = require(import_path3.default.join(tinaTempPath, "client.js"));
|
|
760
|
-
const client = clientFunc.default;
|
|
761
|
-
ctx.client = client;
|
|
762
|
-
await cleanup({ tinaTempPath });
|
|
763
|
-
} catch (e) {
|
|
764
|
-
await cleanup({ tinaTempPath });
|
|
765
|
-
if (e instanceof Error) {
|
|
766
|
-
if (e.name === "TinaSchemaValidationError") {
|
|
767
|
-
throw e;
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
throw new ExecuteSchemaError(e);
|
|
771
|
-
}
|
|
772
|
-
return next();
|
|
773
|
-
};
|
|
774
721
|
var compileFile = async (options, fileName) => {
|
|
775
722
|
const root2 = options.rootPath;
|
|
776
723
|
if (!root2) {
|
|
@@ -933,30 +880,6 @@ var loaders = {
|
|
|
933
880
|
".tsx": "tsx"
|
|
934
881
|
};
|
|
935
882
|
|
|
936
|
-
// src/cmds/start-server/index.ts
|
|
937
|
-
var import_path11 = __toModule(require("path"));
|
|
938
|
-
var import_chalk4 = __toModule(require("chalk"));
|
|
939
|
-
var import_chokidar = __toModule(require("chokidar"));
|
|
940
|
-
var import_metrics2 = __toModule(require("@tinacms/metrics"));
|
|
941
|
-
|
|
942
|
-
// src/cmds/start-server/lock.ts
|
|
943
|
-
var AsyncLock = class {
|
|
944
|
-
constructor() {
|
|
945
|
-
this.disable = () => {
|
|
946
|
-
};
|
|
947
|
-
this.promise = Promise.resolve();
|
|
948
|
-
}
|
|
949
|
-
enable() {
|
|
950
|
-
this.promise = new Promise((resolve2) => this.disable = resolve2);
|
|
951
|
-
}
|
|
952
|
-
};
|
|
953
|
-
|
|
954
|
-
// src/buildTina/index.ts
|
|
955
|
-
var import_fs_extra6 = __toModule(require("fs-extra"));
|
|
956
|
-
var import_graphql9 = __toModule(require("@tinacms/graphql"));
|
|
957
|
-
var import_datalayer = __toModule(require("@tinacms/datalayer"));
|
|
958
|
-
var import_path8 = __toModule(require("path"));
|
|
959
|
-
|
|
960
883
|
// src/cmds/query-gen/genTypes.ts
|
|
961
884
|
var import_graphql8 = __toModule(require("graphql"));
|
|
962
885
|
var import_fs_extra3 = __toModule(require("fs-extra"));
|
|
@@ -1387,6 +1310,7 @@ var buildCmdBuild = async (ctx, next, options) => {
|
|
|
1387
1310
|
usingTs: ctx.usingTs,
|
|
1388
1311
|
port: options.port
|
|
1389
1312
|
});
|
|
1313
|
+
ctx.apiUrl = apiUrl;
|
|
1390
1314
|
await buildAdmin({
|
|
1391
1315
|
local: options.local,
|
|
1392
1316
|
rootPath: ctx.rootPath,
|
|
@@ -1677,6 +1601,7 @@ or`);
|
|
|
1677
1601
|
|
|
1678
1602
|
// src/cmds/statusChecks/waitForIndexing.ts
|
|
1679
1603
|
var import_progress = __toModule(require("progress"));
|
|
1604
|
+
var import_url_pattern = __toModule(require("url-pattern"));
|
|
1680
1605
|
var POLLING_INTERVAL = 5e3;
|
|
1681
1606
|
var STATUS_INPROGRESS = "inprogress";
|
|
1682
1607
|
var STATUS_COMPLETE = "complete";
|
|
@@ -1688,11 +1613,8 @@ var IndexFailedError = class extends Error {
|
|
|
1688
1613
|
}
|
|
1689
1614
|
};
|
|
1690
1615
|
var waitForDB = async (ctx, next, options) => {
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
}
|
|
1694
|
-
const client = ctx.client;
|
|
1695
|
-
const { host, clientId, branch, isLocalClient } = client.parseURL();
|
|
1616
|
+
const token = ctx.schema.config.token;
|
|
1617
|
+
const { clientId, branch, isLocalClient, host } = parseURL(ctx.apiUrl);
|
|
1696
1618
|
if (isLocalClient) {
|
|
1697
1619
|
return next();
|
|
1698
1620
|
}
|
|
@@ -1704,8 +1626,8 @@ var waitForDB = async (ctx, next, options) => {
|
|
|
1704
1626
|
}
|
|
1705
1627
|
const headers = new Headers();
|
|
1706
1628
|
headers.append("Content-Type", "application/json");
|
|
1707
|
-
if (
|
|
1708
|
-
headers.append("X-API-KEY",
|
|
1629
|
+
if (token) {
|
|
1630
|
+
headers.append("X-API-KEY", token);
|
|
1709
1631
|
}
|
|
1710
1632
|
const response = await fetch(`https://${host}/db/${clientId}/status/${branch}`, {
|
|
1711
1633
|
method: "GET",
|
|
@@ -1744,6 +1666,32 @@ var waitForDB = async (ctx, next, options) => {
|
|
|
1744
1666
|
waitFor: pollForStatus
|
|
1745
1667
|
});
|
|
1746
1668
|
};
|
|
1669
|
+
var parseURL = (url) => {
|
|
1670
|
+
if (url.includes("localhost")) {
|
|
1671
|
+
return {
|
|
1672
|
+
host: "localhost",
|
|
1673
|
+
branch: null,
|
|
1674
|
+
isLocalClient: true,
|
|
1675
|
+
clientId: null
|
|
1676
|
+
};
|
|
1677
|
+
}
|
|
1678
|
+
const params = new URL(url);
|
|
1679
|
+
const pattern = new import_url_pattern.default("/content/:clientId/github/*", {
|
|
1680
|
+
escapeChar: " "
|
|
1681
|
+
});
|
|
1682
|
+
const result = pattern.match(params.pathname);
|
|
1683
|
+
const branch = result == null ? void 0 : result._;
|
|
1684
|
+
const clientId = result == null ? void 0 : result.clientId;
|
|
1685
|
+
if (!branch || !clientId) {
|
|
1686
|
+
throw new Error(`Invalid URL format provided. Expected: https://content.tinajs.io/content/<ClientID>/github/<Branch> but but received ${url}`);
|
|
1687
|
+
}
|
|
1688
|
+
return {
|
|
1689
|
+
host: params.host,
|
|
1690
|
+
clientId,
|
|
1691
|
+
branch,
|
|
1692
|
+
isLocalClient: false
|
|
1693
|
+
};
|
|
1694
|
+
};
|
|
1747
1695
|
|
|
1748
1696
|
// src/cmds/startSubprocess/index.ts
|
|
1749
1697
|
var import_child_process = __toModule(require("child_process"));
|
|
@@ -2371,13 +2319,53 @@ function execShellCommand(cmd) {
|
|
|
2371
2319
|
|
|
2372
2320
|
// src/cmds/statusChecks/checkClientInformation.ts
|
|
2373
2321
|
var import_progress2 = __toModule(require("progress"));
|
|
2322
|
+
async function request(args) {
|
|
2323
|
+
let data = {};
|
|
2324
|
+
const headers = new Headers();
|
|
2325
|
+
if (args.token) {
|
|
2326
|
+
headers.append("X-API-KEY", args.token);
|
|
2327
|
+
}
|
|
2328
|
+
headers.append("Content-Type", "application/json");
|
|
2329
|
+
const bodyString = JSON.stringify({
|
|
2330
|
+
query: args.query,
|
|
2331
|
+
variables: (args == null ? void 0 : args.variables) || {}
|
|
2332
|
+
});
|
|
2333
|
+
const url = args == null ? void 0 : args.url;
|
|
2334
|
+
const res = await fetch(url, {
|
|
2335
|
+
method: "POST",
|
|
2336
|
+
headers,
|
|
2337
|
+
body: bodyString,
|
|
2338
|
+
redirect: "follow"
|
|
2339
|
+
});
|
|
2340
|
+
if (!res.ok) {
|
|
2341
|
+
let additionalInfo = "";
|
|
2342
|
+
if (res.status === 401) {
|
|
2343
|
+
additionalInfo = "Please check that your client ID, URL and read only token are configured properly.";
|
|
2344
|
+
}
|
|
2345
|
+
throw new Error(`Server responded with status code ${res.status}, ${res.statusText}. ${additionalInfo ? additionalInfo : ""} Please see our FAQ for more information: https://tina.io/docs/errors/faq/`);
|
|
2346
|
+
}
|
|
2347
|
+
const json = await res.json();
|
|
2348
|
+
if (json.errors) {
|
|
2349
|
+
throw new Error(`Unable to fetch, please see our FAQ for more information: https://tina.io/docs/errors/faq/
|
|
2350
|
+
|
|
2351
|
+
Errors:
|
|
2352
|
+
${json.errors.map((error) => error.message).join("\n")}`);
|
|
2353
|
+
}
|
|
2354
|
+
return {
|
|
2355
|
+
data: json == null ? void 0 : json.data,
|
|
2356
|
+
query: args.query
|
|
2357
|
+
};
|
|
2358
|
+
}
|
|
2374
2359
|
var checkClientInfo = async (ctx, next, _options) => {
|
|
2375
2360
|
var _a;
|
|
2376
|
-
const client = ctx.client;
|
|
2377
2361
|
const config2 = (_a = ctx.schema) == null ? void 0 : _a.config;
|
|
2362
|
+
const token = config2.token;
|
|
2363
|
+
const url = ctx.apiUrl;
|
|
2378
2364
|
const bar = new import_progress2.default("Checking clientId, token and branch. :prog", 1);
|
|
2379
2365
|
try {
|
|
2380
|
-
await
|
|
2366
|
+
await request({
|
|
2367
|
+
token,
|
|
2368
|
+
url,
|
|
2381
2369
|
query: `query {
|
|
2382
2370
|
collections {
|
|
2383
2371
|
name
|
|
@@ -2542,7 +2530,6 @@ var baseCmds = [
|
|
|
2542
2530
|
checkOptions,
|
|
2543
2531
|
buildSetupCmdBuild,
|
|
2544
2532
|
buildCmdBuild,
|
|
2545
|
-
compileClient,
|
|
2546
2533
|
checkClientInfo,
|
|
2547
2534
|
waitForDB
|
|
2548
2535
|
], options)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/cli",
|
|
3
|
-
"version": "0.62.
|
|
3
|
+
"version": "0.62.3",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -52,11 +52,11 @@
|
|
|
52
52
|
"@graphql-codegen/visitor-plugin-common": "^2.4.0",
|
|
53
53
|
"@graphql-tools/graphql-file-loader": "^7.2.0",
|
|
54
54
|
"@graphql-tools/load": "^7.3.2",
|
|
55
|
-
"@tinacms/app": "0.0.
|
|
55
|
+
"@tinacms/app": "0.0.28",
|
|
56
56
|
"@tinacms/datalayer": "0.2.4",
|
|
57
|
-
"@tinacms/graphql": "0.63.
|
|
57
|
+
"@tinacms/graphql": "0.63.20",
|
|
58
58
|
"@tinacms/metrics": "0.0.3",
|
|
59
|
-
"@tinacms/schema-tools": "0.2.
|
|
59
|
+
"@tinacms/schema-tools": "0.2.2",
|
|
60
60
|
"add": "^2.0.6",
|
|
61
61
|
"ajv": "^6.12.3",
|
|
62
62
|
"altair-express-middleware": "4.0.6",
|
|
@@ -81,6 +81,7 @@
|
|
|
81
81
|
"log4js": "^6.4.0",
|
|
82
82
|
"multer": "1.4.5-lts.1",
|
|
83
83
|
"normalize-path": "^3.0.0",
|
|
84
|
+
"url-pattern": "^1.0.3",
|
|
84
85
|
"progress": "^2.0.3",
|
|
85
86
|
"prompts": "^2.4.1",
|
|
86
87
|
"yarn": "^1.22.17",
|