@cdk8s/projen-common 0.0.237 → 0.0.239
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/.jsii +166 -70
- package/.projenrc.ts +17 -0
- package/API.md +6745 -54
- package/git-hooks/prepare-commit-msg +0 -0
- package/git-hooks/setup.sh +0 -0
- package/lib/index.d.ts +1 -37
- package/lib/index.js +12 -86
- package/lib/projects/index.d.ts +2 -0
- package/lib/projects/index.js +7 -0
- package/lib/projects/jsii.d.ts +48 -0
- package/lib/projects/jsii.js +71 -0
- package/lib/projects/typescript.d.ts +34 -0
- package/lib/projects/typescript.js +89 -0
- package/node_modules/codemaker/LICENSE +202 -0
- package/node_modules/codemaker/NOTICE +2 -0
- package/node_modules/codemaker/README.md +120 -0
- package/node_modules/codemaker/jest.config.mjs +3 -0
- package/node_modules/codemaker/lib/case-utils.d.ts +4 -0
- package/node_modules/codemaker/lib/case-utils.js +29 -0
- package/node_modules/codemaker/lib/codemaker.d.ts +107 -0
- package/node_modules/codemaker/lib/codemaker.js +164 -0
- package/node_modules/codemaker/lib/filebuff.d.ts +11 -0
- package/node_modules/codemaker/lib/filebuff.js +26 -0
- package/node_modules/codemaker/lib/index.d.ts +3 -0
- package/node_modules/codemaker/lib/index.js +19 -0
- package/node_modules/codemaker/node_modules/camelcase/index.d.ts +103 -0
- package/node_modules/codemaker/node_modules/camelcase/index.js +113 -0
- package/node_modules/codemaker/node_modules/camelcase/license +9 -0
- package/node_modules/codemaker/node_modules/camelcase/package.json +44 -0
- package/node_modules/codemaker/node_modules/camelcase/readme.md +144 -0
- package/node_modules/codemaker/package.json +41 -0
- package/node_modules/decamelize/index.d.ts +59 -0
- package/node_modules/decamelize/index.js +65 -0
- package/node_modules/decamelize/license +9 -0
- package/node_modules/decamelize/package.json +40 -0
- package/node_modules/decamelize/readme.md +92 -0
- package/node_modules/fs-extra/LICENSE +15 -0
- package/node_modules/fs-extra/README.md +262 -0
- package/node_modules/fs-extra/lib/copy/copy-sync.js +169 -0
- package/node_modules/fs-extra/lib/copy/copy.js +235 -0
- package/node_modules/fs-extra/lib/copy/index.js +7 -0
- package/node_modules/fs-extra/lib/empty/index.js +39 -0
- package/node_modules/fs-extra/lib/ensure/file.js +69 -0
- package/node_modules/fs-extra/lib/ensure/index.js +23 -0
- package/node_modules/fs-extra/lib/ensure/link.js +64 -0
- package/node_modules/fs-extra/lib/ensure/symlink-paths.js +99 -0
- package/node_modules/fs-extra/lib/ensure/symlink-type.js +31 -0
- package/node_modules/fs-extra/lib/ensure/symlink.js +82 -0
- package/node_modules/fs-extra/lib/fs/index.js +128 -0
- package/node_modules/fs-extra/lib/index.js +16 -0
- package/node_modules/fs-extra/lib/json/index.js +16 -0
- package/node_modules/fs-extra/lib/json/jsonfile.js +11 -0
- package/node_modules/fs-extra/lib/json/output-json-sync.js +12 -0
- package/node_modules/fs-extra/lib/json/output-json.js +12 -0
- package/node_modules/fs-extra/lib/mkdirs/index.js +14 -0
- package/node_modules/fs-extra/lib/mkdirs/make-dir.js +27 -0
- package/node_modules/fs-extra/lib/mkdirs/utils.js +21 -0
- package/node_modules/fs-extra/lib/move/index.js +7 -0
- package/node_modules/fs-extra/lib/move/move-sync.js +54 -0
- package/node_modules/fs-extra/lib/move/move.js +75 -0
- package/node_modules/fs-extra/lib/output-file/index.js +40 -0
- package/node_modules/fs-extra/lib/path-exists/index.js +12 -0
- package/node_modules/fs-extra/lib/remove/index.js +22 -0
- package/node_modules/fs-extra/lib/remove/rimraf.js +302 -0
- package/node_modules/fs-extra/lib/util/stat.js +154 -0
- package/node_modules/fs-extra/lib/util/utimes.js +26 -0
- package/node_modules/fs-extra/package.json +67 -0
- package/node_modules/graceful-fs/LICENSE +15 -0
- package/node_modules/graceful-fs/README.md +143 -0
- package/node_modules/graceful-fs/clone.js +23 -0
- package/node_modules/graceful-fs/graceful-fs.js +448 -0
- package/node_modules/graceful-fs/legacy-streams.js +118 -0
- package/node_modules/graceful-fs/package.json +50 -0
- package/node_modules/graceful-fs/polyfills.js +355 -0
- package/node_modules/jsonfile/CHANGELOG.md +171 -0
- package/node_modules/jsonfile/LICENSE +15 -0
- package/node_modules/jsonfile/README.md +230 -0
- package/node_modules/jsonfile/index.js +88 -0
- package/node_modules/jsonfile/package.json +40 -0
- package/node_modules/jsonfile/utils.js +14 -0
- package/node_modules/universalify/LICENSE +20 -0
- package/node_modules/universalify/README.md +76 -0
- package/node_modules/universalify/index.js +24 -0
- package/node_modules/universalify/package.json +34 -0
- package/package.json +17 -9
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# codemaker
|
|
2
|
+
|
|
3
|
+
Makes code. Well.. just a simple text writer with support for:
|
|
4
|
+
|
|
5
|
+
1. Blocks (indentation/open/close)
|
|
6
|
+
2. Supports multiple files (with subdirectories)
|
|
7
|
+
3. Exclusion of files
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
import { CodeMaker } from 'codemaker'
|
|
11
|
+
|
|
12
|
+
let maker = new CodeMaker();
|
|
13
|
+
maker.openFile('myfile.js');
|
|
14
|
+
maker.line('first line');
|
|
15
|
+
maker.openBlock('open');
|
|
16
|
+
maker.line('second line');
|
|
17
|
+
maker.closeBlock();
|
|
18
|
+
maker.indent('generic open [');
|
|
19
|
+
maker.line('boom');
|
|
20
|
+
maker.line('bam');
|
|
21
|
+
maker.unindent(']');
|
|
22
|
+
maker.closeFile('myfile.js');
|
|
23
|
+
|
|
24
|
+
let yourfileRelativePath = './relative/subdirs/are/also/supported/yourfile.js';
|
|
25
|
+
maker.openFile(yourfileRelativePath);
|
|
26
|
+
maker.line('this is your file speaking');
|
|
27
|
+
|
|
28
|
+
// change indentation and block formatting
|
|
29
|
+
maker.indentation = 10;
|
|
30
|
+
maker.openBlockFormatter = s => `(--- ${s} ---`;
|
|
31
|
+
maker.closeBlockFormatter = s => `--- ${s} ---)`;
|
|
32
|
+
|
|
33
|
+
maker.openBlock('block1');
|
|
34
|
+
maker.line('block1.line1');
|
|
35
|
+
maker.line('block1.line2');
|
|
36
|
+
maker.openBlock('block2');
|
|
37
|
+
maker.line('block2.line1');
|
|
38
|
+
maker.closeBlock('block2 (close)');
|
|
39
|
+
maker.line('block1.line3');
|
|
40
|
+
maker.closeBlock('block1 (close)');
|
|
41
|
+
|
|
42
|
+
// closeFile will ensure that you are closing the same file.
|
|
43
|
+
maker.closeFile(yourfileRelativePath);
|
|
44
|
+
|
|
45
|
+
// files can also be excluded by adding their path to exclude()
|
|
46
|
+
maker.openFile('rel/excluded.txt');
|
|
47
|
+
maker.line('this file will not be emitted in save()');
|
|
48
|
+
maker.closeFile('rel/excluded.txt');
|
|
49
|
+
|
|
50
|
+
// later in the day
|
|
51
|
+
maker.exclude('rel/excluded.txt');
|
|
52
|
+
|
|
53
|
+
// this is javascript - you can customize openBlock to whatever
|
|
54
|
+
maker.openBlock = function(s) {
|
|
55
|
+
this.line(s);
|
|
56
|
+
this.open('{');
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
maker.openFile('custom-blocks.cpp');
|
|
60
|
+
maker.openBlock('Block1()');
|
|
61
|
+
maker.line('L1');
|
|
62
|
+
maker.openBlock('Block2()');
|
|
63
|
+
maker.line('L2');
|
|
64
|
+
maker.closeBlock();
|
|
65
|
+
maker.closeBlock();
|
|
66
|
+
maker.closeFile('custom-blocks.cpp');
|
|
67
|
+
|
|
68
|
+
// returns a sorted list of output files
|
|
69
|
+
let files = await maker.save('/tmp/source-files');
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
* /tmp/source-files/myfile.js:
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
first line
|
|
76
|
+
open {
|
|
77
|
+
second line
|
|
78
|
+
}
|
|
79
|
+
generic open [
|
|
80
|
+
boom
|
|
81
|
+
bam
|
|
82
|
+
]
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
* /tmp/source-files/relative/subdirs/are/also/supported/yourfile.js:
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
this is your file speaking
|
|
89
|
+
(--- block1 ---
|
|
90
|
+
block1.line1
|
|
91
|
+
block1.line2
|
|
92
|
+
(--- block2 ---
|
|
93
|
+
block2.line1
|
|
94
|
+
--- block2 (close) ---)
|
|
95
|
+
block1.line3
|
|
96
|
+
--- block1 (close) ---)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
* /tmp/source-files/custom-blocks.cpp:
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
Block1()
|
|
103
|
+
{
|
|
104
|
+
L1
|
|
105
|
+
Block2()
|
|
106
|
+
{
|
|
107
|
+
L2
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Neat.
|
|
113
|
+
|
|
114
|
+
Also bundles a couple of case utils from **sindresorhus**:
|
|
115
|
+
|
|
116
|
+
```js
|
|
117
|
+
maker.toCamelCase(s, ...)
|
|
118
|
+
maker.toPascalCase(s, ...)
|
|
119
|
+
maker.toSnakCase(s, sep = '_')
|
|
120
|
+
```
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toSnakeCase = exports.toPascalCase = exports.toCamelCase = void 0;
|
|
4
|
+
const camelcase = require("camelcase");
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
6
|
+
const decamelize = require("decamelize");
|
|
7
|
+
const COMMON_ABBREVIATIONS = ['KiB', 'MiB', 'GiB'];
|
|
8
|
+
function toCamelCase(...args) {
|
|
9
|
+
return camelcase(args);
|
|
10
|
+
}
|
|
11
|
+
exports.toCamelCase = toCamelCase;
|
|
12
|
+
function toPascalCase(...args) {
|
|
13
|
+
return camelcase(args, { pascalCase: true });
|
|
14
|
+
}
|
|
15
|
+
exports.toPascalCase = toPascalCase;
|
|
16
|
+
const ABBREV_RE = new RegExp(`(^|[^A-Z])(${COMMON_ABBREVIATIONS.map(regexQuote).join('|')})($|[^a-z])`, 'g');
|
|
17
|
+
function toSnakeCase(s, separator = '_') {
|
|
18
|
+
// Save common abbrevations
|
|
19
|
+
s = s.replace(ABBREV_RE, (_, before, abbr, after) => before + ucfirst(abbr.toLowerCase()) + after);
|
|
20
|
+
return decamelize(s, { separator });
|
|
21
|
+
function ucfirst(str) {
|
|
22
|
+
return str.slice(0, 1).toUpperCase() + str.slice(1).toLowerCase();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.toSnakeCase = toSnakeCase;
|
|
26
|
+
function regexQuote(s) {
|
|
27
|
+
return s.replace(/[.?*+^$[\]\\(){}|-]/g, '\\$&');
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=case-utils.js.map
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-file text writer with some code-generation features.
|
|
3
|
+
*/
|
|
4
|
+
export declare class CodeMaker {
|
|
5
|
+
/**
|
|
6
|
+
* The indentation level of the file.
|
|
7
|
+
*/
|
|
8
|
+
indentation: number;
|
|
9
|
+
/**
|
|
10
|
+
* The character to use for indentation. When setting this to `\t`, consider
|
|
11
|
+
* also setting `indentation` to `1`.
|
|
12
|
+
*/
|
|
13
|
+
indentCharacter: ' ' | '\t';
|
|
14
|
+
private currIndent;
|
|
15
|
+
private currentFile?;
|
|
16
|
+
private readonly files;
|
|
17
|
+
private readonly excludes;
|
|
18
|
+
constructor({ indentationLevel, indentCharacter, }?: {
|
|
19
|
+
indentationLevel?: CodeMaker['indentation'];
|
|
20
|
+
indentCharacter?: CodeMaker['indentCharacter'];
|
|
21
|
+
});
|
|
22
|
+
get currentIndentLength(): number;
|
|
23
|
+
/**
|
|
24
|
+
* Formats an block open statement.
|
|
25
|
+
*/
|
|
26
|
+
openBlockFormatter: (s?: string) => string;
|
|
27
|
+
/**
|
|
28
|
+
* Formats a block close statement.
|
|
29
|
+
*/
|
|
30
|
+
closeBlockFormatter: (s?: string) => string | false;
|
|
31
|
+
/**
|
|
32
|
+
* Saves all the files created in this code maker.
|
|
33
|
+
* @param rootDir The root directory for all saved files.
|
|
34
|
+
* @returns A sorted list of all the files saved (absolute paths).
|
|
35
|
+
*/
|
|
36
|
+
save(rootDir: string): Promise<string[]>;
|
|
37
|
+
/**
|
|
38
|
+
* Sets the name of the current file we are working with.
|
|
39
|
+
* Note that this doesn't really create a new file (files are only created when save() is called.
|
|
40
|
+
* Use `closeFile` to close this file.
|
|
41
|
+
* @param filePath The relative path of the new file.
|
|
42
|
+
*/
|
|
43
|
+
openFile(filePath: string): void;
|
|
44
|
+
/**
|
|
45
|
+
* Indicates that we finished generating the current file.
|
|
46
|
+
* @param filePath The relative file path (must be the same as one passed to openFile)
|
|
47
|
+
*/
|
|
48
|
+
closeFile(filePath: string): void;
|
|
49
|
+
/**
|
|
50
|
+
* Emits a line into the currently opened file.
|
|
51
|
+
* Line is emitted with the current level of indentation.
|
|
52
|
+
* If no arguments are provided, an empty new line is emitted.
|
|
53
|
+
* @param fmt String format arguments (passed to `util.format`)
|
|
54
|
+
* @param args String arguments
|
|
55
|
+
*/
|
|
56
|
+
line(fmt?: string, ...args: string[]): void;
|
|
57
|
+
/**
|
|
58
|
+
* Same as `open`.
|
|
59
|
+
*/
|
|
60
|
+
indent(textBefore?: string): void;
|
|
61
|
+
/**
|
|
62
|
+
* Same as `close`.
|
|
63
|
+
*/
|
|
64
|
+
unindent(textAfter?: string | false): void;
|
|
65
|
+
/**
|
|
66
|
+
* Increases the indentation level by `indentation` spaces for the next line.
|
|
67
|
+
* @param textBefore Text to emit before the newline (i.e. block open).
|
|
68
|
+
*/
|
|
69
|
+
open(textBefore?: string): void;
|
|
70
|
+
/**
|
|
71
|
+
* Decreases the indentation level by `indentation` for the next line.
|
|
72
|
+
* @param textAfter Text to emit in the line after indentation was decreased.
|
|
73
|
+
* If `false` no line will be emitted at all, but the indent
|
|
74
|
+
* counter will be decremented.
|
|
75
|
+
*/
|
|
76
|
+
close(textAfter?: string | false): void;
|
|
77
|
+
/**
|
|
78
|
+
* Opens a code block. The formatting of the block is determined by `openBlockFormatter`.
|
|
79
|
+
* @param text The text to pass to the formatter.
|
|
80
|
+
*/
|
|
81
|
+
openBlock(text: string): void;
|
|
82
|
+
/**
|
|
83
|
+
* Closes a code block. The formatting of the block is determined by `closeBlockFormatter`.
|
|
84
|
+
* @param text The text to pass to the formatter.
|
|
85
|
+
*/
|
|
86
|
+
closeBlock(text?: string): void;
|
|
87
|
+
/**
|
|
88
|
+
* Adds a file to the exclude list. This means this file will not be saved during save().
|
|
89
|
+
* @param filePath The relative path of the file.
|
|
90
|
+
*/
|
|
91
|
+
exclude(filePath: string): void;
|
|
92
|
+
/**
|
|
93
|
+
* convertsStringToCamelCase
|
|
94
|
+
*/
|
|
95
|
+
toCamelCase(...args: string[]): string;
|
|
96
|
+
/**
|
|
97
|
+
* ConvertsStringToPascalCase
|
|
98
|
+
*/
|
|
99
|
+
toPascalCase(...args: string[]): string;
|
|
100
|
+
/**
|
|
101
|
+
* convert_string_to_snake_case
|
|
102
|
+
* @param sep Separator (defaults to '_')
|
|
103
|
+
*/
|
|
104
|
+
toSnakeCase(s: string, sep?: string): string;
|
|
105
|
+
private makeIndent;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=codemaker.d.ts.map
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CodeMaker = void 0;
|
|
4
|
+
const util = require("util");
|
|
5
|
+
const caseutils = require("./case-utils");
|
|
6
|
+
const filebuff_1 = require("./filebuff");
|
|
7
|
+
/**
|
|
8
|
+
* Multi-file text writer with some code-generation features.
|
|
9
|
+
*/
|
|
10
|
+
class CodeMaker {
|
|
11
|
+
constructor({ indentationLevel = 4, indentCharacter = ' ', } = {}) {
|
|
12
|
+
this.currIndent = 0;
|
|
13
|
+
this.files = new Array();
|
|
14
|
+
this.excludes = new Array();
|
|
15
|
+
/**
|
|
16
|
+
* Formats an block open statement.
|
|
17
|
+
*/
|
|
18
|
+
this.openBlockFormatter = (s) => `${s} {`;
|
|
19
|
+
/**
|
|
20
|
+
* Formats a block close statement.
|
|
21
|
+
*/
|
|
22
|
+
this.closeBlockFormatter = () => '}';
|
|
23
|
+
this.indentation = indentationLevel;
|
|
24
|
+
this.indentCharacter = indentCharacter;
|
|
25
|
+
}
|
|
26
|
+
get currentIndentLength() {
|
|
27
|
+
return this.currIndent * this.indentation;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Saves all the files created in this code maker.
|
|
31
|
+
* @param rootDir The root directory for all saved files.
|
|
32
|
+
* @returns A sorted list of all the files saved (absolute paths).
|
|
33
|
+
*/
|
|
34
|
+
async save(rootDir) {
|
|
35
|
+
const paths = this.files
|
|
36
|
+
.filter((file) => !this.excludes.includes(file.filePath))
|
|
37
|
+
.map((file) => file.save(rootDir));
|
|
38
|
+
return (await Promise.all(paths)).sort();
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Sets the name of the current file we are working with.
|
|
42
|
+
* Note that this doesn't really create a new file (files are only created when save() is called.
|
|
43
|
+
* Use `closeFile` to close this file.
|
|
44
|
+
* @param filePath The relative path of the new file.
|
|
45
|
+
*/
|
|
46
|
+
openFile(filePath) {
|
|
47
|
+
if (this.currentFile) {
|
|
48
|
+
throw new Error(`Cannot open file ${filePath} without closing the previous file ${this.currentFile.filePath}`);
|
|
49
|
+
}
|
|
50
|
+
this.currentFile = new filebuff_1.default(filePath);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Indicates that we finished generating the current file.
|
|
54
|
+
* @param filePath The relative file path (must be the same as one passed to openFile)
|
|
55
|
+
*/
|
|
56
|
+
closeFile(filePath) {
|
|
57
|
+
if (!this.currentFile) {
|
|
58
|
+
throw new Error(`Cannot close file ${filePath}. It was never opened`);
|
|
59
|
+
}
|
|
60
|
+
if (this.currentFile.filePath !== filePath) {
|
|
61
|
+
throw new Error(`Cannot close file ${filePath}. The currently opened file is ${this.currentFile.filePath}`);
|
|
62
|
+
}
|
|
63
|
+
this.files.push(this.currentFile);
|
|
64
|
+
this.currentFile = undefined;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Emits a line into the currently opened file.
|
|
68
|
+
* Line is emitted with the current level of indentation.
|
|
69
|
+
* If no arguments are provided, an empty new line is emitted.
|
|
70
|
+
* @param fmt String format arguments (passed to `util.format`)
|
|
71
|
+
* @param args String arguments
|
|
72
|
+
*/
|
|
73
|
+
line(fmt, ...args) {
|
|
74
|
+
if (!this.currentFile) {
|
|
75
|
+
throw new Error('Cannot emit source lines without opening a file');
|
|
76
|
+
}
|
|
77
|
+
if (fmt) {
|
|
78
|
+
fmt = this.makeIndent() + fmt;
|
|
79
|
+
this.currentFile.write(util.format(fmt, ...args));
|
|
80
|
+
}
|
|
81
|
+
this.currentFile.write('\n');
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Same as `open`.
|
|
85
|
+
*/
|
|
86
|
+
indent(textBefore) {
|
|
87
|
+
this.open(textBefore);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Same as `close`.
|
|
91
|
+
*/
|
|
92
|
+
unindent(textAfter) {
|
|
93
|
+
this.close(textAfter);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Increases the indentation level by `indentation` spaces for the next line.
|
|
97
|
+
* @param textBefore Text to emit before the newline (i.e. block open).
|
|
98
|
+
*/
|
|
99
|
+
open(textBefore) {
|
|
100
|
+
this.line(textBefore);
|
|
101
|
+
this.currIndent++;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Decreases the indentation level by `indentation` for the next line.
|
|
105
|
+
* @param textAfter Text to emit in the line after indentation was decreased.
|
|
106
|
+
* If `false` no line will be emitted at all, but the indent
|
|
107
|
+
* counter will be decremented.
|
|
108
|
+
*/
|
|
109
|
+
close(textAfter) {
|
|
110
|
+
this.currIndent--;
|
|
111
|
+
if (textAfter !== false) {
|
|
112
|
+
this.line(textAfter);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Opens a code block. The formatting of the block is determined by `openBlockFormatter`.
|
|
117
|
+
* @param text The text to pass to the formatter.
|
|
118
|
+
*/
|
|
119
|
+
openBlock(text) {
|
|
120
|
+
this.open(this.openBlockFormatter(text));
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Closes a code block. The formatting of the block is determined by `closeBlockFormatter`.
|
|
124
|
+
* @param text The text to pass to the formatter.
|
|
125
|
+
*/
|
|
126
|
+
closeBlock(text) {
|
|
127
|
+
this.close(this.closeBlockFormatter(text));
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Adds a file to the exclude list. This means this file will not be saved during save().
|
|
131
|
+
* @param filePath The relative path of the file.
|
|
132
|
+
*/
|
|
133
|
+
exclude(filePath) {
|
|
134
|
+
this.excludes.push(filePath);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* convertsStringToCamelCase
|
|
138
|
+
*/
|
|
139
|
+
toCamelCase(...args) {
|
|
140
|
+
return caseutils.toCamelCase(...args);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* ConvertsStringToPascalCase
|
|
144
|
+
*/
|
|
145
|
+
toPascalCase(...args) {
|
|
146
|
+
return caseutils.toPascalCase(...args);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* convert_string_to_snake_case
|
|
150
|
+
* @param sep Separator (defaults to '_')
|
|
151
|
+
*/
|
|
152
|
+
toSnakeCase(s, sep = '_') {
|
|
153
|
+
return caseutils.toSnakeCase(s, sep);
|
|
154
|
+
}
|
|
155
|
+
makeIndent() {
|
|
156
|
+
const length = this.currentIndentLength;
|
|
157
|
+
if (length <= 0) {
|
|
158
|
+
return '';
|
|
159
|
+
}
|
|
160
|
+
return this.indentCharacter.repeat(length);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
exports.CodeMaker = CodeMaker;
|
|
164
|
+
//# sourceMappingURL=codemaker.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Buffers the text of a file for later saving.
|
|
3
|
+
*/
|
|
4
|
+
export default class FileBuffer {
|
|
5
|
+
readonly filePath: string;
|
|
6
|
+
private buffer;
|
|
7
|
+
constructor(filePath: string);
|
|
8
|
+
write(s: string): void;
|
|
9
|
+
save(rootDir: string): Promise<string>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=filebuff.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const path = require("path");
|
|
4
|
+
/**
|
|
5
|
+
* Buffers the text of a file for later saving.
|
|
6
|
+
*/
|
|
7
|
+
class FileBuffer {
|
|
8
|
+
constructor(filePath) {
|
|
9
|
+
this.buffer = '';
|
|
10
|
+
this.filePath = filePath;
|
|
11
|
+
}
|
|
12
|
+
write(s) {
|
|
13
|
+
this.buffer += s;
|
|
14
|
+
}
|
|
15
|
+
async save(rootDir) {
|
|
16
|
+
// just-in-time require so that this file can be loaded in browsers as well.
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports,@typescript-eslint/no-var-requires
|
|
18
|
+
const fs = require('fs-extra');
|
|
19
|
+
const fullPath = path.join(rootDir, this.filePath);
|
|
20
|
+
await fs.mkdirs(path.dirname(fullPath));
|
|
21
|
+
await fs.writeFile(fullPath, this.buffer);
|
|
22
|
+
return fullPath;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.default = FileBuffer;
|
|
26
|
+
//# sourceMappingURL=filebuff.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./codemaker"), exports);
|
|
18
|
+
__exportStar(require("./case-utils"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
declare namespace camelcase {
|
|
2
|
+
interface Options {
|
|
3
|
+
/**
|
|
4
|
+
Uppercase the first character: `foo-bar` → `FooBar`.
|
|
5
|
+
|
|
6
|
+
@default false
|
|
7
|
+
*/
|
|
8
|
+
readonly pascalCase?: boolean;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
Preserve the consecutive uppercase characters: `foo-BAR` → `FooBAR`.
|
|
12
|
+
|
|
13
|
+
@default false
|
|
14
|
+
*/
|
|
15
|
+
readonly preserveConsecutiveUppercase?: boolean;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
The locale parameter indicates the locale to be used to convert to upper/lower case according to any locale-specific case mappings. If multiple locales are given in an array, the best available locale is used.
|
|
19
|
+
|
|
20
|
+
Setting `locale: false` ignores the platform locale and uses the [Unicode Default Case Conversion](https://unicode-org.github.io/icu/userguide/transforms/casemappings.html#simple-single-character-case-mapping) algorithm.
|
|
21
|
+
|
|
22
|
+
Default: The host environment’s current locale.
|
|
23
|
+
|
|
24
|
+
@example
|
|
25
|
+
```
|
|
26
|
+
import camelCase = require('camelcase');
|
|
27
|
+
|
|
28
|
+
camelCase('lorem-ipsum', {locale: 'en-US'});
|
|
29
|
+
//=> 'loremIpsum'
|
|
30
|
+
camelCase('lorem-ipsum', {locale: 'tr-TR'});
|
|
31
|
+
//=> 'loremİpsum'
|
|
32
|
+
camelCase('lorem-ipsum', {locale: ['en-US', 'en-GB']});
|
|
33
|
+
//=> 'loremIpsum'
|
|
34
|
+
camelCase('lorem-ipsum', {locale: ['tr', 'TR', 'tr-TR']});
|
|
35
|
+
//=> 'loremİpsum'
|
|
36
|
+
```
|
|
37
|
+
*/
|
|
38
|
+
readonly locale?: false | string | readonly string[];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
Convert a dash/dot/underscore/space separated string to camelCase or PascalCase: `foo-bar` → `fooBar`.
|
|
44
|
+
|
|
45
|
+
Correctly handles Unicode strings.
|
|
46
|
+
|
|
47
|
+
@param input - String to convert to camel case.
|
|
48
|
+
|
|
49
|
+
@example
|
|
50
|
+
```
|
|
51
|
+
import camelCase = require('camelcase');
|
|
52
|
+
|
|
53
|
+
camelCase('foo-bar');
|
|
54
|
+
//=> 'fooBar'
|
|
55
|
+
|
|
56
|
+
camelCase('foo_bar');
|
|
57
|
+
//=> 'fooBar'
|
|
58
|
+
|
|
59
|
+
camelCase('Foo-Bar');
|
|
60
|
+
//=> 'fooBar'
|
|
61
|
+
|
|
62
|
+
camelCase('розовый_пушистый_единорог');
|
|
63
|
+
//=> 'розовыйПушистыйЕдинорог'
|
|
64
|
+
|
|
65
|
+
camelCase('Foo-Bar', {pascalCase: true});
|
|
66
|
+
//=> 'FooBar'
|
|
67
|
+
|
|
68
|
+
camelCase('--foo.bar', {pascalCase: false});
|
|
69
|
+
//=> 'fooBar'
|
|
70
|
+
|
|
71
|
+
camelCase('Foo-BAR', {preserveConsecutiveUppercase: true});
|
|
72
|
+
//=> 'fooBAR'
|
|
73
|
+
|
|
74
|
+
camelCase('fooBAR', {pascalCase: true, preserveConsecutiveUppercase: true}));
|
|
75
|
+
//=> 'FooBAR'
|
|
76
|
+
|
|
77
|
+
camelCase('foo bar');
|
|
78
|
+
//=> 'fooBar'
|
|
79
|
+
|
|
80
|
+
console.log(process.argv[3]);
|
|
81
|
+
//=> '--foo-bar'
|
|
82
|
+
camelCase(process.argv[3]);
|
|
83
|
+
//=> 'fooBar'
|
|
84
|
+
|
|
85
|
+
camelCase(['foo', 'bar']);
|
|
86
|
+
//=> 'fooBar'
|
|
87
|
+
|
|
88
|
+
camelCase(['__foo__', '--bar'], {pascalCase: true});
|
|
89
|
+
//=> 'FooBar'
|
|
90
|
+
|
|
91
|
+
camelCase(['foo', 'BAR'], {pascalCase: true, preserveConsecutiveUppercase: true})
|
|
92
|
+
//=> 'FooBAR'
|
|
93
|
+
|
|
94
|
+
camelCase('lorem-ipsum', {locale: 'en-US'});
|
|
95
|
+
//=> 'loremIpsum'
|
|
96
|
+
```
|
|
97
|
+
*/
|
|
98
|
+
declare function camelcase(
|
|
99
|
+
input: string | readonly string[],
|
|
100
|
+
options?: camelcase.Options
|
|
101
|
+
): string;
|
|
102
|
+
|
|
103
|
+
export = camelcase;
|