@baeta/plugin-pagination 0.0.2 → 0.0.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/CHANGELOG.md +8 -0
- package/dist/index.cjs +23 -7
- package/dist/index.js +22 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @baeta/plugin-pagination
|
|
2
2
|
|
|
3
|
+
## 0.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`8569eca`](https://github.com/andreisergiu98/baeta/commit/8569ecaf263e24f8d17f62ea00a0cd374dd27941) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - add final new line
|
|
8
|
+
|
|
9
|
+
- [#31](https://github.com/andreisergiu98/baeta/pull/31) [`f122a1e`](https://github.com/andreisergiu98/baeta/commit/f122a1e2970d915ce3c24931d4309db26665c739) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - ignore generated sdl
|
|
10
|
+
|
|
3
11
|
## 0.0.2
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true})
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// index.ts
|
|
2
2
|
var _generatorsdk = require('@baeta/generator-sdk');
|
|
3
3
|
var _path = require('path');
|
|
4
4
|
function printFields(fields) {
|
|
@@ -10,7 +10,7 @@ ${printFields(fields)}
|
|
|
10
10
|
}`;
|
|
11
11
|
}
|
|
12
12
|
function printTypes(types) {
|
|
13
|
-
return types.join("\n\n");
|
|
13
|
+
return types.join("\n\n") + "\n";
|
|
14
14
|
}
|
|
15
15
|
function printPageInfo(addFields = []) {
|
|
16
16
|
return printType("PageInfo", [
|
|
@@ -24,7 +24,8 @@ function printExport(moduleDefinitionName) {
|
|
|
24
24
|
const importName = parsed.ext === ".ts" ? parsed.name : moduleDefinitionName;
|
|
25
25
|
return `import { getConnectionsModule } from "./${importName}";
|
|
26
26
|
|
|
27
|
-
export const connectionsModule = getConnectionsModule()
|
|
27
|
+
export const connectionsModule = getConnectionsModule();
|
|
28
|
+
`;
|
|
28
29
|
}
|
|
29
30
|
function printConnectionTypes(name, typeOptions, options) {
|
|
30
31
|
const {
|
|
@@ -45,10 +46,25 @@ function printConnectionTypes(name, typeOptions, options) {
|
|
|
45
46
|
]);
|
|
46
47
|
return [connection, edge];
|
|
47
48
|
}
|
|
49
|
+
function createConnectionModuleDir(modulesDir, moduleName = "connections") {
|
|
50
|
+
return _path.join.call(void 0, modulesDir, moduleName);
|
|
51
|
+
}
|
|
52
|
+
function createGqlFilename(moduleDir) {
|
|
53
|
+
return `${moduleDir}/connections.gql`;
|
|
54
|
+
}
|
|
55
|
+
function createExportFilename(moduleDir) {
|
|
56
|
+
return `${moduleDir}/index.ts`;
|
|
57
|
+
}
|
|
48
58
|
function paginationPlugin(options) {
|
|
49
59
|
return _generatorsdk.createPluginV1.call(void 0, {
|
|
50
60
|
name: "pagination",
|
|
51
61
|
actionName: "pagination connections",
|
|
62
|
+
watch: (generatorOptions) => {
|
|
63
|
+
return {
|
|
64
|
+
include: [],
|
|
65
|
+
ignore: [createConnectionModuleDir(generatorOptions.modulesDir, options.moduleName)]
|
|
66
|
+
};
|
|
67
|
+
},
|
|
52
68
|
generate: async (ctx, next) => {
|
|
53
69
|
const types = [printPageInfo(options.pageInfoFields)];
|
|
54
70
|
for (const name in options.types) {
|
|
@@ -58,12 +74,12 @@ function paginationPlugin(options) {
|
|
|
58
74
|
}
|
|
59
75
|
types.push(...printConnectionTypes(name, typeOptions === true ? {} : typeOptions, options));
|
|
60
76
|
}
|
|
61
|
-
const
|
|
77
|
+
const moduleDir = createConnectionModuleDir(
|
|
62
78
|
ctx.generatorOptions.modulesDir,
|
|
63
|
-
|
|
79
|
+
options.moduleName
|
|
64
80
|
);
|
|
65
81
|
const definitionFile = new (0, _generatorsdk.File)(
|
|
66
|
-
|
|
82
|
+
createGqlFilename(moduleDir),
|
|
67
83
|
printTypes(types),
|
|
68
84
|
"pagination"
|
|
69
85
|
);
|
|
@@ -71,7 +87,7 @@ function paginationPlugin(options) {
|
|
|
71
87
|
ctx.fileManager.add(definitionFile);
|
|
72
88
|
if (options.createExport !== false) {
|
|
73
89
|
const exportFile = new (0, _generatorsdk.File)(
|
|
74
|
-
|
|
90
|
+
createExportFilename(moduleDir),
|
|
75
91
|
printExport(ctx.generatorOptions.moduleDefinitionName),
|
|
76
92
|
"pagination"
|
|
77
93
|
);
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ ${printFields(fields)}
|
|
|
10
10
|
}`;
|
|
11
11
|
}
|
|
12
12
|
function printTypes(types) {
|
|
13
|
-
return types.join("\n\n");
|
|
13
|
+
return types.join("\n\n") + "\n";
|
|
14
14
|
}
|
|
15
15
|
function printPageInfo(addFields = []) {
|
|
16
16
|
return printType("PageInfo", [
|
|
@@ -24,7 +24,8 @@ function printExport(moduleDefinitionName) {
|
|
|
24
24
|
const importName = parsed.ext === ".ts" ? parsed.name : moduleDefinitionName;
|
|
25
25
|
return `import { getConnectionsModule } from "./${importName}";
|
|
26
26
|
|
|
27
|
-
export const connectionsModule = getConnectionsModule()
|
|
27
|
+
export const connectionsModule = getConnectionsModule();
|
|
28
|
+
`;
|
|
28
29
|
}
|
|
29
30
|
function printConnectionTypes(name, typeOptions, options) {
|
|
30
31
|
const {
|
|
@@ -45,10 +46,25 @@ function printConnectionTypes(name, typeOptions, options) {
|
|
|
45
46
|
]);
|
|
46
47
|
return [connection, edge];
|
|
47
48
|
}
|
|
49
|
+
function createConnectionModuleDir(modulesDir, moduleName = "connections") {
|
|
50
|
+
return join(modulesDir, moduleName);
|
|
51
|
+
}
|
|
52
|
+
function createGqlFilename(moduleDir) {
|
|
53
|
+
return `${moduleDir}/connections.gql`;
|
|
54
|
+
}
|
|
55
|
+
function createExportFilename(moduleDir) {
|
|
56
|
+
return `${moduleDir}/index.ts`;
|
|
57
|
+
}
|
|
48
58
|
function paginationPlugin(options) {
|
|
49
59
|
return createPluginV1({
|
|
50
60
|
name: "pagination",
|
|
51
61
|
actionName: "pagination connections",
|
|
62
|
+
watch: (generatorOptions) => {
|
|
63
|
+
return {
|
|
64
|
+
include: [],
|
|
65
|
+
ignore: [createConnectionModuleDir(generatorOptions.modulesDir, options.moduleName)]
|
|
66
|
+
};
|
|
67
|
+
},
|
|
52
68
|
generate: async (ctx, next) => {
|
|
53
69
|
const types = [printPageInfo(options.pageInfoFields)];
|
|
54
70
|
for (const name in options.types) {
|
|
@@ -58,12 +74,12 @@ function paginationPlugin(options) {
|
|
|
58
74
|
}
|
|
59
75
|
types.push(...printConnectionTypes(name, typeOptions === true ? {} : typeOptions, options));
|
|
60
76
|
}
|
|
61
|
-
const
|
|
77
|
+
const moduleDir = createConnectionModuleDir(
|
|
62
78
|
ctx.generatorOptions.modulesDir,
|
|
63
|
-
options.moduleName
|
|
79
|
+
options.moduleName
|
|
64
80
|
);
|
|
65
81
|
const definitionFile = new File(
|
|
66
|
-
|
|
82
|
+
createGqlFilename(moduleDir),
|
|
67
83
|
printTypes(types),
|
|
68
84
|
"pagination"
|
|
69
85
|
);
|
|
@@ -71,7 +87,7 @@ function paginationPlugin(options) {
|
|
|
71
87
|
ctx.fileManager.add(definitionFile);
|
|
72
88
|
if (options.createExport !== false) {
|
|
73
89
|
const exportFile = new File(
|
|
74
|
-
|
|
90
|
+
createExportFilename(moduleDir),
|
|
75
91
|
printExport(ctx.generatorOptions.moduleDefinitionName),
|
|
76
92
|
"pagination"
|
|
77
93
|
);
|