gaffer-generator 1.2.7 → 2.0.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.
Files changed (47) hide show
  1. package/README.md +4 -2
  2. package/cli.js +43 -37
  3. package/lib/argv.js +9 -0
  4. package/lib/create.js +40 -0
  5. package/{src → lib}/generate/directory.js +13 -14
  6. package/{src → lib}/generate/file.js +13 -13
  7. package/{src → lib}/generate/node.js +6 -9
  8. package/lib/generate/root.js +95 -0
  9. package/{src → lib}/templateArgs.js +1 -1
  10. package/lib/utils/contentsDiffer.js +20 -0
  11. package/lib/utils/log.js +26 -0
  12. package/lib/utils/logChange.js +16 -0
  13. package/lib/utils/logError.js +10 -0
  14. package/lib/utils/logRemoval.js +10 -0
  15. package/lib/utils/lowerCaseFirst.js +11 -0
  16. package/lib/utils/normalizeLineEndings.js +8 -0
  17. package/lib/utils/normalizePath.js +10 -0
  18. package/lib/utils/parameterizeString.js +19 -0
  19. package/lib/utils/safeRead.js +17 -0
  20. package/lib/utils/safeWrite.js +23 -0
  21. package/lib/utils.js +16 -0
  22. package/package.json +39 -11
  23. package/.github/dependabot.yml +0 -8
  24. package/.github/workflows/codeql-analysis.yml +0 -67
  25. package/SECURITY.md +0 -15
  26. package/example/sample.json +0 -431
  27. package/example/sample.templateroot/date-parser.ts +0 -10
  28. package/example/sample.templateroot/is-set.ts +0 -3
  29. package/example/sample.templateroot/models/_eachEnum.fileName_.ts +0 -13
  30. package/example/sample.templateroot/models/_eachModel.fileName_.ts +0 -73
  31. package/example/sample.templateroot/models/index.ts +0 -14
  32. package/example/sample.templateroot/services/_eachController.fileName_.ts +0 -82
  33. package/example/sample.templateroot/services/index.ts +0 -11
  34. package/example/sample.templateroot/template.js +0 -413
  35. package/jest.config.js +0 -185
  36. package/renovate.json +0 -6
  37. package/src/__mocks__/fs.js +0 -59
  38. package/src/create.js +0 -38
  39. package/src/create.test.js +0 -5
  40. package/src/generate/directory.test.js +0 -5
  41. package/src/generate/file.test.js +0 -5
  42. package/src/generate/node.test.js +0 -5
  43. package/src/generate/root.js +0 -86
  44. package/src/generate/root.test.js +0 -5
  45. package/src/lodash.js +0 -17205
  46. package/src/utils.js +0 -179
  47. package/src/utils.test.js +0 -146
