@tinacms/cli 0.56.5 → 0.58.0
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 +47 -0
- package/dist/cmds/compile/index.d.ts +1 -0
- package/dist/cmds/init/setup-files/index.d.ts +1 -2
- package/dist/cmds/start-server/index.d.ts +3 -2
- package/dist/cmds/start-server/server.d.ts +1 -1
- package/dist/codegen/index.d.ts +3 -1
- package/dist/codegen/plugin.d.ts +17 -0
- package/dist/codegen/sdkPlugin/config.d.ts +24 -0
- package/dist/codegen/sdkPlugin/index.d.ts +27 -0
- package/dist/codegen/sdkPlugin/visitor.d.ts +24 -0
- package/dist/index.js +267 -149
- package/package.json +14 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
# tinacms-cli
|
|
2
2
|
|
|
3
|
+
## 0.58.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- fa7a0419f: Adds experimental support for a data layer between file-based content and the GraphQL API. This allows documents to be indexed so the CMS can behave more like a traditional CMS, with the ability enforce foreign reference constraints and filtering/pagination capabilities.
|
|
8
|
+
- 8c14f29ef: Updated cli to include a new option, `--noSDK`. When this flag is present it will not generate the SDK.
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- 9c5f888a3: Modifies `tinacms init` for `TinaAdmin`-ready page
|
|
13
|
+
- Updated dependencies [eb5fbfac7]
|
|
14
|
+
- Updated dependencies [fa7a0419f]
|
|
15
|
+
- Updated dependencies [47d126029]
|
|
16
|
+
- @tinacms/graphql@0.58.0
|
|
17
|
+
|
|
18
|
+
## 0.57.2
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- edb2f4011: Trim path property on collections during compilation
|
|
23
|
+
- Updated dependencies [edb2f4011]
|
|
24
|
+
- @tinacms/graphql@0.57.2
|
|
25
|
+
|
|
26
|
+
## 0.57.1
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- 50710e1d0: Add no-check for Typescript-generated file
|
|
31
|
+
- c78d981e6: Reset entire **generated** folder on re-compile
|
|
32
|
+
- Updated dependencies [60729f60c]
|
|
33
|
+
- @tinacms/graphql@0.57.1
|
|
34
|
+
|
|
35
|
+
## 0.57.0
|
|
36
|
+
|
|
37
|
+
### Minor Changes
|
|
38
|
+
|
|
39
|
+
- d1ed404ba: Add support for auto-generated SDK for type-safe data fetching
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- 138ceb8c4: Clean up dependencies
|
|
44
|
+
- Updated dependencies [138ceb8c4]
|
|
45
|
+
- Updated dependencies [577d6a5ad]
|
|
46
|
+
- Updated dependencies [ed277e3bd]
|
|
47
|
+
- Updated dependencies [d1ed404ba]
|
|
48
|
+
- @tinacms/graphql@0.57.0
|
|
49
|
+
|
|
3
50
|
## 0.56.5
|
|
4
51
|
|
|
5
52
|
### Patch Changes
|
|
@@ -11,5 +11,6 @@ See the License for the specific language governing permissions and
|
|
|
11
11
|
limitations under the License.
|
|
12
12
|
*/
|
|
13
13
|
import type { TinaCloudSchema } from '@tinacms/graphql';
|
|
14
|
+
export declare const resetGeneratedFolder: () => Promise<void>;
|
|
14
15
|
export declare const compile: (_ctx: any, _next: any) => Promise<void>;
|
|
15
16
|
export declare const defineSchema: (config: TinaCloudSchema) => TinaCloudSchema;
|
|
@@ -10,8 +10,7 @@ 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 adminPage = "import {
|
|
14
|
-
export declare const exitAdminPage = "import { useEffect } from \"react\";\nimport { useRouter } from \"next/router\";\nimport { useEditState } from \"tinacms/dist/edit-state\";\n\nconst GoToEditPage = () => {\n const { setEdit } = useEditState();\n const router = useRouter();\n useEffect(() => {\n setEdit(false);\n router.back();\n }, []);\n return <div>Exiting edit mode..</div>;;\n};\n\nexport default GoToEditPage;\n";
|
|
13
|
+
export declare const adminPage = "import { TinaAdmin } from 'tinacms';\nexport default TinaAdmin;\n";
|
|
15
14
|
export declare const blogPost = "---\ntitle: Vote For Pedro\n---\n# Welcome to the blog.\n\n> To edit this site head over to the [` /\n admin`](/admin) route. Then click the pencil icon in the bottom lefthand corner to start editing \uD83E\uDD99. \n\n\n# Dixi gaude Arethusa\n\n## Oscula mihi\n\nLorem markdownum numerabilis armentorum platanus, cultros coniunx sibi per\nsilvas, nostris clausit sequemur diverso scopulosque. Fecit tum alta sed non\nfalcato murmura, geminas donata Amyntore, quoque Nox. Invitam inquit, modo\nnocte; ut ignis faciemque manes in imagine sinistra ut mucrone non ramos\nsepulcro supplex. Crescentesque populos motura, fit cumque. Verumque est; retro\nsibi tristia bracchia Aetola telae caruerunt et.\n\n\n## Mutato fefellimus sit demisit aut alterius sollicito\n\nPhaethonteos vestes quem involvite iuvenca; furiali anne: sati totumque,\n**corpora** cum rapacibus nunc! Nervis repetatne, miserabile doleas, deprensum\nhunc, fluctus Threicio, ad urbes, magicaeque, quid. Per credensque series adicis\npoteram [quidem](#)! Iam uni mensas victrix\nvittas ut flumina Satyri adulter; bellum iacet domitae repercusso truncis urnis\nmille rigidi sub taurum.\n\n\n";
|
|
16
15
|
export declare const nextPostPage: () => string;
|
|
17
16
|
export declare const AppJsContent: (extraImports?: string) => string;
|
|
@@ -13,8 +13,9 @@ limitations under the License.
|
|
|
13
13
|
interface Options {
|
|
14
14
|
port?: number;
|
|
15
15
|
command?: string;
|
|
16
|
-
|
|
16
|
+
experimentalData?: boolean;
|
|
17
17
|
noWatch?: boolean;
|
|
18
|
+
noSDK: boolean;
|
|
18
19
|
}
|
|
19
|
-
export declare function startServer(_ctx: any, _next: any, { port, command,
|
|
20
|
+
export declare function startServer(_ctx: any, _next: any, { port, command, noWatch, experimentalData, noSDK }: Options): Promise<void>;
|
|
20
21
|
export {};
|
package/dist/codegen/index.d.ts
CHANGED
|
@@ -11,4 +11,6 @@ See the License for the specific language governing permissions and
|
|
|
11
11
|
limitations under the License.
|
|
12
12
|
*/
|
|
13
13
|
import { GraphQLSchema } from 'graphql';
|
|
14
|
-
export declare const generateTypes: (schema: GraphQLSchema
|
|
14
|
+
export declare const generateTypes: (schema: GraphQLSchema, queryPathGlob?: string, fragDocPath?: string, options?: {
|
|
15
|
+
noSDK: boolean;
|
|
16
|
+
}) => Promise<string>;
|
|
@@ -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
|
+
import type { PluginFunction } from '@graphql-codegen/plugin-helpers';
|
|
14
|
+
export declare const AddGeneratedClientFunc: PluginFunction;
|
|
15
|
+
export declare const AddGeneratedClient: {
|
|
16
|
+
plugin: PluginFunction<any, import("@graphql-codegen/plugin-helpers").Types.PluginOutput>;
|
|
17
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
import { RawClientSideBasePluginConfig } from '@graphql-codegen/visitor-plugin-common';
|
|
14
|
+
/**
|
|
15
|
+
* This plugin generate a generic SDK (without any Requester implemented), allow you to easily customize the way you fetch your data, without loosing the strongly-typed integration.
|
|
16
|
+
*/
|
|
17
|
+
export interface RawGenericSdkPluginConfig extends RawClientSideBasePluginConfig {
|
|
18
|
+
/**
|
|
19
|
+
* usingObservableFrom: "import Observable from 'zen-observable';"
|
|
20
|
+
* OR
|
|
21
|
+
* usingObservableFrom: "import { Observable } from 'rxjs';"
|
|
22
|
+
*/
|
|
23
|
+
usingObservableFrom?: string;
|
|
24
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
/**
|
|
14
|
+
* PLEASE READ THIS:
|
|
15
|
+
*
|
|
16
|
+
* This plugin is directly copied from https://github.com/dotansimha/graphql-code-generator/tree/master/packages/plugins/typescript/generic-sdk
|
|
17
|
+
*
|
|
18
|
+
* The reason this was needed is because we had to modified the return type of the SDK client. We need to return {data, variables, query}. While the other one just returned the data.
|
|
19
|
+
*
|
|
20
|
+
* This is the same as the above link and may need to be updated time to time. (for example if we want to support GQL v16). There is only one line that differs from the original. (This is shown)
|
|
21
|
+
*/
|
|
22
|
+
import { PluginFunction, PluginValidateFn } from '@graphql-codegen/plugin-helpers';
|
|
23
|
+
import { RawGenericSdkPluginConfig } from './config';
|
|
24
|
+
import { GenericSdkVisitor } from './visitor';
|
|
25
|
+
export declare const plugin: PluginFunction<RawGenericSdkPluginConfig>;
|
|
26
|
+
export declare const validate: PluginValidateFn<any>;
|
|
27
|
+
export { GenericSdkVisitor };
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
import { ClientSideBasePluginConfig, ClientSideBaseVisitor, LoadedFragment } from '@graphql-codegen/visitor-plugin-common';
|
|
14
|
+
import { GraphQLSchema, OperationDefinitionNode } from 'graphql';
|
|
15
|
+
import { RawGenericSdkPluginConfig } from './config';
|
|
16
|
+
export interface GenericSdkPluginConfig extends ClientSideBasePluginConfig {
|
|
17
|
+
usingObservableFrom: string;
|
|
18
|
+
}
|
|
19
|
+
export declare class GenericSdkVisitor extends ClientSideBaseVisitor<RawGenericSdkPluginConfig, GenericSdkPluginConfig> {
|
|
20
|
+
private _operationsToInclude;
|
|
21
|
+
constructor(schema: GraphQLSchema, fragments: LoadedFragment[], rawConfig: RawGenericSdkPluginConfig);
|
|
22
|
+
protected buildOperation(node: OperationDefinitionNode, documentVariableName: string, operationType: string, operationResultType: string, operationVariablesTypes: string): string;
|
|
23
|
+
get sdkContent(): string;
|
|
24
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -25,22 +25,21 @@ var __toModule = (module2) => {
|
|
|
25
25
|
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);
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
// pnp:/
|
|
28
|
+
// pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/cmds/start-server/server.ts
|
|
29
29
|
var server_exports = {};
|
|
30
30
|
__export(server_exports, {
|
|
31
31
|
default: () => server_default
|
|
32
32
|
});
|
|
33
|
-
var
|
|
33
|
+
var import_cors, import_http, import_express, import_altair_express_middleware, import_body_parser, GITHUB_ACCESS_TOKEN, gqlServer, server_default;
|
|
34
34
|
var init_server = __esm({
|
|
35
|
-
"pnp:/
|
|
36
|
-
import_path2 = __toModule(require("path"));
|
|
35
|
+
"pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/cmds/start-server/server.ts"() {
|
|
37
36
|
import_cors = __toModule(require("cors"));
|
|
38
37
|
import_http = __toModule(require("http"));
|
|
39
38
|
import_express = __toModule(require("express"));
|
|
40
39
|
import_altair_express_middleware = __toModule(require("altair-express-middleware"));
|
|
41
40
|
import_body_parser = __toModule(require("body-parser"));
|
|
42
41
|
GITHUB_ACCESS_TOKEN = process.env.GITHUB_PERSONAL_ACCESS_TOKEN;
|
|
43
|
-
gqlServer = async () => {
|
|
42
|
+
gqlServer = async (database) => {
|
|
44
43
|
const gqlPackage = require("@tinacms/graphql");
|
|
45
44
|
const app = (0, import_express.default)();
|
|
46
45
|
const server = import_http.default.createServer(app);
|
|
@@ -63,11 +62,10 @@ var init_server = __esm({
|
|
|
63
62
|
}
|
|
64
63
|
}`
|
|
65
64
|
}));
|
|
66
|
-
const rootPath = import_path2.default.join(process.cwd());
|
|
67
65
|
app.post("/graphql", async (req, res) => {
|
|
68
66
|
const { query, variables } = req.body;
|
|
69
|
-
const result = await gqlPackage.
|
|
70
|
-
|
|
67
|
+
const result = await gqlPackage.resolve({
|
|
68
|
+
database,
|
|
71
69
|
query,
|
|
72
70
|
variables
|
|
73
71
|
});
|
|
@@ -109,18 +107,18 @@ var init_server = __esm({
|
|
|
109
107
|
}
|
|
110
108
|
});
|
|
111
109
|
|
|
112
|
-
// pnp:/
|
|
110
|
+
// pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/index.ts
|
|
113
111
|
__export(exports, {
|
|
114
112
|
defineSchema: () => defineSchema,
|
|
115
113
|
init: () => init
|
|
116
114
|
});
|
|
117
115
|
var commander = __toModule(require("commander"));
|
|
118
116
|
|
|
119
|
-
// pnp:/
|
|
117
|
+
// pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/package.json
|
|
120
118
|
var name = "@tinacms/cli";
|
|
121
|
-
var version = "0.
|
|
119
|
+
var version = "0.57.2";
|
|
122
120
|
|
|
123
|
-
// pnp:/
|
|
121
|
+
// pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/utils/theme.ts
|
|
124
122
|
var import_chalk = __toModule(require("chalk"));
|
|
125
123
|
var successText = import_chalk.default.bold.green;
|
|
126
124
|
var dangerText = import_chalk.default.bold.red;
|
|
@@ -131,7 +129,7 @@ var logText = import_chalk.default.italic.gray;
|
|
|
131
129
|
var warnText = import_chalk.default.yellowBright.bgBlack;
|
|
132
130
|
var CONFIRMATION_TEXT = import_chalk.default.dim("enter to confirm");
|
|
133
131
|
|
|
134
|
-
// pnp:/
|
|
132
|
+
// pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/middleware.ts
|
|
135
133
|
var chain = async (cmds, options) => {
|
|
136
134
|
const ctx = {};
|
|
137
135
|
const next = async (middlewareIndex) => {
|
|
@@ -150,10 +148,10 @@ var chain = async (cmds, options) => {
|
|
|
150
148
|
}
|
|
151
149
|
};
|
|
152
150
|
|
|
153
|
-
// pnp:/
|
|
151
|
+
// pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/cmds/query-gen/attachSchema.ts
|
|
154
152
|
var import_graphql = __toModule(require("@tinacms/graphql"));
|
|
155
153
|
|
|
156
|
-
// pnp:/
|
|
154
|
+
// pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/logger/index.ts
|
|
157
155
|
var import_log4js = __toModule(require("log4js"));
|
|
158
156
|
var logger = import_log4js.default.getLogger();
|
|
159
157
|
import_log4js.default.configure({
|
|
@@ -164,36 +162,190 @@ import_log4js.default.configure({
|
|
|
164
162
|
});
|
|
165
163
|
logger.level = "info";
|
|
166
164
|
|
|
167
|
-
// pnp:/
|
|
165
|
+
// pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/cmds/query-gen/attachSchema.ts
|
|
168
166
|
async function attachSchema(ctx, next, options) {
|
|
169
167
|
logger.info(logText("Building schema..."));
|
|
170
168
|
const rootPath = process.cwd();
|
|
171
|
-
const
|
|
169
|
+
const bridge = new import_graphql.FilesystemBridge(rootPath);
|
|
170
|
+
const store = new import_graphql.FilesystemStore({ rootPath });
|
|
171
|
+
const database = await (0, import_graphql.createDatabase)({ store, bridge });
|
|
172
|
+
const schema = await (0, import_graphql.buildSchema)(rootPath, database);
|
|
172
173
|
ctx.schema = schema;
|
|
173
174
|
next();
|
|
174
175
|
}
|
|
175
176
|
|
|
176
|
-
// pnp:/
|
|
177
|
-
var
|
|
177
|
+
// pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/codegen/index.ts
|
|
178
|
+
var import_graphql5 = __toModule(require("graphql"));
|
|
178
179
|
var import_core = __toModule(require("@graphql-codegen/core"));
|
|
179
180
|
var import_typescript = __toModule(require("@graphql-codegen/typescript"));
|
|
180
181
|
var import_typescript_operations = __toModule(require("@graphql-codegen/typescript-operations"));
|
|
181
|
-
|
|
182
|
+
|
|
183
|
+
// pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/codegen/plugin.ts
|
|
184
|
+
var AddGeneratedClientFunc = (_schema, _documents, _config, _info) => {
|
|
185
|
+
return `
|
|
186
|
+
// TinaSDK generated code
|
|
187
|
+
import { getStaticPropsForTina } from 'tinacms'
|
|
188
|
+
const requester: (doc: any, vars?: any, options?: any) => Promise<any> = async (
|
|
189
|
+
doc,
|
|
190
|
+
vars,
|
|
191
|
+
_options
|
|
192
|
+
) => {
|
|
193
|
+
// const data = await tinaClient.request(doc, { variables: vars });
|
|
194
|
+
const res = await await getStaticPropsForTina({query: doc, variables: vars})
|
|
195
|
+
return res
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* @experimental this class can be used but may change in the future
|
|
200
|
+
**/
|
|
201
|
+
export const ExperimentalGetTinaClient = ()=>getSdk(requester)
|
|
202
|
+
`;
|
|
203
|
+
};
|
|
204
|
+
var AddGeneratedClient = {
|
|
205
|
+
plugin: AddGeneratedClientFunc
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
// pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/codegen/sdkPlugin/index.ts
|
|
209
|
+
var import_graphql3 = __toModule(require("graphql"));
|
|
210
|
+
var import_graphql4 = __toModule(require("graphql"));
|
|
211
|
+
var import_path = __toModule(require("path"));
|
|
212
|
+
|
|
213
|
+
// pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/codegen/sdkPlugin/visitor.ts
|
|
214
|
+
var import_visitor_plugin_common = __toModule(require("@graphql-codegen/visitor-plugin-common"));
|
|
215
|
+
var import_auto_bind = __toModule(require("auto-bind"));
|
|
216
|
+
var import_graphql2 = __toModule(require("graphql"));
|
|
217
|
+
var GenericSdkVisitor = class extends import_visitor_plugin_common.ClientSideBaseVisitor {
|
|
218
|
+
constructor(schema, fragments, rawConfig) {
|
|
219
|
+
super(schema, fragments, rawConfig, {
|
|
220
|
+
usingObservableFrom: rawConfig.usingObservableFrom
|
|
221
|
+
});
|
|
222
|
+
this._operationsToInclude = [];
|
|
223
|
+
(0, import_auto_bind.default)(this);
|
|
224
|
+
if (this.config.usingObservableFrom) {
|
|
225
|
+
this._additionalImports.push(this.config.usingObservableFrom);
|
|
226
|
+
}
|
|
227
|
+
if (this.config.documentMode !== import_visitor_plugin_common.DocumentMode.string) {
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
buildOperation(node, documentVariableName, operationType, operationResultType, operationVariablesTypes) {
|
|
231
|
+
if (node.name == null) {
|
|
232
|
+
throw new Error("Plugin 'generic-sdk' cannot generate SDK for unnamed operation.\n\n" + (0, import_graphql2.print)(node));
|
|
233
|
+
} else {
|
|
234
|
+
this._operationsToInclude.push({
|
|
235
|
+
node,
|
|
236
|
+
documentVariableName,
|
|
237
|
+
operationType,
|
|
238
|
+
operationResultType: `{data: ${operationResultType}, variables: ${operationVariablesTypes}, query: string}`,
|
|
239
|
+
operationVariablesTypes
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
get sdkContent() {
|
|
245
|
+
const usingObservable = !!this.config.usingObservableFrom;
|
|
246
|
+
const allPossibleActions = this._operationsToInclude.map((o) => {
|
|
247
|
+
const optionalVariables = !o.node.variableDefinitions || o.node.variableDefinitions.length === 0 || o.node.variableDefinitions.every((v) => v.type.kind !== import_graphql2.Kind.NON_NULL_TYPE || v.defaultValue);
|
|
248
|
+
const returnType = usingObservable && o.operationType === "Subscription" ? "Observable" : "Promise";
|
|
249
|
+
return `${o.node.name.value}(variables${optionalVariables ? "?" : ""}: ${o.operationVariablesTypes}, options?: C): ${returnType}<${o.operationResultType}> {
|
|
250
|
+
return requester<${o.operationResultType}, ${o.operationVariablesTypes}>(${o.documentVariableName}, variables, options);
|
|
251
|
+
}`;
|
|
252
|
+
}).map((s) => (0, import_visitor_plugin_common.indentMultiline)(s, 2));
|
|
253
|
+
return `export type Requester<C= {}> = <R, V>(doc: ${this.config.documentMode === import_visitor_plugin_common.DocumentMode.string ? "string" : "DocumentNode"}, vars?: V, options?: C) => ${usingObservable ? "Promise<R> & Observable<R>" : "Promise<R>"}
|
|
254
|
+
export function getSdk<C>(requester: Requester<C>) {
|
|
255
|
+
return {
|
|
256
|
+
${allPossibleActions.join(",\n")}
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
export type Sdk = ReturnType<typeof getSdk>;`;
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
// pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/codegen/sdkPlugin/index.ts
|
|
264
|
+
var plugin = (schema, documents, config) => {
|
|
265
|
+
const allAst = (0, import_graphql4.concatAST)(documents.reduce((prev, v) => {
|
|
266
|
+
return [...prev, v.document];
|
|
267
|
+
}, []));
|
|
268
|
+
const allFragments = [
|
|
269
|
+
...allAst.definitions.filter((d) => d.kind === import_graphql4.Kind.FRAGMENT_DEFINITION).map((fragmentDef) => ({
|
|
270
|
+
node: fragmentDef,
|
|
271
|
+
name: fragmentDef.name.value,
|
|
272
|
+
onType: fragmentDef.typeCondition.name.value,
|
|
273
|
+
isExternal: false
|
|
274
|
+
})),
|
|
275
|
+
...config.externalFragments || []
|
|
276
|
+
];
|
|
277
|
+
const visitor = new GenericSdkVisitor(schema, allFragments, config);
|
|
278
|
+
const visitorResult = (0, import_graphql3.visit)(allAst, { leave: visitor });
|
|
279
|
+
return {
|
|
280
|
+
prepend: visitor.getImports(),
|
|
281
|
+
content: [
|
|
282
|
+
visitor.fragments,
|
|
283
|
+
...visitorResult.definitions.filter((t) => typeof t === "string"),
|
|
284
|
+
visitor.sdkContent
|
|
285
|
+
].join("\n")
|
|
286
|
+
};
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
// pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/codegen/index.ts
|
|
290
|
+
var import_load = __toModule(require("@graphql-tools/load"));
|
|
291
|
+
var import_graphql_file_loader = __toModule(require("@graphql-tools/graphql-file-loader"));
|
|
292
|
+
var generateTypes = async (schema, queryPathGlob = process.cwd(), fragDocPath = process.cwd(), options = { noSDK: false }) => {
|
|
182
293
|
logger.info("Generating types...");
|
|
183
294
|
try {
|
|
295
|
+
let docs = [];
|
|
296
|
+
let fragDocs = [];
|
|
297
|
+
try {
|
|
298
|
+
if (!options.noSDK) {
|
|
299
|
+
docs = await (0, import_load.loadDocuments)(queryPathGlob, {
|
|
300
|
+
loaders: [new import_graphql_file_loader.GraphQLFileLoader()]
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
} catch (e) {
|
|
304
|
+
let showErrorMessage = true;
|
|
305
|
+
const message = e.message || "";
|
|
306
|
+
if (message.includes("Unable to find any GraphQL type definitions for the following pointers:")) {
|
|
307
|
+
showErrorMessage = false;
|
|
308
|
+
}
|
|
309
|
+
if (showErrorMessage) {
|
|
310
|
+
console.error(e);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
try {
|
|
314
|
+
if (!options.noSDK) {
|
|
315
|
+
fragDocs = await (0, import_load.loadDocuments)(fragDocPath, {
|
|
316
|
+
loaders: [new import_graphql_file_loader.GraphQLFileLoader()]
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
} catch (error) {
|
|
320
|
+
console.error(error);
|
|
321
|
+
}
|
|
184
322
|
const res = await (0, import_core.codegen)({
|
|
185
|
-
filename: process.cwd()
|
|
186
|
-
schema: (0,
|
|
187
|
-
documents: [],
|
|
323
|
+
filename: process.cwd(),
|
|
324
|
+
schema: (0, import_graphql5.parse)((0, import_graphql5.printSchema)(schema)),
|
|
325
|
+
documents: [...docs, ...fragDocs],
|
|
188
326
|
config: {},
|
|
189
|
-
plugins: [
|
|
327
|
+
plugins: [
|
|
328
|
+
{ typescript: {} },
|
|
329
|
+
{ typescriptOperations: {} },
|
|
330
|
+
{
|
|
331
|
+
typescriptSdk: {
|
|
332
|
+
gqlImport: "tinacms#gql",
|
|
333
|
+
documentNodeImport: "tinacms#DocumentNode"
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
{ AddGeneratedClient: {} }
|
|
337
|
+
],
|
|
190
338
|
pluginMap: {
|
|
191
339
|
typescript: {
|
|
192
340
|
plugin: import_typescript.plugin
|
|
193
341
|
},
|
|
194
342
|
typescriptOperations: {
|
|
195
343
|
plugin: import_typescript_operations.plugin
|
|
196
|
-
}
|
|
344
|
+
},
|
|
345
|
+
typescriptSdk: {
|
|
346
|
+
plugin
|
|
347
|
+
},
|
|
348
|
+
AddGeneratedClient
|
|
197
349
|
}
|
|
198
350
|
});
|
|
199
351
|
return res;
|
|
@@ -202,17 +354,20 @@ var generateTypes = async (schema) => {
|
|
|
202
354
|
}
|
|
203
355
|
};
|
|
204
356
|
|
|
205
|
-
// pnp:/
|
|
206
|
-
var
|
|
357
|
+
// pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/cmds/query-gen/genTypes.ts
|
|
358
|
+
var import_graphql6 = __toModule(require("graphql"));
|
|
207
359
|
var import_fs_extra = __toModule(require("fs-extra"));
|
|
208
360
|
async function genTypes({ schema }, next, options) {
|
|
209
|
-
const typescriptTypes = await generateTypes(schema);
|
|
210
361
|
const typesPath = process.cwd() + "/.tina/__generated__/types.ts";
|
|
211
|
-
|
|
362
|
+
const fragPath = process.cwd() + "/.tina/__generated__/*.{graphql,gql}";
|
|
363
|
+
const queryPathGlob = process.cwd() + "/.tina/queries/**/*.{graphql,gql}";
|
|
364
|
+
const typescriptTypes = await generateTypes(schema, queryPathGlob, fragPath, options);
|
|
365
|
+
await import_fs_extra.default.outputFile(typesPath, `//@ts-nocheck
|
|
366
|
+
// DO NOT MODIFY THIS FILE. This file is automatically generated by Tina
|
|
212
367
|
${typescriptTypes}
|
|
213
368
|
`);
|
|
214
369
|
logger.info(`Typescript types => ${successText(typesPath)}`);
|
|
215
|
-
const schemaString = await (0,
|
|
370
|
+
const schemaString = await (0, import_graphql6.printSchema)(schema);
|
|
216
371
|
const schemaPath = process.cwd() + "/.tina/__generated__/schema.gql";
|
|
217
372
|
await import_fs_extra.default.outputFile(schemaPath, `# DO NOT MODIFY THIS FILE. This file is automatically generated by Tina
|
|
218
373
|
${schemaString}
|
|
@@ -225,19 +380,19 @@ schema {
|
|
|
225
380
|
next();
|
|
226
381
|
}
|
|
227
382
|
|
|
228
|
-
// pnp:/
|
|
383
|
+
// pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/cmds/start-server/index.ts
|
|
229
384
|
var import_child_process = __toModule(require("child_process"));
|
|
230
385
|
var import_path3 = __toModule(require("path"));
|
|
231
|
-
var
|
|
386
|
+
var import_graphql7 = __toModule(require("@tinacms/graphql"));
|
|
232
387
|
|
|
233
|
-
// pnp:/
|
|
388
|
+
// pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/cmds/compile/index.ts
|
|
234
389
|
var import_fast_glob = __toModule(require("fast-glob"));
|
|
235
390
|
var import_normalize_path = __toModule(require("normalize-path"));
|
|
236
|
-
var
|
|
391
|
+
var import_path2 = __toModule(require("path"));
|
|
237
392
|
var import_fs_extra2 = __toModule(require("fs-extra"));
|
|
238
393
|
var ts = __toModule(require("typescript"));
|
|
239
394
|
|
|
240
|
-
// pnp:/
|
|
395
|
+
// pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/cmds/compile/defaultSchema.ts
|
|
241
396
|
var defaultSchema = `
|
|
242
397
|
import { defineSchema } from "@tinacms/cli";
|
|
243
398
|
|
|
@@ -268,44 +423,54 @@ export default defineSchema({
|
|
|
268
423
|
});
|
|
269
424
|
`;
|
|
270
425
|
|
|
271
|
-
// pnp:/
|
|
272
|
-
var tinaPath =
|
|
273
|
-
var
|
|
274
|
-
var
|
|
426
|
+
// pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/cmds/compile/index.ts
|
|
427
|
+
var tinaPath = import_path2.default.join(process.cwd(), ".tina");
|
|
428
|
+
var tinaGeneratedPath = import_path2.default.join(tinaPath, "__generated__");
|
|
429
|
+
var tinaTempPath = import_path2.default.join(tinaGeneratedPath, "temp");
|
|
430
|
+
var tinaConfigPath = import_path2.default.join(tinaGeneratedPath, "config");
|
|
431
|
+
var resetGeneratedFolder = async () => {
|
|
432
|
+
try {
|
|
433
|
+
await import_fs_extra2.default.rmdir(tinaGeneratedPath, {
|
|
434
|
+
recursive: true
|
|
435
|
+
});
|
|
436
|
+
} catch (e) {
|
|
437
|
+
console.log(e);
|
|
438
|
+
}
|
|
439
|
+
await import_fs_extra2.default.mkdir(tinaGeneratedPath);
|
|
440
|
+
await import_fs_extra2.default.outputFile(import_path2.default.join(tinaGeneratedPath, ".gitignore"), "db");
|
|
441
|
+
};
|
|
275
442
|
var compile = async (_ctx, _next) => {
|
|
276
443
|
logger.info(logText("Compiling..."));
|
|
277
|
-
if (!import_fs_extra2.default.existsSync(tinaPath) || !import_fs_extra2.default.existsSync(
|
|
444
|
+
if (!import_fs_extra2.default.existsSync(tinaPath) || !import_fs_extra2.default.existsSync(import_path2.default.join(tinaPath, "schema.ts"))) {
|
|
278
445
|
logger.info(dangerText(`
|
|
279
446
|
.tina/schema.ts not found, Creating one for you...
|
|
280
447
|
See Documentation: https://tina.io/docs/tina-cloud/cli/#getting-started"
|
|
281
448
|
`));
|
|
282
|
-
const file =
|
|
449
|
+
const file = import_path2.default.join(tinaPath, "schema.ts");
|
|
283
450
|
await import_fs_extra2.default.ensureFile(file);
|
|
284
451
|
await import_fs_extra2.default.writeFile(file, defaultSchema);
|
|
285
452
|
}
|
|
286
|
-
await import_fs_extra2.default.remove(tinaTempPath);
|
|
287
|
-
await import_fs_extra2.default.remove(tinaConfigPath);
|
|
288
453
|
await transpile2(tinaPath, tinaTempPath);
|
|
289
454
|
Object.keys(require.cache).map((key) => {
|
|
290
455
|
if (key.startsWith(tinaTempPath)) {
|
|
291
456
|
delete require.cache[require.resolve(key)];
|
|
292
457
|
}
|
|
293
458
|
});
|
|
294
|
-
const schemaFunc = require(
|
|
459
|
+
const schemaFunc = require(import_path2.default.join(tinaTempPath, "schema.js"));
|
|
295
460
|
const schemaObject = schemaFunc.default;
|
|
296
|
-
await import_fs_extra2.default.outputFile(
|
|
461
|
+
await import_fs_extra2.default.outputFile(import_path2.default.join(tinaConfigPath, "schema.json"), JSON.stringify(schemaObject, null, 2));
|
|
297
462
|
await import_fs_extra2.default.remove(tinaTempPath);
|
|
298
463
|
};
|
|
299
464
|
var transpile2 = async (projectDir, tempDir) => {
|
|
300
465
|
logger.info(logText("Transpiling..."));
|
|
301
466
|
const posixProjectDir = (0, import_normalize_path.default)(projectDir);
|
|
302
467
|
const posixTempDir = (0, import_normalize_path.default)(tempDir);
|
|
303
|
-
return Promise.all(import_fast_glob.default.sync(
|
|
468
|
+
return Promise.all(import_fast_glob.default.sync(import_path2.default.join(projectDir, "**", "*.ts").replace(/\\/g, "/"), {
|
|
304
469
|
ignore: [
|
|
305
|
-
|
|
470
|
+
import_path2.default.join(projectDir, "__generated__", "**", "*.ts").replace(/\\/g, "/")
|
|
306
471
|
]
|
|
307
472
|
}).map(async function(file) {
|
|
308
|
-
const fullPath =
|
|
473
|
+
const fullPath = import_path2.default.resolve(file);
|
|
309
474
|
const contents = await import_fs_extra2.default.readFileSync(fullPath).toString();
|
|
310
475
|
const newContent = ts.transpile(contents);
|
|
311
476
|
const newPath = file.replace(posixProjectDir, posixTempDir).replace(".ts", ".js");
|
|
@@ -317,10 +482,18 @@ var defineSchema = (config) => {
|
|
|
317
482
|
return config;
|
|
318
483
|
};
|
|
319
484
|
|
|
320
|
-
// pnp:/
|
|
485
|
+
// pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/cmds/start-server/index.ts
|
|
321
486
|
var import_chokidar = __toModule(require("chokidar"));
|
|
322
487
|
var gqlPackageFile = require.resolve("@tinacms/graphql");
|
|
323
|
-
async function startServer(_ctx, _next, { port = 4001, command,
|
|
488
|
+
async function startServer(_ctx, _next, { port = 4001, command, noWatch, experimentalData, noSDK }) {
|
|
489
|
+
const rootPath = process.cwd();
|
|
490
|
+
if (!process.env.CI && !noWatch) {
|
|
491
|
+
await resetGeneratedFolder();
|
|
492
|
+
}
|
|
493
|
+
const bridge = new import_graphql7.FilesystemBridge(rootPath);
|
|
494
|
+
const store = experimentalData ? new import_graphql7.LevelStore(rootPath) : new import_graphql7.FilesystemStore({ rootPath });
|
|
495
|
+
const shouldBuild = bridge.supportsBuilding();
|
|
496
|
+
const database = await (0, import_graphql7.createDatabase)({ store, bridge });
|
|
324
497
|
const startSubprocess = () => {
|
|
325
498
|
if (typeof command === "string") {
|
|
326
499
|
const commands = command.split(" ");
|
|
@@ -343,38 +516,42 @@ stack: ${code.stack || "No stack was provided"}`);
|
|
|
343
516
|
});
|
|
344
517
|
}
|
|
345
518
|
};
|
|
346
|
-
const rootPath = process.cwd();
|
|
347
519
|
let ready = false;
|
|
348
520
|
if (!noWatch && !process.env.CI) {
|
|
349
|
-
import_chokidar.default.watch(`${rootPath}/**/*.ts
|
|
521
|
+
import_chokidar.default.watch([`${rootPath}/**/*.{ts,gql,graphql}`], {
|
|
350
522
|
ignored: `${import_path3.default.resolve(rootPath)}/.tina/__generated__/**/*`
|
|
351
523
|
}).on("ready", async () => {
|
|
352
524
|
console.log("Generating Tina config");
|
|
353
525
|
try {
|
|
354
|
-
|
|
526
|
+
if (shouldBuild) {
|
|
527
|
+
await build(noSDK);
|
|
528
|
+
}
|
|
355
529
|
ready = true;
|
|
356
530
|
startSubprocess();
|
|
357
531
|
} catch (e) {
|
|
358
532
|
logger.info(dangerText(`${e.message}`));
|
|
533
|
+
console.log(e);
|
|
359
534
|
process.exit(0);
|
|
360
535
|
}
|
|
361
536
|
}).on("all", async () => {
|
|
362
537
|
if (ready) {
|
|
363
538
|
logger.info("Tina change detected, regenerating config");
|
|
364
539
|
try {
|
|
365
|
-
|
|
540
|
+
if (shouldBuild) {
|
|
541
|
+
await build(noSDK);
|
|
542
|
+
}
|
|
366
543
|
} catch (e) {
|
|
367
|
-
logger.info(dangerText("Compilation failed with errors. Server has not been restarted.") + `see error below
|
|
544
|
+
logger.info(dangerText("Compilation failed with errors. Server has not been restarted.") + ` see error below
|
|
368
545
|
${e.message}`);
|
|
369
546
|
}
|
|
370
547
|
}
|
|
371
548
|
});
|
|
372
549
|
}
|
|
373
|
-
const build = async () => {
|
|
550
|
+
const build = async (noSDK2) => {
|
|
374
551
|
await compile(null, null);
|
|
375
|
-
const schema = await (0,
|
|
552
|
+
const schema = await (0, import_graphql7.buildSchema)(rootPath, database);
|
|
376
553
|
await genTypes({ schema }, () => {
|
|
377
|
-
}, {});
|
|
554
|
+
}, { noSDK: noSDK2 });
|
|
378
555
|
};
|
|
379
556
|
const state = {
|
|
380
557
|
server: null,
|
|
@@ -383,7 +560,7 @@ stack: ${code.stack || "No stack was provided"}`);
|
|
|
383
560
|
let isReady = false;
|
|
384
561
|
const start = async () => {
|
|
385
562
|
const s = (init_server(), server_exports);
|
|
386
|
-
state.server = await s.default(
|
|
563
|
+
state.server = await s.default(database);
|
|
387
564
|
state.server.listen(port, () => {
|
|
388
565
|
logger.info(`Started Filesystem GraphQL server on port: ${port}`);
|
|
389
566
|
logger.info(`Visit the playground at http://localhost:${port}/altair/`);
|
|
@@ -431,44 +608,15 @@ stack: ${code.stack || "No stack was provided"}`);
|
|
|
431
608
|
}
|
|
432
609
|
}
|
|
433
610
|
|
|
434
|
-
// pnp:/
|
|
611
|
+
// pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/cmds/init/index.ts
|
|
435
612
|
var import_fs_extra3 = __toModule(require("fs-extra"));
|
|
436
613
|
var import_path4 = __toModule(require("path"));
|
|
437
614
|
var import_progress = __toModule(require("progress"));
|
|
438
615
|
var import_prompts = __toModule(require("prompts"));
|
|
439
616
|
|
|
440
|
-
// pnp:/
|
|
441
|
-
var adminPage = `import {
|
|
442
|
-
|
|
443
|
-
import { useEditState } from "tinacms/dist/edit-state";
|
|
444
|
-
|
|
445
|
-
const GoToEditPage = () => {
|
|
446
|
-
const { setEdit } = useEditState();
|
|
447
|
-
const router = useRouter();
|
|
448
|
-
useEffect(() => {
|
|
449
|
-
setEdit(true);
|
|
450
|
-
router.back();
|
|
451
|
-
}, []);
|
|
452
|
-
return <div>Entering edit mode..</div>;
|
|
453
|
-
};
|
|
454
|
-
|
|
455
|
-
export default GoToEditPage;
|
|
456
|
-
`;
|
|
457
|
-
var exitAdminPage = `import { useEffect } from "react";
|
|
458
|
-
import { useRouter } from "next/router";
|
|
459
|
-
import { useEditState } from "tinacms/dist/edit-state";
|
|
460
|
-
|
|
461
|
-
const GoToEditPage = () => {
|
|
462
|
-
const { setEdit } = useEditState();
|
|
463
|
-
const router = useRouter();
|
|
464
|
-
useEffect(() => {
|
|
465
|
-
setEdit(false);
|
|
466
|
-
router.back();
|
|
467
|
-
}, []);
|
|
468
|
-
return <div>Exiting edit mode..</div>;;
|
|
469
|
-
};
|
|
470
|
-
|
|
471
|
-
export default GoToEditPage;
|
|
617
|
+
// pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/cmds/init/setup-files/index.ts
|
|
618
|
+
var adminPage = `import { TinaAdmin } from 'tinacms';
|
|
619
|
+
export default TinaAdmin;
|
|
472
620
|
`;
|
|
473
621
|
var blogPost = `---
|
|
474
622
|
title: Vote For Pedro
|
|
@@ -773,7 +921,6 @@ const App = ({ Component, pageProps }) => {
|
|
|
773
921
|
<TinaCMS
|
|
774
922
|
clientId={process.env.NEXT_PUBLIC_TINA_CLIENT_ID}
|
|
775
923
|
branch={process.env.NEXT_PUBLIC_EDIT_BRANCH}
|
|
776
|
-
organization={process.env.NEXT_PUBLIC_ORGANIZATION_NAME}
|
|
777
924
|
isLocalClient={Boolean(
|
|
778
925
|
Number(process.env.NEXT_PUBLIC_USE_LOCAL_CLIENT ?? true)
|
|
779
926
|
)}
|
|
@@ -792,7 +939,7 @@ const App = ({ Component, pageProps }) => {
|
|
|
792
939
|
export default App
|
|
793
940
|
`;
|
|
794
941
|
|
|
795
|
-
// pnp:/
|
|
942
|
+
// pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/cmds/init/index.ts
|
|
796
943
|
var import_chalk2 = __toModule(require("chalk"));
|
|
797
944
|
function execShellCommand(cmd) {
|
|
798
945
|
const exec = require("child_process").exec;
|
|
@@ -885,52 +1032,13 @@ async function tinaSetup(ctx, next, options) {
|
|
|
885
1032
|
}
|
|
886
1033
|
}, null, 2);
|
|
887
1034
|
(0, import_fs_extra3.writeFileSync)(packagePath, newPack);
|
|
888
|
-
const adminPath = import_path4.default.join(pagesPath, "admin.
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
const extension = import_fs_extra3.default.existsSync(adminPath) ? ".tsx" : "js";
|
|
894
|
-
const override = await (0, import_prompts.default)({
|
|
895
|
-
name: "override",
|
|
896
|
-
type: "confirm",
|
|
897
|
-
message: `Whoops... looks like you already have an admin${extension} do you want to override it?`
|
|
898
|
-
});
|
|
899
|
-
if (override.override) {
|
|
900
|
-
import_fs_extra3.default.writeFileSync(import_path4.default.join(pagesPath, "admin" + extension), adminPage);
|
|
901
|
-
} else {
|
|
902
|
-
const res = await (0, import_prompts.default)({
|
|
903
|
-
name: "name",
|
|
904
|
-
type: "text",
|
|
905
|
-
message: warnText("What would you like the route to be named that enters edit mode?: ")
|
|
906
|
-
});
|
|
907
|
-
const adminName = res.name || "admin";
|
|
908
|
-
import_fs_extra3.default.writeFileSync(import_path4.default.join(pagesPath, adminName + extension), adminPage);
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
const exitAdminPath = import_path4.default.join(pagesPath, "exit-admin.tsx");
|
|
912
|
-
const exitAdminPathJS = import_path4.default.join(pagesPath, "exit-admin.js");
|
|
913
|
-
if (!import_fs_extra3.default.existsSync(exitAdminPath) && !import_fs_extra3.default.existsSync(exitAdminPathJS)) {
|
|
914
|
-
import_fs_extra3.default.writeFileSync(exitAdminPathJS, exitAdminPage);
|
|
915
|
-
} else {
|
|
916
|
-
const extension = import_fs_extra3.default.existsSync(exitAdminPath) ? ".tsx" : "js";
|
|
917
|
-
const override = await (0, import_prompts.default)({
|
|
918
|
-
name: "override",
|
|
919
|
-
type: "confirm",
|
|
920
|
-
message: `Whoops... looks like you already have an exit-admin${extension} do you want to override it?`
|
|
921
|
-
});
|
|
922
|
-
if (override.override) {
|
|
923
|
-
import_fs_extra3.default.writeFileSync(import_path4.default.join(pagesPath, "exit-admin" + extension), exitAdminPage);
|
|
924
|
-
} else {
|
|
925
|
-
const res = await (0, import_prompts.default)({
|
|
926
|
-
name: "name",
|
|
927
|
-
type: "text",
|
|
928
|
-
message: warnText("What would you like the route to be named that exits edit mode?: ")
|
|
929
|
-
});
|
|
930
|
-
const adminName = res.name || "exit-admin";
|
|
931
|
-
import_fs_extra3.default.writeFileSync(import_path4.default.join(pagesPath, adminName + extension), exitAdminPage);
|
|
932
|
-
}
|
|
1035
|
+
const adminPath = import_path4.default.join(pagesPath, "admin", "[[...tina]].js");
|
|
1036
|
+
if (import_fs_extra3.default.pathExistsSync(import_path4.default.join(pagesPath, "admin"))) {
|
|
1037
|
+
logger.warn(`Unable to add /pages/admin/[[...tina]].js, this path already exists.
|
|
1038
|
+
Learn more about toggling edit-mode at https://tina.io/docs/tinacms-context/#manually-toggling-edit-mode`);
|
|
1039
|
+
return next();
|
|
933
1040
|
}
|
|
1041
|
+
(0, import_fs_extra3.outputFileSync)(adminPath, adminPage);
|
|
934
1042
|
next();
|
|
935
1043
|
}
|
|
936
1044
|
async function successMessage(ctx, next, options) {
|
|
@@ -942,7 +1050,7 @@ Enjoy Tina \u{1F999} !
|
|
|
942
1050
|
next();
|
|
943
1051
|
}
|
|
944
1052
|
|
|
945
|
-
// pnp:/
|
|
1053
|
+
// pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/cmds/baseCmds.ts
|
|
946
1054
|
var CMD_GEN_TYPES = "schema:types";
|
|
947
1055
|
var CMD_START_SERVER = "server:start";
|
|
948
1056
|
var CMD_COMPILE_MODELS = "schema:compile";
|
|
@@ -951,40 +1059,50 @@ var startServerPortOption = {
|
|
|
951
1059
|
name: "--port <port>",
|
|
952
1060
|
description: "Specify a port to run the server on. (default 4001)"
|
|
953
1061
|
};
|
|
1062
|
+
var experimentalDatalayer = {
|
|
1063
|
+
name: "--experimentalData",
|
|
1064
|
+
description: "Build the server with additional data querying capabilities"
|
|
1065
|
+
};
|
|
954
1066
|
var subCommand = {
|
|
955
1067
|
name: "-c, --command <command>",
|
|
956
1068
|
description: "The sub-command to run"
|
|
957
1069
|
};
|
|
958
|
-
var experimentalCommand = {
|
|
959
|
-
name: "--experimental",
|
|
960
|
-
description: "Run the unstable version of this service"
|
|
961
|
-
};
|
|
962
1070
|
var noWatchOption = {
|
|
963
1071
|
name: "--noWatch",
|
|
964
1072
|
description: "Don't regenerate config on file changes"
|
|
965
1073
|
};
|
|
1074
|
+
var noSDKCodegenOption = {
|
|
1075
|
+
name: "--noSDK",
|
|
1076
|
+
description: "Don't generate the generated client SDK"
|
|
1077
|
+
};
|
|
966
1078
|
var baseCmds = [
|
|
967
1079
|
{
|
|
968
1080
|
command: CMD_START_SERVER,
|
|
969
1081
|
description: "Start Filesystem Graphql Server",
|
|
970
|
-
options: [
|
|
1082
|
+
options: [
|
|
1083
|
+
startServerPortOption,
|
|
1084
|
+
subCommand,
|
|
1085
|
+
experimentalDatalayer,
|
|
1086
|
+
noWatchOption,
|
|
1087
|
+
noSDKCodegenOption
|
|
1088
|
+
],
|
|
971
1089
|
action: (options) => chain([startServer], options)
|
|
972
1090
|
},
|
|
973
1091
|
{
|
|
974
1092
|
command: CMD_COMPILE_MODELS,
|
|
975
1093
|
description: "Compile schema into static files for the server",
|
|
976
|
-
options: [
|
|
1094
|
+
options: [experimentalDatalayer],
|
|
977
1095
|
action: (options) => chain([compile], options)
|
|
978
1096
|
},
|
|
979
1097
|
{
|
|
980
1098
|
command: CMD_GEN_TYPES,
|
|
981
1099
|
description: "Generate a GraphQL query for your site's schema, (and optionally Typescript types)",
|
|
982
|
-
options: [
|
|
1100
|
+
options: [experimentalDatalayer, noSDKCodegenOption],
|
|
983
1101
|
action: (options) => chain([attachSchema, genTypes], options)
|
|
984
1102
|
},
|
|
985
1103
|
{
|
|
986
1104
|
command: INIT,
|
|
987
|
-
options: [
|
|
1105
|
+
options: [experimentalDatalayer],
|
|
988
1106
|
description: "Add Tina Cloud to an existing project",
|
|
989
1107
|
action: (options) => chain([
|
|
990
1108
|
initTina,
|
|
@@ -1001,7 +1119,7 @@ var baseCmds = [
|
|
|
1001
1119
|
}
|
|
1002
1120
|
];
|
|
1003
1121
|
|
|
1004
|
-
// pnp:/
|
|
1122
|
+
// pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/index.ts
|
|
1005
1123
|
var program = new commander.Command(name);
|
|
1006
1124
|
var registerCommands = (commands, noHelp = false) => {
|
|
1007
1125
|
commands.forEach((command, i) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.58.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
]
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@tinacms/scripts": "0.50.
|
|
24
|
+
"@tinacms/scripts": "0.50.4",
|
|
25
25
|
"@types/clear": "0.1.0",
|
|
26
26
|
"@types/cors": "2.8.5",
|
|
27
27
|
"@types/express": "^4.17.7",
|
|
@@ -38,24 +38,28 @@
|
|
|
38
38
|
"@types/progress": "^2.0.3",
|
|
39
39
|
"@types/prompts": "^2.0.13",
|
|
40
40
|
"@types/yup": "^0.29.11",
|
|
41
|
-
"jest": "^27.0.6"
|
|
42
|
-
"ts-jest": "^26.5.3"
|
|
41
|
+
"jest": "^27.0.6"
|
|
43
42
|
},
|
|
44
43
|
"scripts": {
|
|
45
|
-
"build": "yarn
|
|
46
|
-
"watch": "yarn tsup src/index.ts --watch --format cjs --dts",
|
|
44
|
+
"build": "echo \"Run `yarn build` from the root of the repository instead\"",
|
|
47
45
|
"test": "jest --passWithNoTests",
|
|
48
46
|
"types": "yarn tsc",
|
|
49
47
|
"test-watch": "jest --passWithNoTests --watch",
|
|
50
48
|
"generate:schema": "yarn node scripts/generateSchema.js"
|
|
51
49
|
},
|
|
52
50
|
"dependencies": {
|
|
53
|
-
"@graphql-codegen/core": "^1.
|
|
54
|
-
"@graphql-codegen/
|
|
55
|
-
"@graphql-codegen/typescript
|
|
56
|
-
"@
|
|
51
|
+
"@graphql-codegen/core": "^2.1.0",
|
|
52
|
+
"@graphql-codegen/plugin-helpers": "latest",
|
|
53
|
+
"@graphql-codegen/typescript": "^2.2.2",
|
|
54
|
+
"@graphql-codegen/typescript-generic-sdk": "^2.1.4",
|
|
55
|
+
"@graphql-codegen/typescript-operations": "^2.1.4",
|
|
56
|
+
"@graphql-codegen/visitor-plugin-common": "^2.4.0",
|
|
57
|
+
"@graphql-tools/graphql-file-loader": "^7.2.0",
|
|
58
|
+
"@graphql-tools/load": "^7.3.2",
|
|
59
|
+
"@tinacms/graphql": "0.58.0",
|
|
57
60
|
"ajv": "^6.12.3",
|
|
58
61
|
"altair-express-middleware": "4.0.6",
|
|
62
|
+
"auto-bind": "^4.0.0",
|
|
59
63
|
"axios": "0.19.0",
|
|
60
64
|
"body-parser": "^1.19.0",
|
|
61
65
|
"chalk": "^2.4.2",
|
|
@@ -74,7 +78,6 @@
|
|
|
74
78
|
"normalize-path": "^3.0.0",
|
|
75
79
|
"progress": "^2.0.3",
|
|
76
80
|
"prompts": "^2.4.1",
|
|
77
|
-
"tsup": "4.6.1",
|
|
78
81
|
"typescript": "^4.3.5",
|
|
79
82
|
"yup": "^0.32.9"
|
|
80
83
|
},
|