@vendure/cli 2.1.0-next.5

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.
Files changed (38) hide show
  1. package/LICENSE +9 -0
  2. package/dist/cli.d.ts +2 -0
  3. package/dist/cli.js +11 -0
  4. package/dist/cli.js.map +1 -0
  5. package/dist/commands/new/new.d.ts +2 -0
  6. package/dist/commands/new/new.js +18 -0
  7. package/dist/commands/new/new.js.map +1 -0
  8. package/dist/commands/new/plugin/new-plugin.d.ts +3 -0
  9. package/dist/commands/new/plugin/new-plugin.js +204 -0
  10. package/dist/commands/new/plugin/new-plugin.js.map +1 -0
  11. package/dist/commands/new/plugin/scaffold/api/admin.resolver.d.ts +3 -0
  12. package/dist/commands/new/plugin/scaffold/api/admin.resolver.js +66 -0
  13. package/dist/commands/new/plugin/scaffold/api/admin.resolver.js.map +1 -0
  14. package/dist/commands/new/plugin/scaffold/api/api-extensions.d.ts +2 -0
  15. package/dist/commands/new/plugin/scaffold/api/api-extensions.js +82 -0
  16. package/dist/commands/new/plugin/scaffold/api/api-extensions.js.map +1 -0
  17. package/dist/commands/new/plugin/scaffold/api/shop.resolver.d.ts +3 -0
  18. package/dist/commands/new/plugin/scaffold/api/shop.resolver.js +57 -0
  19. package/dist/commands/new/plugin/scaffold/api/shop.resolver.js.map +1 -0
  20. package/dist/commands/new/plugin/scaffold/constants.d.ts +2 -0
  21. package/dist/commands/new/plugin/scaffold/constants.js +21 -0
  22. package/dist/commands/new/plugin/scaffold/constants.js.map +1 -0
  23. package/dist/commands/new/plugin/scaffold/entities/entity.d.ts +2 -0
  24. package/dist/commands/new/plugin/scaffold/entities/entity.js +21 -0
  25. package/dist/commands/new/plugin/scaffold/entities/entity.js.map +1 -0
  26. package/dist/commands/new/plugin/scaffold/plugin.d.ts +2 -0
  27. package/dist/commands/new/plugin/scaffold/plugin.js +51 -0
  28. package/dist/commands/new/plugin/scaffold/plugin.js.map +1 -0
  29. package/dist/commands/new/plugin/scaffold/services/service.d.ts +3 -0
  30. package/dist/commands/new/plugin/scaffold/services/service.js +80 -0
  31. package/dist/commands/new/plugin/scaffold/services/service.js.map +1 -0
  32. package/dist/commands/new/plugin/scaffold/types.d.ts +2 -0
  33. package/dist/commands/new/plugin/scaffold/types.js +15 -0
  34. package/dist/commands/new/plugin/scaffold/types.js.map +1 -0
  35. package/dist/commands/new/plugin/types.d.ts +21 -0
  36. package/dist/commands/new/plugin/types.js +3 -0
  37. package/dist/commands/new/plugin/types.js.map +1 -0
  38. package/package.json +47 -0