@@ -1,67 +0,0 @@
1
- # For most projects, this workflow file will not need changing; you simply need
2
- # to commit it to your repository.
3
- #
4
- # You may wish to alter this file to override the set of languages analyzed,
5
- # or to provide custom queries or build logic.
6
- #
7
- # ******** NOTE ********
8
- # We have attempted to detect the languages in your repository. Please check
9
- # the `language` matrix defined below to confirm you have the correct set of
10
- # supported CodeQL languages.
11
- #
12
- name: "CodeQL"
13
-
14
- on:
15
- push:
16
- branches: [ master ]
17
- pull_request:
18
- # The branches below must be a subset of the branches above
19
- branches: [ master ]
20
- schedule:
21
- - cron: '22 16 * * 6'
22
-
23
- jobs:
24
- analyze:
25
- name: Analyze
26
- runs-on: ubuntu-latest
27
-
28
- strategy:
29
- fail-fast: false
30
- matrix:
31
- language: [ 'javascript' ]
32
- # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
33
- # Learn more:
34
- # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
35
-
36
- steps:
37
- - name: Checkout repository
38
- uses: actions/checkout@v4
39
-
40
- # Initializes the CodeQL tools for scanning.
41
- - name: Initialize CodeQL
42
- uses: github/codeql-action/init@v3
43
- with:
44
- languages: ${{ matrix.language }}
45
- # If you wish to specify custom queries, you can do so here or in a config file.
46
- # By default, queries listed here will override any specified in a config file.
47
- # Prefix the list here with "+" to use these queries and those in the config file.
48
- # queries: ./path/to/local/query, your-org/your-repo/queries@main
49
-
50
- # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
51
- # If this step fails, then you should remove it and run the build manually (see below)
52
- - name: Autobuild
53
- uses: github/codeql-action/autobuild@v3
54
-
55
- # ℹ️ Command-line programs to run using the OS shell.
56
- # 📚 https://git.io/JvXDl
57
-
58
- # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
59
- # and modify them (or add more) to build your code if your project
60
- # uses a compiled language
61
-
62
- #- run: |
63
- # make bootstrap
64
- # make release
65
-
66
- - name: Perform CodeQL Analysis
67
- uses: github/codeql-action/analyze@v3
package/SECURITY.md DELETED
@@ -1,15 +0,0 @@
1
- # Security Policy
2
-
3
- ## Supported Versions
4
-
5
- Use this section to tell people about which versions of your project are
6
- currently being supported with security updates.
7
-
8
- | Version | Supported |
9
- | ------- | ------------------ |
10
- | 1.x | :white_check_mark: |
11
-
12
- ## Reporting a Vulnerability
13
-
14
- If you discover a vulnerability, please create an Issue, or better yet,
15
- a Pull Request, and we'll tackle it together!
@@ -1,431 +0,0 @@
1
- {
2
- "namespace": "Sample.WebApi",
3
- "apiVersion": "1.0.0",
4
- "controllers": [
5
- {
6
- "name": "Address",
7
- "authorized": false,
8
- "obsolete": false,
9
- "methods": [
10
- {
11
- "name": "FindById",
12
- "httpMethodId": 1,
13
- "path": "/address/{addressId}",
14
- "authorized": false,
15
- "obsolete": false,
16
- "attributes": null,
17
- "parameters": [
18
- {
19
- "name": "addressId",
20
- "obsolete": false,
21
- "optional": true,
22
- "hasDefaultValue": true,
23
- "defaultValue": 0,
24
- "sourceId": 1,
25
- "type": {
26
- "typeId": 6,
27
- "formatId": 4,
28
- "nullable": false
29
- }
30
- }
31
- ],
32
- "returnType": {
33
- "typeId": 0,
34
- "name": "Address",
35
- "nullable": false
36
- },
37
- "docs": {
38
- "summary": null,
39
- "remarks": null,
40
- "parameters": [],
41
- "returns": null
42
- }
43
- }
44
- ],
45
- "dependencies": [
46
- "Address"
47
- ],
48
- "docs": {
49
- "summary": null,
50
- "remarks": null
51
- }
52
- }
53
- ],
54
- "enums": [
55
- {
56
- "name": "DayOfWeek",
57
- "fullName": "System.DayOfWeek",
58
- "obsolete": false,
59
- "typeId": 1,
60
- "properties": [
61
- {
62
- "name": "Sunday",
63
- "value": 0
64
- },
65
- {
66
- "name": "Monday",
67
- "value": 1
68
- },
69
- {
70
- "name": "Tuesday",
71
- "value": 2
72
- },
73
- {
74
- "name": "Wednesday",
75
- "value": 3
76
- },
77
- {
78
- "name": "Thursday",
79
- "value": 4
80
- },
81
- {
82
- "name": "Friday",
83
- "value": 5
84
- },
85
- {
86
- "name": "Saturday",
87
- "value": 6
88
- }
89
- ],
90
- "docs": {
91
- "summary": null,
92
- "remarks": null
93
- }
94
- }
95
- ],
96
- "models": [
97
- {
98
- "name": "Address",
99
- "fullName": "Sample.Addresses.Address",
100
- "obsolete": false,
101
- "typeId": 0,
102
- "properties": [
103
- {
104
- "name": "StreetAddress",
105
- "obsolete": false,
106
- "type": {
107
- "typeId": 7,
108
- "formatId": 0,
109
- "nullable": false
110
- }
111
- },
112
- {
113
- "name": "StreetAddressLine2",
114
- "obsolete": false,
115
- "type": {
116
- "typeId": 7,
117
- "formatId": 0,
118
- "nullable": false
119
- }
120
- },
121
- {
122
- "name": "City",
123
- "obsolete": false,
124
- "type": {
125
- "typeId": 7,
126
- "formatId": 0,
127
- "nullable": false
128
- }
129
- },
130
- {
131
- "name": "County",
132
- "obsolete": false,
133
- "type": {
134
- "typeId": 7,
135
- "formatId": 0,
136
- "nullable": false
137
- }
138
- },
139
- {
140
- "name": "State",
141
- "obsolete": false,
142
- "type": {
143
- "typeId": 7,
144
- "formatId": 0,
145
- "nullable": false
146
- }
147
- },
148
- {
149
- "name": "Zip",
150
- "obsolete": false,
151
- "type": {
152
- "typeId": 7,
153
- "formatId": 0,
154
- "nullable": false
155
- }
156
- },
157
- {
158
- "name": "Centroid",
159
- "obsolete": false,
160
- "type": {
161
- "typeId": 0,
162
- "name": "GeoPoint",
163
- "nullable": true
164
- }
165
- }
166
- ],
167
- "dependencies": [
168
- "GeoPoint"
169
- ],
170
- "docs": {
171
- "summary": null,
172
- "remarks": null
173
- }
174
- },
175
- {
176
- "name": "GeoPoint",
177
- "fullName": "Sample.Common.GeoPoint",
178
- "obsolete": false,
179
- "typeId": 0,
180
- "properties": [
181
- {
182
- "name": "Latitude",
183
- "obsolete": false,
184
- "type": {
185
- "typeId": 6,
186
- "formatId": 10,
187
- "nullable": false
188
- }
189
- },
190
- {
191
- "name": "Longitude",
192
- "obsolete": false,
193
- "type": {
194
- "typeId": 6,
195
- "formatId": 10,
196
- "nullable": false
197
- }
198
- }
199
- ],
200
- "dependencies": [],
201
- "docs": {
202
- "summary": null,
203
- "remarks": null
204
- }
205
- },
206
- {
207
- "name": "GeoPolygon",
208
- "fullName": "Sample.Common.GeoPolygon",
209
- "obsolete": false,
210
- "typeId": 0,
211
- "properties": [
212
- {
213
- "name": "Points",
214
- "obsolete": false,
215
- "type": {
216
- "typeId": 3,
217
- "of": {
218
- "typeId": 0,
219
- "name": "GeoPoint",
220
- "nullable": false
221
- },
222
- "nullable": false
223
- }
224
- }
225
- ],
226
- "dependencies": [
227
- "GeoPoint"
228
- ],
229
- "docs": {
230
- "summary": null,
231
- "remarks": null
232
- }
233
- },
234
- {
235
- "name": "GeoRectangle",
236
- "fullName": "Sample.Common.GeoRectangle",
237
- "obsolete": false,
238
- "typeId": 0,
239
- "properties": [
240
- {
241
- "name": "WestLongitude",
242
- "obsolete": false,
243
- "type": {
244
- "typeId": 6,
245
- "formatId": 10,
246
- "nullable": false
247
- }
248
- },
249
- {
250
- "name": "NorthLatitude",
251
- "obsolete": false,
252
- "type": {
253
- "typeId": 6,
254
- "formatId": 10,
255
- "nullable": false
256
- }
257
- },
258
- {
259
- "name": "EastLongitude",
260
- "obsolete": false,
261
- "type": {
262
- "typeId": 6,
263
- "formatId": 10,
264
- "nullable": false
265
- }
266
- },
267
- {
268
- "name": "SouthLatitude",
269
- "obsolete": false,
270
- "type": {
271
- "typeId": 6,
272
- "formatId": 10,
273
- "nullable": false
274
- }
275
- }
276
- ],
277
- "dependencies": [],
278
- "docs": {
279
- "summary": null,
280
- "remarks": null
281
- }
282
- },
283
- {
284
- "name": "PageIndex",
285
- "fullName": "Sample.Common.Paging+PageIndex",
286
- "obsolete": false,
287
- "typeId": 0,
288
- "properties": [
289
- {
290
- "name": "Index",
291
- "obsolete": false,
292
- "type": {
293
- "typeId": 6,
294
- "formatId": 4,
295
- "nullable": false
296
- }
297
- },
298
- {
299
- "name": "IsDisplayedAsEllipsis",
300
- "obsolete": false,
301
- "type": {
302
- "typeId": 5,
303
- "nullable": false
304
- }
305
- },
306
- {
307
- "name": "DisplayText",
308
- "obsolete": false,
309
- "type": {
310
- "typeId": 7,
311
- "formatId": 0,
312
- "nullable": false
313
- }
314
- }
315
- ],
316
- "dependencies": [],
317
- "docs": {
318
- "summary": null,
319
- "remarks": null
320
- }
321
- },
322
- {
323
- "name": "Paging",
324
- "fullName": "Sample.Common.Paging",
325
- "obsolete": false,
326
- "typeId": 0,
327
- "properties": [
328
- {
329
- "name": "DisplayCharCount",
330
- "obsolete": false,
331
- "type": {
332
- "typeId": 6,
333
- "formatId": 4,
334
- "nullable": false
335
- }
336
- },
337
- {
338
- "name": "CurrentPageSize",
339
- "obsolete": false,
340
- "type": {
341
- "typeId": 6,
342
- "formatId": 4,
343
- "nullable": false
344
- }
345
- },
346
- {
347
- "name": "ItemsCount",
348
- "obsolete": false,
349
- "type": {
350
- "typeId": 6,
351
- "formatId": 4,
352
- "nullable": true
353
- }
354
- },
355
- {
356
- "name": "CurrentPageIndex",
357
- "obsolete": false,
358
- "type": {
359
- "typeId": 6,
360
- "formatId": 4,
361
- "nullable": false
362
- }
363
- },
364
- {
365
- "name": "HasItems",
366
- "obsolete": false,
367
- "type": {
368
- "typeId": 5,
369
- "nullable": false
370
- }
371
- },
372
- {
373
- "name": "FirstPageIndex",
374
- "obsolete": false,
375
- "type": {
376
- "typeId": 6,
377
- "formatId": 4,
378
- "nullable": false
379
- }
380
- },
381
- {
382
- "name": "LastPageIndex",
383
- "obsolete": false,
384
- "type": {
385
- "typeId": 6,
386
- "formatId": 4,
387
- "nullable": false
388
- }
389
- },
390
- {
391
- "name": "PreviousPageIndex",
392
- "obsolete": false,
393
- "type": {
394
- "typeId": 6,
395
- "formatId": 4,
396
- "nullable": true
397
- }
398
- },
399
- {
400
- "name": "NextPageIndex",
401
- "obsolete": false,
402
- "type": {
403
- "typeId": 6,
404
- "formatId": 4,
405
- "nullable": true
406
- }
407
- },
408
- {
409
- "name": "PageIndexes",
410
- "obsolete": false,
411
- "type": {
412
- "typeId": 3,
413
- "of": {
414
- "typeId": 0,
415
- "name": "PageIndex",
416
- "nullable": false
417
- },
418
- "nullable": false
419
- }
420
- }
421
- ],
422
- "dependencies": [
423
- "PageIndex"
424
- ],
425
- "docs": {
426
- "summary": null,
427
- "remarks": null
428
- }
429
- }
430
- ]
431
- }
@@ -1,10 +0,0 @@
1
- // TODO: Write this appropriately for your server.
2
- export class DateParser {
3
- public static fromServer(str: string): any {
4
- return new Date(str);
5
- }
6
-
7
- public static forServer(date: Date): string {
8
- return String(date);
9
- }
10
- }
@@ -1,3 +0,0 @@
1
- export function isSet(val) {
2
- return val !== undefined && val !== null;
3
- }
@@ -1,13 +0,0 @@
1
- // ------------------------------------------------------------------------------
2
- // <auto-generated>
3
- // This code was generated by a tool using the template near this directory.
4
- // Please see this solution for more details: Codegen\Codegen.sln
5
- // Changes to this file may cause incorrect behavior and will be lost if
6
- // the code is regenerated.
7
- // </auto-generated>
8
- // ------------------------------------------------------------------------------
9
- export enum <%- Enum.name %> {<%
10
- Enum.properties.forEach(property => { %>
11
- <%- property.name %> = <%- property.value %>,<%
12
- }); %>
13
- }
@@ -1,73 +0,0 @@
1
- // ------------------------------------------------------------------------------
2
- // <auto-generated>
3
- // This code was generated by a tool using the template near this directory.
4
- // Please see this solution for more details: Codegen\Codegen.sln
5
- // Changes to this file may cause incorrect behavior and will be lost if
6
- // the code is regenerated.
7
- // </auto-generated>
8
- // ------------------------------------------------------------------------------
9
- import { DateParser } from '../date-parser';
10
- import { isSet } from '../is-set';
11
- import {<%
12
- dependencies.forEach((dependency, index) => { %>
13
- <%= dependency %><%= index + 1 !== dependencies.length ? ',' : '' %><%
14
- }); %> } from './';
15
-
16
- export class <%= utils.handleBase(Model) %> {<%
17
- Model.properties.forEach(property => { %>
18
- public <%- utils.lowerCaseFirst(property.name) %>:<%- utils.parseType(property) %>;<%
19
- });
20
- %>
21
-
22
- constructor(properties?:Partial<<%= utils.handleBase(Model) %>>) {
23
- if (isSet(properties)) {
24
- <%= utils.handleBase(Model) %>.copyProperties(properties, this);
25
- }
26
- }
27
-
28
- public static fromJSON(json:any) {
29
- let retVal = new <%= utils.handleBase(Model) %>();
30
- if (!json) {
31
- return retVal;
32
- }
33
- <%= utils.handleBase(Model) %>.copyProperties(json, retVal);
34
- return retVal;
35
- }
36
-
37
- private static copyProperties(
38
- from:Partial<<%= utils.handleBase(Model) %>>,
39
- to:Partial<<%= utils.handleBase(Model) %>>) {<%
40
- Model.properties.forEach(property => {
41
- %>
42
- if (isSet(from.<%= utils.lowerCaseFirst(property.name) %>)) {
43
- <%= utils.copyProperties(property.name, property.type) %>
44
- }<%
45
- }); %>
46
- }
47
-
48
- public clone():<%= utils.handleBase(Model) %> {
49
- let retVal = new <%= utils.handleBase(Model) %>();
50
- <%= utils.handleBase(Model) %>.copyProperties(this, retVal);
51
- return retVal;
52
- }
53
-
54
- public toJSON():any {
55
- let retVal:any = {};
56
- <%= utils.handleBase(Model) %>.copyProperties(this, retVal);
57
- return retVal;
58
- }<%
59
- Model.properties
60
- .filter(property => property.type.typeId === utils.MetaTypes.String
61
- && property.type.formatId === utils.MetaStringFormat.DateTime)
62
- .forEach(property => { %>
63
-
64
- public get <%- utils.lowerCaseFirst(property.name).replace(/DateTime$/, '') %>Moment() {
65
- return DateParser.fromServer(this.<%- utils.lowerCaseFirst(property.name) %>);
66
- }
67
-
68
- public set <%- utils.lowerCaseFirst(property.name).replace(/DateTime$/, '') %>Moment(value) {
69
- this.<%- utils.lowerCaseFirst(property.name) %> = DateParser.forServer(value);
70
- }<%
71
- });
72
- %>
73
- }
@@ -1,14 +0,0 @@
1
- // ------------------------------------------------------------------------------
2
- // <auto-generated>
3
- // This code was generated by a tool using the template near this directory.
4
- // Please see this solution for more details: Codegen\Codegen.sln
5
- // Changes to this file may cause incorrect behavior and will be lost if
6
- // the code is regenerated.
7
- // </auto-generated>
8
- // ------------------------------------------------------------------------------<%
9
- enums.forEach(item => { %>
10
- export { <%= item.name %> } from './<%= item.fileName %>';<%
11
- });
12
- models.forEach(model => { %>
13
- export { <%= model.name %> } from '<%= utils.customExists(model) ? '../custom/' : './' %><%= model.fileName %>';<%
14
- }); %>