@jjrawlins/cdk-git-tagger 0.0.0 → 0.0.1

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 (31) hide show
  1. package/.jsii +268 -24
  2. package/jjrawlinscdkgittagger/GitUrlTagger.go +100 -0
  3. package/jjrawlinscdkgittagger/GitUrlTaggerProps.go +14 -0
  4. package/jjrawlinscdkgittagger/GitUrlTagger__checks.go +36 -0
  5. package/jjrawlinscdkgittagger/GitUrlTagger__no_checks.go +18 -0
  6. package/jjrawlinscdkgittagger/LICENSE +202 -0
  7. package/jjrawlinscdkgittagger/README.md +60 -0
  8. package/jjrawlinscdkgittagger/go.mod +13 -0
  9. package/jjrawlinscdkgittagger/internal/types.go +5 -0
  10. package/jjrawlinscdkgittagger/jsii/jsii.go +30 -0
  11. package/jjrawlinscdkgittagger/main.go +30 -0
  12. package/jjrawlinscdkgittagger/version +1 -0
  13. package/lib/GitUrlTagger.d.ts +1 -0
  14. package/lib/GitUrlTagger.js +7 -4
  15. package/package.json +18 -17
  16. package/.git-url-tagger.json +0 -1
  17. package/node_modules/mock-fs/lib/binding.js +0 -1527
  18. package/node_modules/mock-fs/lib/bypass.js +0 -63
  19. package/node_modules/mock-fs/lib/descriptor.js +0 -128
  20. package/node_modules/mock-fs/lib/directory.js +0 -112
  21. package/node_modules/mock-fs/lib/error.js +0 -64
  22. package/node_modules/mock-fs/lib/file.js +0 -127
  23. package/node_modules/mock-fs/lib/filesystem.js +0 -392
  24. package/node_modules/mock-fs/lib/index.js +0 -219
  25. package/node_modules/mock-fs/lib/item.js +0 -338
  26. package/node_modules/mock-fs/lib/loader.js +0 -121
  27. package/node_modules/mock-fs/lib/readfilecontext.js +0 -153
  28. package/node_modules/mock-fs/lib/symlink.js +0 -59
  29. package/node_modules/mock-fs/license.md +0 -49
  30. package/node_modules/mock-fs/package.json +0 -66
  31. package/node_modules/mock-fs/readme.md +0 -290