package/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2018 Michael Bromley
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #! /usr/bin/env node
2
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,11 @@
1
+ #! /usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const commander_1 = require("commander");
5
+ const new_1 = require("./commands/new/new");
6
+ const program = new commander_1.Command();
7
+ const version = require('../package.json').version;
8
+ program.version(version).description('The Vendure CLI');
9
+ (0, new_1.registerNewCommand)(program);
10
+ void program.parseAsync(process.argv);
11
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AAEA,yCAAoC;AAEpC,4CAAwD;AAExD,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAG9B,MAAM,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC;AAEnD,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;AACxD,IAAA,wBAAkB,EAAC,OAAO,CAAC,CAAC;AAE5B,KAAK,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function registerNewCommand(program: Command): void;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerNewCommand = void 0;
4
+ const commander_1 = require("commander");
5
+ const new_plugin_1 = require("./plugin/new-plugin");
6
+ function registerNewCommand(program) {
7
+ program
8
+ .command('new')
9
+ .addArgument(new commander_1.Argument('<type>', 'type of scaffold').choices(['plugin']))
10
+ .description('Generate scaffold for your Vendure project')
11
+ .action(async (type) => {
12
+ if (type === 'plugin') {
13
+ await (0, new_plugin_1.newPlugin)();
14
+ }
15
+ });
16
+ }
17
+ exports.registerNewCommand = registerNewCommand;
18
+ //# sourceMappingURL=new.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new.js","sourceRoot":"","sources":["../../../src/commands/new/new.ts"],"names":[],"mappings":";;;AAAA,yCAA8C;AAE9C,oDAAgD;AAEhD,SAAgB,kBAAkB,CAAC,OAAgB;IAC/C,OAAO;SACF,OAAO,CAAC,KAAK,CAAC;SACd,WAAW,CAAC,IAAI,oBAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;SAC3E,WAAW,CAAC,4CAA4C,CAAC;SACzD,MAAM,CAAC,KAAK,EAAE,IAAY,EAAE,EAAE;QAC3B,IAAI,IAAI,KAAK,QAAQ,EAAE;YACnB,MAAM,IAAA,sBAAS,GAAE,CAAC;SACrB;IACL,CAAC,CAAC,CAAC;AACX,CAAC;AAVD,gDAUC"}
@@ -0,0 +1,3 @@
1
+ import { GeneratePluginOptions } from './types';
2
+ export declare function newPlugin(): Promise<void>;
3
+ export declare function generatePlugin(options: GeneratePluginOptions): Promise<void>;
@@ -0,0 +1,204 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.generatePlugin = exports.newPlugin = void 0;
30
+ const prompts_1 = require("@clack/prompts");
31
+ const change_case_1 = require("change-case");
32
+ const fs = __importStar(require("fs-extra"));
33
+ const path_1 = __importDefault(require("path"));
34
+ const admin_resolver_1 = require("./scaffold/api/admin.resolver");
35
+ const api_extensions_1 = require("./scaffold/api/api-extensions");
36
+ const shop_resolver_1 = require("./scaffold/api/shop.resolver");
37
+ const constants_1 = require("./scaffold/constants");
38
+ const entity_1 = require("./scaffold/entities/entity");
39
+ const plugin_1 = require("./scaffold/plugin");
40
+ const service_1 = require("./scaffold/services/service");
41
+ const types_1 = require("./scaffold/types");
42
+ const cancelledMessage = 'Plugin setup cancelled.';
43
+ async function newPlugin() {
44
+ const options = { name: '', customEntityName: '' };
45
+ (0, prompts_1.intro)('Scaffolding a new Vendure plugin!');
46
+ if (!options.name) {
47
+ const name = await (0, prompts_1.text)({
48
+ message: 'What is the name of the plugin?',
49
+ initialValue: '',
50
+ validate: input => {
51
+ if (!/^[a-z][a-z-0-9]+$/.test(input)) {
52
+ return 'The plugin name must be lowercase and contain only letters, numbers and dashes';
53
+ }
54
+ const proposedPluginDir = getPluginDirName(input);
55
+ if (fs.existsSync(proposedPluginDir)) {
56
+ return `A directory named "${proposedPluginDir}" already exists. Cannot create plugin in this directory.`;
57
+ }
58
+ },
59
+ });
60
+ if ((0, prompts_1.isCancel)(name)) {
61
+ (0, prompts_1.cancel)(cancelledMessage);
62
+ process.exit(0);
63
+ }
64
+ else {
65
+ options.name = name;
66
+ }
67
+ }
68
+ const features = await (0, prompts_1.multiselect)({
69
+ message: 'Which features would you like to include? (use ↑, ↓, space to select)',
70
+ options: [
71
+ { value: 'customEntity', label: 'Custom entity' },
72
+ { value: 'apiExtensions', label: 'GraphQL API extensions' },
73
+ ],
74
+ required: false,
75
+ });
76
+ if (Array.isArray(features)) {
77
+ options.withCustomEntity = features.includes('customEntity');
78
+ options.withApiExtensions = features.includes('apiExtensions');
79
+ }
80
+ if (options.withCustomEntity) {
81
+ const entityName = await (0, prompts_1.text)({
82
+ message: 'What is the name of the custom entity?',
83
+ initialValue: '',
84
+ placeholder: '',
85
+ validate: input => {
86
+ if (!input) {
87
+ return 'The custom entity name cannot be empty';
88
+ }
89
+ const pascalCaseRegex = /^[A-Z][a-zA-Z0-9]*$/;
90
+ if (!pascalCaseRegex.test(input)) {
91
+ return 'The custom entity name must be in PascalCase, e.g. "ProductReview"';
92
+ }
93
+ },
94
+ });
95
+ if ((0, prompts_1.isCancel)(entityName)) {
96
+ (0, prompts_1.cancel)(cancelledMessage);
97
+ process.exit(0);
98
+ }
99
+ else {
100
+ options.customEntityName = (0, change_case_1.pascalCase)(entityName);
101
+ }
102
+ }
103
+ const pluginDir = getPluginDirName(options.name);
104
+ const confirmation = await (0, prompts_1.confirm)({
105
+ message: `Create new plugin in ${pluginDir}?`,
106
+ });
107
+ if ((0, prompts_1.isCancel)(confirmation)) {
108
+ (0, prompts_1.cancel)(cancelledMessage);
109
+ process.exit(0);
110
+ }
111
+ else {
112
+ if (confirmation === true) {
113
+ await generatePlugin(options);
114
+ }
115
+ else {
116
+ (0, prompts_1.cancel)(cancelledMessage);
117
+ }
118
+ }
119
+ }
120
+ exports.newPlugin = newPlugin;
121
+ async function generatePlugin(options) {
122
+ const nameWithoutPlugin = options.name.replace(/-?plugin$/i, '');
123
+ const normalizedName = nameWithoutPlugin + '-plugin';
124
+ const templateContext = Object.assign(Object.assign({}, options), { pluginName: (0, change_case_1.pascalCase)(normalizedName), pluginInitOptionsName: (0, change_case_1.constantCase)(normalizedName) + '_OPTIONS', service: {
125
+ className: (0, change_case_1.pascalCase)(nameWithoutPlugin) + 'Service',
126
+ instanceName: (0, change_case_1.camelCase)(nameWithoutPlugin) + 'Service',
127
+ fileName: (0, change_case_1.paramCase)(nameWithoutPlugin) + '.service',
128
+ }, entity: {
129
+ className: options.customEntityName,
130
+ instanceName: (0, change_case_1.camelCase)(options.customEntityName),
131
+ fileName: (0, change_case_1.paramCase)(options.customEntityName) + '.entity',
132
+ } });
133
+ const files = [
134
+ {
135
+ render: plugin_1.renderPlugin,
136
+ path: (0, change_case_1.paramCase)(nameWithoutPlugin) + '.plugin.ts',
137
+ },
138
+ {
139
+ render: types_1.renderTypes,
140
+ path: 'types.ts',
141
+ },
142
+ {
143
+ render: constants_1.renderConstants,
144
+ path: 'constants.ts',
145
+ },
146
+ ];
147
+ if (options.withApiExtensions) {
148
+ files.push({
149
+ render: api_extensions_1.renderApiExtensions,
150
+ path: 'api/api-extensions.ts',
151
+ });
152
+ if (options.withCustomEntity) {
153
+ files.push({
154
+ render: shop_resolver_1.renderShopResolverWithEntity,
155
+ path: 'api/shop.resolver.ts',
156
+ });
157
+ files.push({
158
+ render: admin_resolver_1.renderAdminResolverWithEntity,
159
+ path: 'api/admin.resolver.ts',
160
+ });
161
+ }
162
+ else {
163
+ files.push({
164
+ render: shop_resolver_1.renderShopResolver,
165
+ path: 'api/shop.resolver.ts',
166
+ });
167
+ files.push({
168
+ render: admin_resolver_1.renderAdminResolver,
169
+ path: 'api/admin.resolver.ts',
170
+ });
171
+ }
172
+ }
173
+ if (options.withCustomEntity) {
174
+ files.push({
175
+ render: entity_1.renderEntity,
176
+ path: `entities/${templateContext.entity.fileName}.ts`,
177
+ });
178
+ files.push({
179
+ render: service_1.renderServiceWithEntity,
180
+ path: `services/${templateContext.service.fileName}.ts`,
181
+ });
182
+ }
183
+ else {
184
+ files.push({
185
+ render: service_1.renderService,
186
+ path: `services/${templateContext.service.fileName}.ts`,
187
+ });
188
+ }
189
+ const pluginDir = getPluginDirName(options.name);
190
+ fs.ensureDirSync(pluginDir);
191
+ files.forEach(file => {
192
+ const filePath = path_1.default.join(pluginDir, file.path);
193
+ const rendered = file.render(templateContext).trim();
194
+ fs.ensureFileSync(filePath);
195
+ fs.writeFileSync(filePath, rendered);
196
+ });
197
+ (0, prompts_1.outro)('✅ Plugin scaffolding complete!');
198
+ }
199
+ exports.generatePlugin = generatePlugin;
200
+ function getPluginDirName(name) {
201
+ const nameWithoutPlugin = name.replace(/-?plugin$/i, '');
202
+ return path_1.default.join(process.cwd(), (0, change_case_1.paramCase)(nameWithoutPlugin));
203
+ }
204
+ //# sourceMappingURL=new-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-plugin.js","sourceRoot":"","sources":["../../../../src/commands/new/plugin/new-plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA4F;AAC5F,6CAA6E;AAC7E,6CAA+B;AAC/B,gDAAwB;AAExB,kEAAmG;AACnG,kEAAoE;AACpE,gEAAgG;AAChG,oDAAuD;AACvD,uDAA0D;AAC1D,8CAAiD;AACjD,yDAAqF;AACrF,4CAA+C;AAG/C,MAAM,gBAAgB,GAAG,yBAAyB,CAAC;AAE5C,KAAK,UAAU,SAAS;IAC3B,MAAM,OAAO,GAA0B,EAAE,IAAI,EAAE,EAAE,EAAE,gBAAgB,EAAE,EAAE,EAAS,CAAC;IACjF,IAAA,eAAK,EAAC,mCAAmC,CAAC,CAAC;IAC3C,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;QACf,MAAM,IAAI,GAAG,MAAM,IAAA,cAAI,EAAC;YACpB,OAAO,EAAE,iCAAiC;YAC1C,YAAY,EAAE,EAAE;YAChB,QAAQ,EAAE,KAAK,CAAC,EAAE;gBACd,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;oBAClC,OAAO,gFAAgF,CAAC;iBAC3F;gBACD,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;gBAClD,IAAI,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE;oBAClC,OAAO,sBAAsB,iBAAiB,2DAA2D,CAAC;iBAC7G;YACL,CAAC;SACJ,CAAC,CAAC;QAEH,IAAI,IAAA,kBAAQ,EAAC,IAAI,CAAC,EAAE;YAChB,IAAA,gBAAM,EAAC,gBAAgB,CAAC,CAAC;YACzB,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;QACH,KAAK,CAAC,IAAI,CAAC;YACP,MAAM,EAAE,uBAAa;YACrB,IAAI,EAAE,YAAY,eAAe,CAAC,OAAO,CAAC,QAAQ,KAAK;SAC1D,CAAC,CAAC;KACN;IAED,MAAM,SAAS,GAAG,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,EAAE,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAC5B,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACjB,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QACjD,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,IAAI,EAAE,CAAC;QACrD,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QAC5B,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,IAAA,eAAK,EAAC,gCAAgC,CAAC,CAAC;AAC5C,CAAC;AAtFD,wCAsFC;AAED,SAAS,gBAAgB,CAAC,IAAY;IAClC,MAAM,iBAAiB,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;IACzD,OAAO,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAA,uBAAS,EAAC,iBAAiB,CAAC,CAAC,CAAC;AAClE,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { TemplateContext } from '../../types';
2
+ export declare function renderAdminResolverWithEntity(context: TemplateContext): string;
3
+ export declare function renderAdminResolver(context: TemplateContext): string;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderAdminResolver = exports.renderAdminResolverWithEntity = void 0;
4
+ function renderAdminResolverWithEntity(context) {
5
+ return `
6
+ import { Args, Resolver, Mutation } from '@nestjs/graphql';
7
+ import { Allow, Ctx, RequestContext, Transaction, Permission } from '@vendure/core';
8
+
9
+ import { ${context.entity.instanceName}Permission } from '../constants';
10
+ import { ${context.service.className} } from '../services/${context.service.fileName}';
11
+ import { ${context.entity.className} } from '../entities/${context.entity.fileName}';
12
+
13
+ // TODO: Set up graphql-code-generator to generate the types for the following inputs
14
+ type Create${context.customEntityName}Input = any;
15
+ type Update${context.customEntityName}Input = any;
16
+
17
+ @Resolver()
18
+ export class AdminResolver {
19
+ constructor(private ${context.service.instanceName}: ${context.service.className}) {
20
+ }
21
+
22
+ @Transaction()
23
+ @Mutation()
24
+ @Allow(${context.entity.instanceName}Permission.Create)
25
+ create${context.entity.className}(@Ctx() ctx: RequestContext, @Args() args: { input: Create${context.customEntityName}Input }): Promise<${context.entity.className}> {
26
+ return this.${context.service.instanceName}.create(ctx, args.input);
27
+ }
28
+
29
+ @Transaction()
30
+ @Mutation()
31
+ @Allow(${context.entity.instanceName}Permission.Update)
32
+ update${context.entity.className}(
33
+ @Ctx() ctx: RequestContext,
34
+ @Args() args: { input: Update${context.customEntityName}Input },
35
+ ): Promise<${context.entity.className} | undefined> {
36
+ return this.${context.service.instanceName}.update(ctx, args.input);
37
+ }
38
+ }`;
39
+ }
40
+ exports.renderAdminResolverWithEntity = renderAdminResolverWithEntity;
41
+ function renderAdminResolver(context) {
42
+ return `
43
+ import { Args, Query, Mutation, Resolver } from '@nestjs/graphql';
44
+ import { Ctx, PaginatedList, RequestContext, Transaction } from '@vendure/core';
45
+
46
+ import { ${context.service.className} } from '../services/${context.service.fileName}';
47
+
48
+ @Resolver()
49
+ export class AdminResolver {
50
+ constructor(private ${context.service.instanceName}: ${context.service.className}) {
51
+ }
52
+
53
+ @Query()
54
+ exampleShopQuery(@Ctx() ctx: RequestContext) {
55
+ return this.${context.service.instanceName}.exampleMethod(ctx);
56
+ }
57
+
58
+ @Mutation()
59
+ @Transaction()
60
+ exampleShopMutation(@Ctx() ctx: RequestContext, @Args() args: { input: string }) {
61
+ return this.${context.service.instanceName}.exampleMethod(ctx, args);
62
+ }
63
+ }`;
64
+ }
65
+ exports.renderAdminResolver = renderAdminResolver;
66
+ //# sourceMappingURL=admin.resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin.resolver.js","sourceRoot":"","sources":["../../../../../../src/commands/new/plugin/scaffold/api/admin.resolver.ts"],"names":[],"mappings":";;;AAEA,SAAgB,6BAA6B,CAAC,OAAwB;IAClE,OAAiC;;;;WAI1B,OAAO,CAAC,MAAM,CAAC,YAAY;WAC3B,OAAO,CAAC,OAAO,CAAC,SAAS,wBAAwB,OAAO,CAAC,OAAO,CAAC,QAAQ;WACzE,OAAO,CAAC,MAAM,CAAC,SAAS,wBAAwB,OAAO,CAAC,MAAM,CAAC,QAAQ;;;aAGrE,OAAO,CAAC,gBAAgB;aACxB,OAAO,CAAC,gBAAgB;;;;0BAIX,OAAO,CAAC,OAAO,CAAC,YAAY,KAAK,OAAO,CAAC,OAAO,CAAC,SAAS;;;;;aAKvE,OAAO,CAAC,MAAM,CAAC,YAAY;YAC5B,OAAO,CAAC,MAAM,CAAC,SAAS,6DAA6D,OAAO,CAAC,gBAAgB,qBAAqB,OAAO,CAAC,MAAM,CAAC,SAAS;sBAChJ,OAAO,CAAC,OAAO,CAAC,YAAY;;;;;aAKrC,OAAO,CAAC,MAAM,CAAC,YAAY;YAC5B,OAAO,CAAC,MAAM,CAAC,SAAS;;uCAEG,OAAO,CAAC,gBAAgB;iBAC9C,OAAO,CAAC,MAAM,CAAC,SAAS;sBACnB,OAAO,CAAC,OAAO,CAAC,YAAY;;EAEhD,CAAC;AACH,CAAC;AAnCD,sEAmCC;AAED,SAAgB,mBAAmB,CAAC,OAAwB;IACxD,OAAiC;;;;WAI1B,OAAO,CAAC,OAAO,CAAC,SAAS,wBAAwB,OAAO,CAAC,OAAO,CAAC,QAAQ;;;;0BAI1D,OAAO,CAAC,OAAO,CAAC,YAAY,KAAK,OAAO,CAAC,OAAO,CAAC,SAAS;;;;;sBAK9D,OAAO,CAAC,OAAO,CAAC,YAAY;;;;;;sBAM5B,OAAO,CAAC,OAAO,CAAC,YAAY;;EAEhD,CAAC;AACH,CAAC;AAvBD,kDAuBC"}
@@ -0,0 +1,2 @@
1
+ import { TemplateContext } from '../../types';
2
+ export declare function renderApiExtensions(context: TemplateContext): string;
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderApiExtensions = void 0;
4
+ function renderApiExtensions(context) {
5
+ if (!context.withApiExtensions) {
6
+ return '';
7
+ }
8
+ if (!context.withCustomEntity) {
9
+ return `
10
+ import gql from 'graphql-tag';
11
+ export const shopApiExtensions = gql\`
12
+ extend type Query {
13
+ exampleShopQuery: String!
14
+ }
15
+ extend type Mutation {
16
+ exampleShopMutation(input: String!): String!
17
+ }
18
+ \`;
19
+
20
+ export const adminApiExtensions = gql\`
21
+ extend type Query {
22
+ exampleAdminQuery: String!
23
+ }
24
+ extend type Mutation {
25
+ exampleAdminMutation(input: String!): String!
26
+ }
27
+ \`;
28
+ `;
29
+ }
30
+ else {
31
+ const entityName = context.entity.className;
32
+ return `
33
+ import gql from 'graphql-tag';
34
+
35
+ export const commonApiExtensions = gql\`
36
+ type ${entityName} implements Node {
37
+ id: ID!
38
+ createdAt: DateTime!
39
+ updatedAt: DateTime!
40
+ name: String!
41
+ }
42
+
43
+ type ${entityName}List implements PaginatedList {
44
+ items: [${entityName}!]!
45
+ totalItems: Int!
46
+ }
47
+
48
+ extend type Query {
49
+ ${context.entity.instanceName}s(options: ${entityName}ListOptions): ${entityName}List!
50
+ ${context.entity.instanceName}(id: ID!): ${entityName}
51
+ }
52
+
53
+ # Auto-generated at runtime
54
+ input ${entityName}ListOptions
55
+ \`;
56
+
57
+ export const shopApiExtensions = gql\`
58
+ \${commonApiExtensions}
59
+ \`;
60
+
61
+ export const adminApiExtensions = gql\`
62
+ \${commonApiExtensions}
63
+
64
+ extend type Mutation {
65
+ create${entityName}(input: Create${entityName}Input!): ${entityName}!
66
+ update${entityName}(input: Update${entityName}Input!): ${entityName}!
67
+ }
68
+
69
+ input Create${entityName}Input {
70
+ name: String!
71
+ }
72
+
73
+ input Update${entityName}Input {
74
+ id: ID!
75
+ name: String!
76
+ }
77
+ \`;
78
+ `;
79
+ }
80
+ }
81
+ exports.renderApiExtensions = renderApiExtensions;
82
+ //# sourceMappingURL=api-extensions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-extensions.js","sourceRoot":"","sources":["../../../../../../src/commands/new/plugin/scaffold/api/api-extensions.ts"],"names":[],"mappings":";;;AAIA,SAAgB,mBAAmB,CAAC,OAAwB;IACxD,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE;QAC5B,OAAO,EAAE,CAAC;KACb;IACD,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE;QAC3B,OAAiC;;;;;;;;;;;;;;;;;;;CAmBxC,CAAC;KACG;SAAM;QACH,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC;QAC5C,OAAiC;;;;WAI9B,UAAU;;;;;;;WAOV,UAAU;kBACH,UAAU;;;;;UAKlB,OAAO,CAAC,MAAM,CAAC,YAAY,cAAc,UAAU,iBAAiB,UAAU;UAC9E,OAAO,CAAC,MAAM,CAAC,YAAY,cAAc,UAAU;;;;YAIjD,UAAU;;;;;;;;;;;gBAWN,UAAU,iBAAiB,UAAU,YAAY,UAAU;gBAC3D,UAAU,iBAAiB,UAAU,YAAY,UAAU;;;kBAGzD,UAAU;;;;kBAIV,UAAU;;;;;CAK3B,CAAC;KACG;AACL,CAAC;AA3ED,kDA2EC"}
@@ -0,0 +1,3 @@
1
+ import { TemplateContext } from '../../types';
2
+ export declare function renderShopResolverWithEntity(context: TemplateContext): string;
3
+ export declare function renderShopResolver(context: TemplateContext): string;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderShopResolver = exports.renderShopResolverWithEntity = void 0;
4
+ function renderShopResolverWithEntity(context) {
5
+ return `
6
+ import { Args, Query, Resolver } from '@nestjs/graphql';
7
+ import { Ctx, PaginatedList, RequestContext, ListQueryOptions } from '@vendure/core';
8
+
9
+ import { ${context.service.className} } from '../services/${context.service.fileName}';
10
+ import { ${context.entity.className} } from '../entities/${context.entity.fileName}';
11
+
12
+ @Resolver()
13
+ export class ShopResolver {
14
+ constructor(private ${context.service.instanceName}: ${context.service.className}) {
15
+ }
16
+
17
+ @Query()
18
+ ${context.entity.instanceName}s(
19
+ @Ctx() ctx: RequestContext,
20
+ @Args() args: { options: ListQueryOptions<${context.customEntityName}> },
21
+ ): Promise<PaginatedList<${context.customEntityName}>> {
22
+ return this.${context.service.instanceName}.findAll(ctx, args.options || undefined);
23
+ }
24
+
25
+ @Query()
26
+ ${context.entity.instanceName}(@Ctx() ctx: RequestContext, @Args() args: { id: string }): Promise<${context.customEntityName} | null> {
27
+ return this.${context.service.instanceName}.findOne(ctx, args.id);
28
+ }
29
+ }`;
30
+ }
31
+ exports.renderShopResolverWithEntity = renderShopResolverWithEntity;
32
+ function renderShopResolver(context) {
33
+ return `
34
+ import { Args, Query, Mutation, Resolver } from '@nestjs/graphql';
35
+ import { Ctx, PaginatedList, RequestContext, Transaction } from '@vendure/core';
36
+
37
+ import { ${context.service.className} } from '../services/${context.service.fileName}';
38
+
39
+ @Resolver()
40
+ export class ShopResolver {
41
+ constructor(private ${context.service.instanceName}: ${context.service.className}) {
42
+ }
43
+
44
+ @Query()
45
+ exampleShopQuery(@Ctx() ctx: RequestContext) {
46
+ return this.${context.service.instanceName}.exampleMethod(ctx);
47
+ }
48
+
49
+ @Mutation()
50
+ @Transaction()
51
+ exampleShopMutation(@Ctx() ctx: RequestContext, @Args() args: { input: string }) {
52
+ return this.${context.service.instanceName}.exampleMethod(ctx, args);
53
+ }
54
+ }`;
55
+ }
56
+ exports.renderShopResolver = renderShopResolver;
57
+ //# sourceMappingURL=shop.resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shop.resolver.js","sourceRoot":"","sources":["../../../../../../src/commands/new/plugin/scaffold/api/shop.resolver.ts"],"names":[],"mappings":";;;AAEA,SAAgB,4BAA4B,CAAC,OAAwB;IACjE,OAAiC;;;;WAI1B,OAAO,CAAC,OAAO,CAAC,SAAS,wBAAwB,OAAO,CAAC,OAAO,CAAC,QAAQ;WACzE,OAAO,CAAC,MAAM,CAAC,SAAS,wBAAwB,OAAO,CAAC,MAAM,CAAC,QAAQ;;;;0BAIxD,OAAO,CAAC,OAAO,CAAC,YAAY,KAAK,OAAO,CAAC,OAAO,CAAC,SAAS;;;;MAI9E,OAAO,CAAC,MAAM,CAAC,YAAY;;oDAEmB,OAAO,CAAC,gBAAgB;+BAC7C,OAAO,CAAC,gBAAgB;sBACjC,OAAO,CAAC,OAAO,CAAC,YAAY;;;;MAI5C,OAAO,CAAC,MAAM,CAAC,YAAY,uEAAuE,OAAO,CAAC,gBAAgB;sBAC1G,OAAO,CAAC,OAAO,CAAC,YAAY;;EAEhD,CAAC;AACH,CAAC;AA1BD,oEA0BC;AAED,SAAgB,kBAAkB,CAAC,OAAwB;IACvD,OAAiC;;;;WAI1B,OAAO,CAAC,OAAO,CAAC,SAAS,wBAAwB,OAAO,CAAC,OAAO,CAAC,QAAQ;;;;0BAI1D,OAAO,CAAC,OAAO,CAAC,YAAY,KAAK,OAAO,CAAC,OAAO,CAAC,SAAS;;;;;sBAK9D,OAAO,CAAC,OAAO,CAAC,YAAY;;;;;;sBAM5B,OAAO,CAAC,OAAO,CAAC,YAAY;;EAEhD,CAAC;AACH,CAAC;AAvBD,gDAuBC"}
@@ -0,0 +1,2 @@
1
+ import { TemplateContext } from '../types';
2
+ export declare function renderConstants(context: TemplateContext): string;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderConstants = void 0;
4
+ function renderConstants(context) {
5
+ const { pluginName, pluginInitOptionsName } = context;
6
+ const optionalImports = [];
7
+ const optionalStatements = [];
8
+ if (context.withCustomEntity) {
9
+ optionalImports.push(`import { CrudPermissionDefinition } from '@vendure/core';`);
10
+ optionalStatements.push(`export const ${context.entity.instanceName}Permission = new CrudPermissionDefinition('${context.entity.className}');`);
11
+ }
12
+ return `
13
+ ${optionalImports.join('\n')}
14
+
15
+ export const ${pluginInitOptionsName} = Symbol('${pluginInitOptionsName}');
16
+ export const loggerCtx = '${pluginName}';
17
+ ${optionalStatements.join('\n')}
18
+ `;
19
+ }
20
+ exports.renderConstants = renderConstants;
21
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/commands/new/plugin/scaffold/constants.ts"],"names":[],"mappings":";;;AAIA,SAAgB,eAAe,CAAC,OAAwB;IACpD,MAAM,EAAE,UAAU,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAC;IACtD,MAAM,eAAe,GAAa,EAAE,CAAC;IACrC,MAAM,kBAAkB,GAAa,EAAE,CAAC;IACxC,IAAI,OAAO,CAAC,gBAAgB,EAAE;QAC1B,eAAe,CAAC,IAAI,CAAC,2DAA2D,CAAC,CAAC;QAClF,kBAAkB,CAAC,IAAI,CACnB,gBAAgB,OAAO,CAAC,MAAM,CAAC,YAAY,8CAA8C,OAAO,CAAC,MAAM,CAAC,SAAS,KAAK,CACzH,CAAC;KACL;IACD,OAAiC;EACnC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC;;eAEb,qBAAqB,cAAc,qBAAqB;4BAC3C,UAAU;EACpC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC;CAC9B,CAAC;AACF,CAAC;AAjBD,0CAiBC"}
@@ -0,0 +1,2 @@
1
+ import { TemplateContext } from '../../types';
2
+ export declare function renderEntity(context: TemplateContext): string;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderEntity = void 0;
4
+ function renderEntity(context) {
5
+ return `
6
+ import { Entity, Column } from 'typeorm';
7
+ import { VendureEntity, DeepPartial } from '@vendure/core';
8
+
9
+ @Entity()
10
+ export class ${context.entity.className} extends VendureEntity {
11
+ constructor(input?: DeepPartial<${context.entity.className}>) {
12
+ super(input);
13
+ }
14
+
15
+ @Column()
16
+ name: string;
17
+ }
18
+ `;
19
+ }
20
+ exports.renderEntity = renderEntity;
21
+ //# sourceMappingURL=entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity.js","sourceRoot":"","sources":["../../../../../../src/commands/new/plugin/scaffold/entities/entity.ts"],"names":[],"mappings":";;;AAEA,SAAgB,YAAY,CAAC,OAAwB;IACjD,OAAiC;;;;;eAKtB,OAAO,CAAC,MAAM,CAAC,SAAS;sCACD,OAAO,CAAC,MAAM,CAAC,SAAS;;;;;;;CAO7D,CAAC;AACF,CAAC;AAfD,oCAeC"}
@@ -0,0 +1,2 @@
1
+ import { TemplateContext } from '../types';
2
+ export declare function renderPlugin(context: TemplateContext): string;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderPlugin = void 0;
4
+ function renderPlugin(context) {
5
+ const { pluginName, pluginInitOptionsName } = context;
6
+ const optionalImports = [];
7
+ const optionalMetadata = [];
8
+ if (context.withCustomEntity) {
9
+ optionalImports.push(`import { ${context.entity.className} } from './entities/${context.entity.fileName}';`);
10
+ optionalMetadata.push(`entities: [${context.entity.className}],`);
11
+ }
12
+ else {
13
+ optionalMetadata.push(`entities: [],`);
14
+ }
15
+ if (context.withApiExtensions) {
16
+ optionalImports.push(`import { shopApiExtensions, adminApiExtensions } from './api/api-extensions';`);
17
+ optionalImports.push(`import { ShopResolver } from './api/shop.resolver';`);
18
+ optionalImports.push(`import { AdminResolver } from './api/admin.resolver';`);
19
+ optionalMetadata.push(`shopApiExtensions: { resolvers: [ShopResolver], schema: shopApiExtensions },`);
20
+ optionalMetadata.push(`adminApiExtensions: { resolvers: [AdminResolver], schema: adminApiExtensions },`);
21
+ }
22
+ return `
23
+ import { PluginCommonModule, Type, VendurePlugin } from '@vendure/core';
24
+ import path from 'path';
25
+
26
+ import { ${context.service.className} } from './services/${context.service.fileName}';
27
+ import { ${pluginInitOptionsName} } from './constants';
28
+ import { PluginInitOptions } from './types';
29
+ ${optionalImports.join('\n')}
30
+
31
+ @VendurePlugin({
32
+ imports: [PluginCommonModule],
33
+ ${optionalMetadata.join('\n ')}
34
+ providers: [
35
+ ${context.service.className},
36
+ { provide: ${pluginInitOptionsName}, useFactory: () => ${pluginName}.options },
37
+ ],
38
+ compatibility: '^2.0.0',
39
+ })
40
+ export class ${pluginName} {
41
+ static options: PluginInitOptions;
42
+
43
+ static init(options: PluginInitOptions): Type<${pluginName}> {
44
+ this.options = options;
45
+ return ${pluginName};
46
+ }
47
+ }
48
+ `;
49
+ }
50
+ exports.renderPlugin = renderPlugin;
51
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../../../src/commands/new/plugin/scaffold/plugin.ts"],"names":[],"mappings":";;;AAIA,SAAgB,YAAY,CAAC,OAAwB;IACjD,MAAM,EAAE,UAAU,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAC;IACtD,MAAM,eAAe,GAAa,EAAE,CAAC;IACrC,MAAM,gBAAgB,GAAa,EAAE,CAAC;IACtC,IAAI,OAAO,CAAC,gBAAgB,EAAE;QAC1B,eAAe,CAAC,IAAI,CAChB,YAAY,OAAO,CAAC,MAAM,CAAC,SAAS,uBAAuB,OAAO,CAAC,MAAM,CAAC,QAAQ,IAAI,CACzF,CAAC;QACF,gBAAgB,CAAC,IAAI,CAAC,cAAc,OAAO,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC,CAAC;KACrE;SAAM;QACH,gBAAgB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;KAC1C;IACD,IAAI,OAAO,CAAC,iBAAiB,EAAE;QAC3B,eAAe,CAAC,IAAI,CAAC,+EAA+E,CAAC,CAAC;QACtG,eAAe,CAAC,IAAI,CAAC,qDAAqD,CAAC,CAAC;QAC5E,eAAe,CAAC,IAAI,CAAC,uDAAuD,CAAC,CAAC;QAC9E,gBAAgB,CAAC,IAAI,CAAC,8EAA8E,CAAC,CAAC;QACtG,gBAAgB,CAAC,IAAI,CACjB,iFAAiF,CACpF,CAAC;KACL;IAED,OAAiC;;;;WAI1B,OAAO,CAAC,OAAO,CAAC,SAAS,uBAAuB,OAAO,CAAC,OAAO,CAAC,QAAQ;WACxE,qBAAqB;;EAE9B,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC;;;;MAItB,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC;;UAE3B,OAAO,CAAC,OAAO,CAAC,SAAS;qBACd,qBAAqB,uBAAuB,UAAU;;;;eAI5D,UAAU;;;oDAG2B,UAAU;;iBAE7C,UAAU;;;CAG1B,CAAC;AACF,CAAC;AAjDD,oCAiDC"}
@@ -0,0 +1,3 @@
1
+ import { TemplateContext } from '../../types';
2
+ export declare function renderService(context: TemplateContext): string;
3
+ export declare function renderServiceWithEntity(context: TemplateContext): string;
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderServiceWithEntity = exports.renderService = void 0;
4
+ function renderService(context) {
5
+ return `
6
+ import { Inject, Injectable } from '@nestjs/common';
7
+ import { RequestContext, TransactionalConnection } from '@vendure/core';
8
+
9
+ import { ${context.pluginInitOptionsName} } from '../constants';
10
+ import { PluginInitOptions } from '../types';
11
+
12
+ @Injectable()
13
+ export class ${context.service.className} {
14
+ constructor(
15
+ private connection: TransactionalConnection,
16
+ @Inject(${context.pluginInitOptionsName}) private options: PluginInitOptions,
17
+ ) {}
18
+
19
+ async exampleMethod(
20
+ ctx: RequestContext,
21
+ options?: { input?: string },
22
+ ): Promise<string> {
23
+ return options?.input ? 'Hello \${options.input}' : 'Hello World';
24
+ }
25
+ }
26
+ `;
27
+ }
28
+ exports.renderService = renderService;
29
+ function renderServiceWithEntity(context) {
30
+ return `
31
+ import { Inject, Injectable } from '@nestjs/common';
32
+ import { ListQueryBuilder, ListQueryOptions, PaginatedList, RequestContext, TransactionalConnection } from '@vendure/core';
33
+
34
+ import { ${context.customEntityName} } from '../entities/${context.entity.fileName}';
35
+ import { ${context.pluginInitOptionsName} } from '../constants';
36
+ import { PluginInitOptions } from '../types';
37
+
38
+ // TODO: Set up graphql-code-generator to generate the types for the following inputs
39
+ type Create${context.customEntityName}Input = any;
40
+ type Update${context.customEntityName}Input = any;
41
+
42
+ @Injectable()
43
+ export class ${context.service.className} {
44
+ constructor(
45
+ private connection: TransactionalConnection,
46
+ @Inject(${context.pluginInitOptionsName}) private options: PluginInitOptions,
47
+ private listQueryBuilder: ListQueryBuilder,
48
+ ) {}
49
+
50
+ async findAll(
51
+ ctx: RequestContext,
52
+ options?: ListQueryOptions<${context.customEntityName}>,
53
+ ): Promise<PaginatedList<${context.customEntityName}>> {
54
+ return this.listQueryBuilder
55
+ .build(${context.customEntityName}, options, { ctx })
56
+ .getManyAndCount()
57
+ .then(([items, totalItems]) => ({
58
+ items,
59
+ totalItems,
60
+ }));
61
+ }
62
+
63
+ async findOne(ctx: RequestContext, id: string): Promise<${context.customEntityName} | null> {
64
+ return this.connection.getRepository(ctx, ${context.customEntityName}).findOne({ where: { id } });
65
+ }
66
+
67
+ async create(ctx: RequestContext, input: Create${context.customEntityName}Input): Promise<${context.customEntityName}> {
68
+ return this.connection.getRepository(ctx, ${context.customEntityName}).save(new ${context.customEntityName}(input));
69
+ }
70
+
71
+ async update(ctx: RequestContext, input: Update${context.customEntityName}Input): Promise<${context.customEntityName}> {
72
+ const example = await this.connection.getEntityOrThrow(ctx, ${context.customEntityName}, input.id);
73
+ const updated = { ...example, ...input };
74
+ return this.connection.getRepository(ctx, ${context.customEntityName}).save(updated);
75
+ }
76
+ }
77
+ `;
78
+ }
79
+ exports.renderServiceWithEntity = renderServiceWithEntity;
80
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../../../../src/commands/new/plugin/scaffold/services/service.ts"],"names":[],"mappings":";;;AAIA,SAAgB,aAAa,CAAC,OAAwB;IAClD,OAAiC;;;;WAI1B,OAAO,CAAC,qBAAqB;;;;eAIzB,OAAO,CAAC,OAAO,CAAC,SAAS;;;kBAGtB,OAAO,CAAC,qBAAqB;;;;;;;;;;CAU9C,CAAC;AACF,CAAC;AAvBD,sCAuBC;AAED,SAAgB,uBAAuB,CAAC,OAAwB;IAC5D,OAAiC;;;;WAI1B,OAAO,CAAC,gBAAgB,wBAAwB,OAAO,CAAC,MAAM,CAAC,QAAQ;WACvE,OAAO,CAAC,qBAAqB;;;;aAI3B,OAAO,CAAC,gBAAgB;aACxB,OAAO,CAAC,gBAAgB;;;eAGtB,OAAO,CAAC,OAAO,CAAC,SAAS;;;kBAGtB,OAAO,CAAC,qBAAqB;;;;;;qCAMV,OAAO,CAAC,gBAAgB;+BAC9B,OAAO,CAAC,gBAAgB;;qBAElC,OAAO,CAAC,gBAAgB;;;;;;;;8DAQiB,OAAO,CAAC,gBAAgB;oDAClC,OAAO,CAAC,gBAAgB;;;qDAGvB,OAAO,CAAC,gBAAgB,mBAAmB,OAAO,CAAC,gBAAgB;oDACpE,OAAO,CAAC,gBAAgB,cAAc,OAAO,CAAC,gBAAgB;;;qDAG7D,OAAO,CAAC,gBAAgB,mBAAmB,OAAO,CAAC,gBAAgB;sEAClD,OAAO,CAAC,gBAAgB;;oDAE1C,OAAO,CAAC,gBAAgB;;;CAG3E,CAAC;AACF,CAAC;AAjDD,0DAiDC"}
@@ -0,0 +1,2 @@
1
+ import { TemplateContext } from '../types';
2
+ export declare function renderTypes(options: TemplateContext): string;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderTypes = void 0;
4
+ function renderTypes(options) {
5
+ return `
6
+ /**
7
+ * The plugin can be configured using the following options:
8
+ */
9
+ export interface PluginInitOptions {
10
+ exampleOption: string;
11
+ }
12
+ `;
13
+ }
14
+ exports.renderTypes = renderTypes;
15
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/commands/new/plugin/scaffold/types.ts"],"names":[],"mappings":";;;AAEA,SAAgB,WAAW,CAAC,OAAwB;IAChD,OAAiC;;;;;;;CAOpC,CAAC;AACF,CAAC;AATD,kCASC"}
@@ -0,0 +1,21 @@
1
+ export interface GeneratePluginOptions {
2
+ name: string;
3
+ withCustomEntity: boolean;
4
+ withApiExtensions: boolean;
5
+ withAdminUi: boolean;
6
+ customEntityName: string;
7
+ }
8
+ export type TemplateContext = GeneratePluginOptions & {
9
+ pluginName: string;
10
+ pluginInitOptionsName: string;
11
+ service: {
12
+ instanceName: string;
13
+ className: string;
14
+ fileName: string;
15
+ };
16
+ entity: {
17
+ instanceName: string;
18
+ className: string;
19
+ fileName: string;
20
+ };
21
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/commands/new/plugin/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@vendure/cli",
3
+ "version": "2.1.0-next.5",
4
+ "description": "A modern, headless ecommerce framework",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/vendure-ecommerce/vendure/"
8
+ },
9
+ "keywords": [
10
+ "vendure",
11
+ "ecommerce",
12
+ "headless",
13
+ "graphql",
14
+ "typescript"
15
+ ],
16
+ "homepage": "https://www.vendure.io/",
17
+ "funding": "https://github.com/sponsors/michaelbromley",
18
+ "private": false,
19
+ "license": "MIT",
20
+ "type": "commonjs",
21
+ "scripts": {
22
+ "build": "rimraf dist && tsc -p ./tsconfig.cli.json",
23
+ "watch": "tsc -p ./tsconfig.cli.json --watch",
24
+ "ci": "yarn build"
25
+ },
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "bin": {
30
+ "vendure": "dist/cli.js"
31
+ },
32
+ "files": [
33
+ "dist/**/*"
34
+ ],
35
+ "dependencies": {
36
+ "@clack/prompts": "^0.7.0",
37
+ "@vendure/common": "2.1.0-next.5",
38
+ "change-case": "^4.1.2",
39
+ "commander": "^11.0.0",
40
+ "fs-extra": "^11.1.1",
41
+ "picocolors": "^1.0.0"
42
+ },
43
+ "devDependencies": {
44
+ "typescript": "4.9.5"
45
+ },
46
+ "gitHead": "b4b78ba7ac534e5995877e46421870b114f429de"
47
+ }