@@ -1,392 +0,0 @@
1
- 'use strict';
2
-
3
- const os = require('os');
4
- const path = require('path');
5
- const Directory = require('./directory.js');
6
- const File = require('./file.js');
7
- const {FSError} = require('./error.js');
8
- const SymbolicLink = require('./symlink.js');
9
-
10
- const isWindows = process.platform === 'win32';
11
-
12
- // on Win32, change filepath from \\?\c:\a\b to C:\a\b
13
- function getRealPath(filepath) {
14
- if (isWindows && filepath.startsWith('\\\\?\\')) {
15
- // Remove win32 file namespace prefix \\?\
16
- return filepath[4].toUpperCase() + filepath.slice(5);
17
- }
18
- return filepath;
19
- }
20
-
21
- function getPathParts(filepath) {
22
- // path.toNamespacedPath is only for Win32 system.
23
- // on other platform, it returns the path unmodified.
24
- const parts = path.toNamespacedPath(path.resolve(filepath)).split(path.sep);
25
- parts.shift();
26
- if (isWindows) {
27
- // parts currently looks like ['', '?', 'c:', ...]
28
- parts.shift();
29
- const q = parts.shift(); // should be '?'
30
- // https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file?redirectedfrom=MSDN#win32-file-namespaces
31
- // Win32 File Namespaces prefix \\?\
32
- const base = '\\\\' + q + '\\' + parts.shift().toLowerCase();
33
- parts.unshift(base);
34
- }
35
- if (parts[parts.length - 1] === '') {
36
- parts.pop();
37
- }
38
- return parts;
39
- }
40
-
41
- /**
42
- * Create a new file system.
43
- * @param {object} options Any filesystem options.
44
- * @param {boolean} options.createCwd Create a directory for `process.cwd()`
45
- * (defaults to `true`).
46
- * @param {boolean} options.createTmp Create a directory for `os.tmpdir()`
47
- * (defaults to `true`).
48
- * @class
49
- */
50
- function FileSystem(options) {
51
- options = options || {};
52
-
53
- const createCwd = 'createCwd' in options ? options.createCwd : true;
54
- const createTmp = 'createTmp' in options ? options.createTmp : true;
55
-
56
- const root = new Directory();
57
-
58
- // populate with default directories
59
- const defaults = [];
60
- if (createCwd) {
61
- defaults.push(process.cwd());
62
- }
63
-
64
- if (createTmp) {
65
- defaults.push((os.tmpdir && os.tmpdir()) || os.tmpDir());
66
- }
67
-
68
- defaults.forEach(function (dir) {
69
- const parts = getPathParts(dir);
70
- let directory = root;
71
- for (let i = 0, ii = parts.length; i < ii; ++i) {
72
- const name = parts[i];
73
- const candidate = directory.getItem(name);
74
- if (!candidate) {
75
- directory = directory.addItem(name, new Directory());
76
- } else if (candidate instanceof Directory) {
77
- directory = candidate;
78
- } else {
79
- throw new Error('Failed to create directory: ' + dir);
80
- }
81
- }
82
- });
83
-
84
- /**
85
- * Root directory.
86
- * @type {Directory}
87
- */
88
- this._root = root;
89
- }
90
-
91
- /**
92
- * Get the root directory.
93
- * @return {Directory} The root directory.
94
- */
95
- FileSystem.prototype.getRoot = function () {
96
- return this._root;
97
- };
98
-
99
- /**
100
- * Get a file system item.
101
- * @param {string} filepath Path to item.
102
- * @return {Item} The item (or null if not found).
103
- */
104
- FileSystem.prototype.getItem = function (filepath) {
105
- const parts = getPathParts(filepath);
106
- const currentParts = getPathParts(process.cwd());
107
- let item = this._root;
108
- let itemPath = '/';
109
- for (let i = 0, ii = parts.length; i < ii; ++i) {
110
- const name = parts[i];
111
- while (item instanceof SymbolicLink) {
112
- // Symbolic link being traversed as a directory --- If link targets
113
- // another symbolic link, resolve target's path relative to the original
114
- // link's target, otherwise relative to the current item.
115
- itemPath = path.resolve(path.dirname(itemPath), item.getPath());
116
- item = this.getItem(itemPath);
117
- }
118
- if (item) {
119
- if (item instanceof Directory && name !== currentParts[i]) {
120
- // make sure traversal is allowed
121
- // This fails for Windows directories which do not have execute permission, by default. It may be a good idea
122
- // to change this logic to windows-friendly. See notes in mock.createDirectoryInfoFromPaths()
123
- if (!item.canExecute()) {
124
- throw new FSError('EACCES', filepath);
125
- }
126
- }
127
- if (item instanceof File) {
128
- throw new FSError('ENOTDIR', filepath);
129
- }
130
- item = item.getItem(name);
131
- }
132
- if (!item) {
133
- break;
134
- }
135
- itemPath = path.resolve(itemPath, name);
136
- }
137
- return item;
138
- };
139
-
140
- function _getFilepath(item, itemPath, wanted) {
141
- if (item === wanted) {
142
- return itemPath;
143
- }
144
- if (item instanceof Directory) {
145
- for (const name of item.list()) {
146
- const got = _getFilepath(
147
- item.getItem(name),
148
- path.join(itemPath, name),
149
- wanted
150
- );
151
- if (got) {
152
- return got;
153
- }
154
- }
155
- }
156
- return null;
157
- }
158
-
159
- /**
160
- * Get file path from a file system item.
161
- * @param {Item} item a file system item.
162
- * @return {string} file path for the item (or null if not found).
163
- */
164
- FileSystem.prototype.getFilepath = function (item) {
165
- const namespacedPath = _getFilepath(this._root, isWindows ? '' : '/', item);
166
- return getRealPath(namespacedPath);
167
- };
168
-
169
- /**
170
- * Populate a directory with an item.
171
- * @param {Directory} directory The directory to populate.
172
- * @param {string} name The name of the item.
173
- * @param {string | Buffer | Function | object} obj Instructions for creating the
174
- * item.
175
- */
176
- function populate(directory, name, obj) {
177
- let item;
178
- if (typeof obj === 'string' || Buffer.isBuffer(obj)) {
179
- // contents for a file
180
- item = new File();
181
- item.setContent(obj);
182
- } else if (typeof obj === 'function') {
183
- // item factory
184
- item = obj();
185
- } else if (typeof obj === 'object') {
186
- // directory with more to populate
187
- item = new Directory();
188
- for (const key in obj) {
189
- populate(item, key, obj[key]);
190
- }
191
- } else {
192
- throw new Error('Unsupported type: ' + typeof obj + ' of item ' + name);
193
- }
194
-
195
- /**
196
- * Special exception for redundant adding of empty directories.
197
- */
198
- if (
199
- item instanceof Directory &&
200
- item.list().length === 0 &&
201
- directory.getItem(name) instanceof Directory
202
- ) {
203
- // pass
204
- } else {
205
- directory.addItem(name, item);
206
- }
207
- }
208
-
209
- /**
210
- * Configure a mock file system.
211
- * @param {object} paths Config object.
212
- * @param {object} options Any filesystem options.
213
- * @param {boolean} options.createCwd Create a directory for `process.cwd()`
214
- * (defaults to `true`).
215
- * @param {boolean} options.createTmp Create a directory for `os.tmpdir()`
216
- * (defaults to `true`).
217
- * @return {FileSystem} Mock file system.
218
- */
219
- FileSystem.create = function (paths, options) {
220
- const system = new FileSystem(options);
221
-
222
- for (const filepath in paths) {
223
- const parts = getPathParts(filepath);
224
- let directory = system._root;
225
- for (let i = 0, ii = parts.length - 1; i < ii; ++i) {
226
- const name = parts[i];
227
- const candidate = directory.getItem(name);
228
- if (!candidate) {
229
- directory = directory.addItem(name, new Directory());
230
- } else if (candidate instanceof Directory) {
231
- directory = candidate;
232
- } else {
233
- throw new Error('Failed to create directory: ' + filepath);
234
- }
235
- }
236
- populate(directory, parts[parts.length - 1], paths[filepath]);
237
- }
238
-
239
- return system;
240
- };
241
-
242
- /**
243
- * Generate a factory for new files.
244
- * @param {object} config File config.
245
- * @return {function():File} Factory that creates a new file.
246
- */
247
- FileSystem.file = function (config) {
248
- config = config || {};
249
- return function () {
250
- const file = new File();
251
- if (config.hasOwnProperty('content')) {
252
- file.setContent(config.content);
253
- }
254
- if (config.hasOwnProperty('mode')) {
255
- file.setMode(config.mode);
256
- } else {
257
- file.setMode(438); // 0666
258
- }
259
- if (config.hasOwnProperty('uid')) {
260
- file.setUid(config.uid);
261
- }
262
- if (config.hasOwnProperty('gid')) {
263
- file.setGid(config.gid);
264
- }
265
- if (config.hasOwnProperty('atime')) {
266
- file.setATime(config.atime);
267
- } else if (config.hasOwnProperty('atimeMs')) {
268
- file.setATime(new Date(config.atimeMs));
269
- }
270
- if (config.hasOwnProperty('ctime')) {
271
- file.setCTime(config.ctime);
272
- } else if (config.hasOwnProperty('ctimeMs')) {
273
- file.setCTime(new Date(config.ctimeMs));
274
- }
275
- if (config.hasOwnProperty('mtime')) {
276
- file.setMTime(config.mtime);
277
- } else if (config.hasOwnProperty('mtimeMs')) {
278
- file.setMTime(new Date(config.mtimeMs));
279
- }
280
- if (config.hasOwnProperty('birthtime')) {
281
- file.setBirthtime(config.birthtime);
282
- } else if (config.hasOwnProperty('birthtimeMs')) {
283
- file.setBirthtime(new Date(config.birthtimeMs));
284
- }
285
- return file;
286
- };
287
- };
288
-
289
- /**
290
- * Generate a factory for new symbolic links.
291
- * @param {object} config File config.
292
- * @return {function():File} Factory that creates a new symbolic link.
293
- */
294
- FileSystem.symlink = function (config) {
295
- config = config || {};
296
- return function () {
297
- const link = new SymbolicLink();
298
- if (config.hasOwnProperty('mode')) {
299
- link.setMode(config.mode);
300
- } else {
301
- link.setMode(438); // 0666
302
- }
303
- if (config.hasOwnProperty('uid')) {
304
- link.setUid(config.uid);
305
- }
306
- if (config.hasOwnProperty('gid')) {
307
- link.setGid(config.gid);
308
- }
309
- if (config.hasOwnProperty('path')) {
310
- link.setPath(config.path);
311
- } else {
312
- throw new Error('Missing "path" property');
313
- }
314
- if (config.hasOwnProperty('atime')) {
315
- link.setATime(config.atime);
316
- } else if (config.hasOwnProperty('atimeMs')) {
317
- link.setATime(new Date(config.atimeMs));
318
- }
319
- if (config.hasOwnProperty('ctime')) {
320
- link.setCTime(config.ctime);
321
- } else if (config.hasOwnProperty('ctimeMs')) {
322
- link.setCTime(new Date(config.ctimeMs));
323
- }
324
- if (config.hasOwnProperty('mtime')) {
325
- link.setMTime(config.mtime);
326
- } else if (config.hasOwnProperty('mtimeMs')) {
327
- link.setMTime(new Date(config.mtimeMs));
328
- }
329
- if (config.hasOwnProperty('birthtime')) {
330
- link.setBirthtime(config.birthtime);
331
- } else if (config.hasOwnProperty('birthtimeMs')) {
332
- link.setBirthtime(new Date(config.birthtimeMs));
333
- }
334
- return link;
335
- };
336
- };
337
-
338
- /**
339
- * Generate a factory for new directories.
340
- * @param {object} config File config.
341
- * @return {function():Directory} Factory that creates a new directory.
342
- */
343
- FileSystem.directory = function (config) {
344
- config = config || {};
345
- return function () {
346
- const dir = new Directory();
347
- if (config.hasOwnProperty('mode')) {
348
- dir.setMode(config.mode);
349
- }
350
- if (config.hasOwnProperty('uid')) {
351
- dir.setUid(config.uid);
352
- }
353
- if (config.hasOwnProperty('gid')) {
354
- dir.setGid(config.gid);
355
- }
356
- if (config.hasOwnProperty('items')) {
357
- for (const name in config.items) {
358
- populate(dir, name, config.items[name]);
359
- }
360
- }
361
- if (config.hasOwnProperty('atime')) {
362
- dir.setATime(config.atime);
363
- } else if (config.hasOwnProperty('atimeMs')) {
364
- dir.setATime(new Date(config.atimeMs));
365
- }
366
- if (config.hasOwnProperty('ctime')) {
367
- dir.setCTime(config.ctime);
368
- } else if (config.hasOwnProperty('ctimeMs')) {
369
- dir.setCTime(new Date(config.ctimeMs));
370
- }
371
- if (config.hasOwnProperty('mtime')) {
372
- dir.setMTime(config.mtime);
373
- } else if (config.hasOwnProperty('mtimeMs')) {
374
- dir.setMTime(new Date(config.mtimeMs));
375
- }
376
- if (config.hasOwnProperty('birthtime')) {
377
- dir.setBirthtime(config.birthtime);
378
- } else if (config.hasOwnProperty('birthtimeMs')) {
379
- dir.setBirthtime(new Date(config.birthtimeMs));
380
- }
381
- return dir;
382
- };
383
- };
384
-
385
- /**
386
- * Module exports.
387
- * @type {Function}
388
- */
389
- module.exports = FileSystem;
390
- exports = module.exports;
391
- exports.getPathParts = getPathParts;
392
- exports.getRealPath = getRealPath;
@@ -1,219 +0,0 @@
1
- 'use strict';
2
-
3
- const Binding = require('./binding.js');
4
- const {FSError} = require('./error.js');
5
- const FileSystem = require('./filesystem.js');
6
- const realBinding = process.binding('fs');
7
- const path = require('path');
8
- const loader = require('./loader.js');
9
- const bypass = require('./bypass.js');
10
- const {
11
- getReadFileContextPrototype,
12
- patchReadFileContext,
13
- } = require('./readfilecontext.js');
14
- const fs = require('fs');
15
-
16
- const realProcessProps = {
17
- cwd: process.cwd,
18
- chdir: process.chdir,
19
- };
20
- const realCreateWriteStream = fs.createWriteStream;
21
- const realStats = realBinding.Stats;
22
- const realStatWatcher = realBinding.StatWatcher;
23
-
24
- /**
25
- * Pre-patch fs binding.
26
- * This allows mock-fs to work properly under nodejs v10+ readFile
27
- * As ReadFileContext nodejs v10+ implementation traps original binding methods:
28
- * const { FSReqWrap, close, read } = process.binding('fs');
29
- * Note this patch only solves issue for readFile, as the require of
30
- * ReadFileContext is delayed by readFile implementation.
31
- * if (!ReadFileContext) ReadFileContext = require('internal/fs/read_file_context')
32
- *
33
- * @param {string} key Property name.
34
- */
35
- function patch(key) {
36
- const existingMethod = realBinding[key];
37
- realBinding[key] = function () {
38
- if (this._mockedBinding) {
39
- return this._mockedBinding[key].apply(this._mockedBinding, arguments);
40
- } else {
41
- return existingMethod.apply(this, arguments);
42
- }
43
- }.bind(realBinding);
44
- }
45
-
46
- for (const key in Binding.prototype) {
47
- if (typeof realBinding[key] === 'function') {
48
- // Stats and StatWatcher are constructors
49
- if (key !== 'Stats' && key !== 'StatWatcher') {
50
- patch(key);
51
- }
52
- }
53
- }
54
-
55
- const readFileContextPrototype = getReadFileContextPrototype();
56
-
57
- patchReadFileContext(readFileContextPrototype);
58
-
59
- function overrideBinding(binding) {
60
- realBinding._mockedBinding = binding;
61
- }
62
-
63
- function overrideProcess(cwd, chdir) {
64
- process.cwd = cwd;
65
- process.chdir = chdir;
66
- }
67
-
68
- /**
69
- * Have to disable write stream _writev on nodejs v10+.
70
- *
71
- * nodejs v8 lib/fs.js
72
- * note binding.writeBuffers will use mock-fs patched writeBuffers.
73
- *
74
- * const binding = process.binding('fs');
75
- * function writev(fd, chunks, position, callback) {
76
- * // ...
77
- * binding.writeBuffers(fd, chunks, position, req);
78
- * }
79
- *
80
- * nodejs v10+ lib/internal/fs/streams.js
81
- * note it uses original writeBuffers, bypassed mock-fs patched writeBuffers.
82
- *
83
- * const {writeBuffers} = internalBinding('fs');
84
- * function writev(fd, chunks, position, callback) {
85
- * // ...
86
- * writeBuffers(fd, chunks, position, req);
87
- * }
88
- *
89
- * Luckily _writev is an optional method on Writeable stream implementation.
90
- * When _writev is missing, it will fall back to make multiple _write calls.
91
- */
92
- function overrideCreateWriteStream() {
93
- fs.createWriteStream = function (path, options) {
94
- const output = realCreateWriteStream(path, options);
95
- // disable _writev, this will over shadow WriteStream.prototype._writev
96
- if (realBinding._mockedBinding) {
97
- output._writev = undefined;
98
- }
99
- return output;
100
- };
101
- }
102
-
103
- function overrideReadFileContext(binding) {
104
- readFileContextPrototype._mockedBinding = binding;
105
- }
106
-
107
- function restoreBinding() {
108
- delete realBinding._mockedBinding;
109
- realBinding.Stats = realStats;
110
- realBinding.StatWatcher = realStatWatcher;
111
- }
112
-
113
- function restoreProcess() {
114
- for (const key in realProcessProps) {
115
- process[key] = realProcessProps[key];
116
- }
117
- }
118
-
119
- function restoreCreateWriteStream() {
120
- fs.createWriteStream = realCreateWriteStream;
121
- }
122
-
123
- function restoreReadFileContext(binding) {
124
- delete readFileContextPrototype._mockedBinding;
125
- }
126
-
127
- /**
128
- * Swap out the fs bindings for a mock file system.
129
- * @param {object} config Mock file system configuration.
130
- * @param {object} [options={}] Any filesystem options.
131
- * @param {boolean} options.createCwd Create a directory for `process.cwd()`
132
- * (defaults to `true`).
133
- * @param {boolean} options.createTmp Create a directory for `os.tmpdir()`
134
- * (defaults to `true`).
135
- */
136
- module.exports = function mock(config, options = {}) {
137
- const system = FileSystem.create(config, options);
138
- const binding = new Binding(system);
139
-
140
- overrideBinding(binding);
141
-
142
- overrideReadFileContext(binding);
143
-
144
- let currentPath = process.cwd();
145
- overrideProcess(
146
- function cwd() {
147
- if (realBinding._mockedBinding) {
148
- return currentPath;
149
- }
150
- return realProcessProps.cwd();
151
- },
152
- function chdir(directory) {
153
- if (realBinding._mockedBinding) {
154
- if (!fs.statSync(path.toNamespacedPath(directory)).isDirectory()) {
155
- throw new FSError('ENOTDIR');
156
- }
157
- currentPath = path.resolve(currentPath, directory);
158
- } else {
159
- return realProcessProps.chdir(directory);
160
- }
161
- }
162
- );
163
-
164
- overrideCreateWriteStream();
165
- };
166
-
167
- exports = module.exports;
168
-
169
- /**
170
- * Get hold of the mocked filesystem's 'root'
171
- * If fs hasn't currently been replaced, this will return an empty object
172
- * @return {object} The mock root.
173
- */
174
- exports.getMockRoot = function () {
175
- if (realBinding._mockedBinding) {
176
- return realBinding._mockedBinding.getSystem().getRoot();
177
- } else {
178
- return {};
179
- }
180
- };
181
-
182
- /**
183
- * Restore the fs bindings for the real file system.
184
- */
185
- exports.restore = function () {
186
- restoreBinding();
187
- restoreProcess();
188
- restoreCreateWriteStream();
189
- restoreReadFileContext();
190
- };
191
-
192
- /**
193
- * Create a file factory.
194
- */
195
- exports.file = FileSystem.file;
196
-
197
- /**
198
- * Create a directory factory.
199
- */
200
- exports.directory = FileSystem.directory;
201
-
202
- /**
203
- * Create a symbolic link factory.
204
- */
205
- exports.symlink = FileSystem.symlink;
206
-
207
- /**
208
- * Automatically maps specified paths (for use with `mock()`)
209
- */
210
- exports.load = loader.load;
211
-
212
- /**
213
- * Perform action, bypassing mock FS
214
- * @example
215
- * // This file exists on the real FS, not on the mocked FS
216
- * const filePath = '/path/file.json';
217
- * const data = mock.bypass(() => fs.readFileSync(filePath, 'utf-8'));
218
- */
219
- exports.bypass = bypass;