@nathapp/na-cli 1.0.0-rc.4 → 1.0.0-rc.6
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/README.md +5 -1
- package/dist/index.js +12 -4
- package/dist/index.js.map +1 -1
- package/dist/templates/ts-library/.eslintrc.js +24 -0
- package/dist/templates/ts-library/LICENSE +21 -0
- package/dist/templates/ts-library/Makefile +66 -0
- package/dist/templates/ts-library/README.md +1 -0
- package/dist/templates/ts-library/index.d.ts +1 -0
- package/dist/templates/ts-library/index.js +6 -0
- package/dist/templates/ts-library/package.json +36 -0
- package/dist/templates/ts-library/test/jest-e2e.json +9 -0
- package/dist/templates/ts-library/tsconfig.build.json +4 -0
- package/dist/utils/template.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +12 -4
- package/src/utils/template.ts +1 -0
- package/templates/ts-library/.eslintrc.js +24 -0
- package/templates/ts-library/LICENSE +21 -0
- package/templates/ts-library/Makefile +66 -0
- package/templates/ts-library/README.md +1 -0
- package/templates/ts-library/index.d.ts +1 -0
- package/templates/ts-library/index.js +6 -0
- package/templates/ts-library/package.json +36 -0
- package/templates/ts-library/test/jest-e2e.json +9 -0
- package/templates/ts-library/tsconfig.build.json +4 -0
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -28,6 +28,12 @@ var QUESTIONS = [
|
|
|
28
28
|
else
|
|
29
29
|
return 'Project name may only include letters, numbers, underscores and hashes.';
|
|
30
30
|
}
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'author',
|
|
34
|
+
type: 'input',
|
|
35
|
+
message: 'Author:',
|
|
36
|
+
when: function () { return !yargs.argv['author']; }
|
|
31
37
|
}
|
|
32
38
|
];
|
|
33
39
|
var CURR_DIR = process.cwd();
|
|
@@ -38,6 +44,8 @@ inquirer.prompt(QUESTIONS)
|
|
|
38
44
|
var projectChoice = answers['template'];
|
|
39
45
|
// @ts-ignore
|
|
40
46
|
var projectName = answers['name'];
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
var author = answers['author'];
|
|
41
49
|
var templatePath = path.join(__dirname, 'templates', projectChoice);
|
|
42
50
|
var tartgetPath = path.join(CURR_DIR, projectName);
|
|
43
51
|
var templateConfig = getTemplateConfig(templatePath);
|
|
@@ -51,7 +59,7 @@ inquirer.prompt(QUESTIONS)
|
|
|
51
59
|
if (!createProject(tartgetPath)) {
|
|
52
60
|
return;
|
|
53
61
|
}
|
|
54
|
-
createDirectoryContents(templatePath, projectName, templateConfig);
|
|
62
|
+
createDirectoryContents(templatePath, projectName, templateConfig, author);
|
|
55
63
|
if (!postProcess(options)) {
|
|
56
64
|
return;
|
|
57
65
|
}
|
|
@@ -116,7 +124,7 @@ function postProcessNode(options) {
|
|
|
116
124
|
return true;
|
|
117
125
|
}
|
|
118
126
|
var SKIP_FILES = ['node_modules', '.template.json'];
|
|
119
|
-
function createDirectoryContents(templatePath, projectName, config) {
|
|
127
|
+
function createDirectoryContents(templatePath, projectName, config, author) {
|
|
120
128
|
var filesToCreate = fs.readdirSync(templatePath);
|
|
121
129
|
filesToCreate.forEach(function (file) {
|
|
122
130
|
var origFilePath = path.join(templatePath, file);
|
|
@@ -126,14 +134,14 @@ function createDirectoryContents(templatePath, projectName, config) {
|
|
|
126
134
|
return;
|
|
127
135
|
if (stats.isFile()) {
|
|
128
136
|
var contents = fs.readFileSync(origFilePath, 'utf8');
|
|
129
|
-
contents = template.render(contents, { projectName: projectName });
|
|
137
|
+
contents = template.render(contents, { projectName: projectName, author: author });
|
|
130
138
|
var writePath = path.join(CURR_DIR, projectName, file);
|
|
131
139
|
fs.writeFileSync(writePath, contents, 'utf8');
|
|
132
140
|
}
|
|
133
141
|
else if (stats.isDirectory()) {
|
|
134
142
|
fs.mkdirSync(path.join(CURR_DIR, projectName, file));
|
|
135
143
|
// recursive call
|
|
136
|
-
createDirectoryContents(path.join(templatePath, file), path.join(projectName, file), config);
|
|
144
|
+
createDirectoryContents(path.join(templatePath, file), path.join(projectName, file), config, author);
|
|
137
145
|
}
|
|
138
146
|
});
|
|
139
147
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAEA,mCAAqC;AACrC,uBAAyB;AACzB,2BAA6B;AAC7B,+BAAiC;AACjC,2CAA6C;AAC7C,+BAA0B;AAC1B,6BAA+B;AAE/B,IAAM,OAAO,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC;AAElE,IAAM,SAAS,GAAG;IAChB;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,mDAAmD;QAC5D,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE,cAAM,OAAA,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,EAAvB,CAAuB;KACpC;IACD;QACE,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,eAAe;QACxB,IAAI,EAAE,cAAM,OAAA,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAnB,CAAmB;QAC/B,QAAQ,EAAE,UAAC,KAAa;YACtB,IAAI,qBAAqB,CAAC,IAAI,CAAC,KAAK,CAAC;gBAAE,OAAO,IAAI,CAAC;;gBAC9C,OAAO,yEAAyE,CAAC;QACxF,CAAC;KACF;CACF,CAAC;AAEF,IAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;AAe/B,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC;KACvB,IAAI,CAAC,UAAA,OAAO;IAEX,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IACjD,aAAa;IACb,IAAM,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAC1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'module',
|
|
6
|
+
},
|
|
7
|
+
plugins: ['@typescript-eslint/eslint-plugin'],
|
|
8
|
+
extends: [
|
|
9
|
+
'plugin:@typescript-eslint/recommended',
|
|
10
|
+
'plugin:prettier/recommended',
|
|
11
|
+
],
|
|
12
|
+
root: true,
|
|
13
|
+
env: {
|
|
14
|
+
node: true,
|
|
15
|
+
jest: true,
|
|
16
|
+
},
|
|
17
|
+
ignorePatterns: ['.eslintrc.js'],
|
|
18
|
+
rules: {
|
|
19
|
+
'@typescript-eslint/interface-name-prefix': 'off',
|
|
20
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
21
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
22
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 KnowYourself
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
MAKEFILE := $(abspath $(lastword $(MAKEFILE_LIST)))
|
|
2
|
+
ROOT_PATH := $(shell pwd)
|
|
3
|
+
|
|
4
|
+
.PHONY: test
|
|
5
|
+
|
|
6
|
+
version-major: #version-sync
|
|
7
|
+
@npm -s version major --no-git-tag-version
|
|
8
|
+
|
|
9
|
+
version-minor: #version-sync
|
|
10
|
+
@npm -s version minor --no-git-tag-version
|
|
11
|
+
|
|
12
|
+
version-patch: #version-sync
|
|
13
|
+
@npm -s version patch --no-git-tag-version
|
|
14
|
+
|
|
15
|
+
version-prerelease: #version-sync
|
|
16
|
+
@npm -s version prerelease --preid=rc --no-git-tag-version
|
|
17
|
+
|
|
18
|
+
version-latest:
|
|
19
|
+
@(git tag --sort=-creatordate || echo) | awk 'NR==1 { \
|
|
20
|
+
split($$0, n, "-"); \
|
|
21
|
+
if (n[1] != "") { \
|
|
22
|
+
split(n[1], v, "."); \
|
|
23
|
+
if (v[1] ~ /^[0-9]+$$/ && v[2] ~ /^[0-9]+$$/ && v[3] ~ /^[0-9]+$$/) { \
|
|
24
|
+
print $$0; \
|
|
25
|
+
exit 0; \
|
|
26
|
+
} \
|
|
27
|
+
} \
|
|
28
|
+
print "1.0.0-rc.0"; \
|
|
29
|
+
} \
|
|
30
|
+
END { \
|
|
31
|
+
if (NR == 0) { \
|
|
32
|
+
print "1.0.0-rc.0"; \
|
|
33
|
+
} \
|
|
34
|
+
}'
|
|
35
|
+
|
|
36
|
+
version-sync:
|
|
37
|
+
@git checkout $(CI_COMMIT_BRANCH)
|
|
38
|
+
@git pull --tags 2&>/dev/null || true
|
|
39
|
+
@git tag --sort=-creatordate | head -10
|
|
40
|
+
@cat package.json | jq -r --arg PKG_VERSION `make --no-print-directory -f$(MAKEFILE) version-latest` '.version=$$PKG_VERSION' > package.json;
|
|
41
|
+
@echo -n "Current Git tag: "; cat package.json | jq -r '.version'
|
|
42
|
+
|
|
43
|
+
version:
|
|
44
|
+
@echo $(shell node -p "require('$(ROOT_PATH)/package.json').version")
|
|
45
|
+
|
|
46
|
+
name:
|
|
47
|
+
@echo $(SERVICE_NAME)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
test:
|
|
51
|
+
@echo "Skipped"
|
|
52
|
+
|
|
53
|
+
build-prerelease: version-prerelease
|
|
54
|
+
@npm run build
|
|
55
|
+
|
|
56
|
+
build: version-patch
|
|
57
|
+
@npm run build
|
|
58
|
+
|
|
59
|
+
release:
|
|
60
|
+
@npm publish --access public
|
|
61
|
+
|
|
62
|
+
publish-prerelease: build-prerelease
|
|
63
|
+
@make --no-print-directory release
|
|
64
|
+
|
|
65
|
+
publish: build
|
|
66
|
+
@make --no-print-directory release
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Library
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./dist";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "<%= projectName %>",
|
|
3
|
+
"version": "1.0.0-rc.0",
|
|
4
|
+
"description": "na-cli generated ts-library 1.0.0",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "rimraf dist && tsc -p tsconfig.json",
|
|
7
|
+
"precommit": "lint-staged",
|
|
8
|
+
"prepublish": "npm run build",
|
|
9
|
+
"publish-public": "npm publish --access public",
|
|
10
|
+
"test": "jest",
|
|
11
|
+
"test:watch": "jest --watch",
|
|
12
|
+
"test:cov": "jest --coverage",
|
|
13
|
+
"test:e2e": "jest --config ./test/jest-e2e.json",
|
|
14
|
+
"lint": "eslint -c .eslintrc.js"
|
|
15
|
+
},
|
|
16
|
+
"author": "<%= author %>",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/jest": "^28.1.6",
|
|
20
|
+
"@types/node": "^18.11.18",
|
|
21
|
+
"@typescript-eslint/eslint-plugin": "^4.3.5",
|
|
22
|
+
"@typescript-eslint/parser": "^4.3.5",
|
|
23
|
+
"eslint": "*",
|
|
24
|
+
"eslint-config-prettier": "^6",
|
|
25
|
+
"eslint-plugin-prettier": "^3",
|
|
26
|
+
"jest": "^28.1.3",
|
|
27
|
+
"prettier": "^2",
|
|
28
|
+
"ts-jest": "^28.0.7",
|
|
29
|
+
"typescript": "^4.3.5"
|
|
30
|
+
},
|
|
31
|
+
"types": "./index.d.ts",
|
|
32
|
+
"main": "index.js",
|
|
33
|
+
"directories": {
|
|
34
|
+
"lib": "lib"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/utils/template.ts"],"names":[],"mappings":";;;AAAA,yBAA2B;
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/utils/template.ts"],"names":[],"mappings":";;;AAAA,yBAA2B;AAO3B,SAAgB,MAAM,CAAC,OAAe,EAAE,IAAkB;IACtD,OAAO,GAAG,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AACrC,CAAC;AAFD,wBAEC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nathapp/na-cli",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.6",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"start": "
|
|
6
|
+
"start": "npm run build && node dist/index.js",
|
|
7
7
|
"build": "tsc && shx rm -rf dist/templates && shx cp -r templates dist"
|
|
8
8
|
},
|
|
9
9
|
"bin": {
|
package/src/index.ts
CHANGED
|
@@ -27,6 +27,12 @@ const QUESTIONS = [
|
|
|
27
27
|
if (/^([A-Za-z\-\_\d])+$/.test(input)) return true;
|
|
28
28
|
else return 'Project name may only include letters, numbers, underscores and hashes.';
|
|
29
29
|
}
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'author',
|
|
33
|
+
type: 'input',
|
|
34
|
+
message: 'Author:',
|
|
35
|
+
when: () => !yargs.argv['author']
|
|
30
36
|
}
|
|
31
37
|
];
|
|
32
38
|
|
|
@@ -53,6 +59,8 @@ inquirer.prompt(QUESTIONS)
|
|
|
53
59
|
const projectChoice = answers['template'];
|
|
54
60
|
// @ts-ignore
|
|
55
61
|
const projectName = answers['name'];
|
|
62
|
+
// @ts-ignore
|
|
63
|
+
const author = answers['author'];
|
|
56
64
|
const templatePath = path.join(__dirname, 'templates', projectChoice);
|
|
57
65
|
const tartgetPath = path.join(CURR_DIR, projectName);
|
|
58
66
|
const templateConfig = getTemplateConfig(templatePath);
|
|
@@ -69,7 +77,7 @@ inquirer.prompt(QUESTIONS)
|
|
|
69
77
|
return;
|
|
70
78
|
}
|
|
71
79
|
|
|
72
|
-
createDirectoryContents(templatePath, projectName, templateConfig);
|
|
80
|
+
createDirectoryContents(templatePath, projectName, templateConfig, author);
|
|
73
81
|
|
|
74
82
|
if (!postProcess(options)) {
|
|
75
83
|
return;
|
|
@@ -154,7 +162,7 @@ function postProcessNode(options: CliOptions) {
|
|
|
154
162
|
|
|
155
163
|
const SKIP_FILES = ['node_modules', '.template.json'];
|
|
156
164
|
|
|
157
|
-
function createDirectoryContents(templatePath: string, projectName: string, config: TemplateConfig) {
|
|
165
|
+
function createDirectoryContents(templatePath: string, projectName: string, config: TemplateConfig, author?: string) {
|
|
158
166
|
const filesToCreate = fs.readdirSync(templatePath);
|
|
159
167
|
|
|
160
168
|
filesToCreate.forEach(file => {
|
|
@@ -168,7 +176,7 @@ function createDirectoryContents(templatePath: string, projectName: string, conf
|
|
|
168
176
|
if (stats.isFile()) {
|
|
169
177
|
let contents = fs.readFileSync(origFilePath, 'utf8');
|
|
170
178
|
|
|
171
|
-
contents = template.render(contents, { projectName });
|
|
179
|
+
contents = template.render(contents, { projectName, author });
|
|
172
180
|
|
|
173
181
|
const writePath = path.join(CURR_DIR, projectName, file);
|
|
174
182
|
fs.writeFileSync(writePath, contents, 'utf8');
|
|
@@ -176,7 +184,7 @@ function createDirectoryContents(templatePath: string, projectName: string, conf
|
|
|
176
184
|
fs.mkdirSync(path.join(CURR_DIR, projectName, file));
|
|
177
185
|
|
|
178
186
|
// recursive call
|
|
179
|
-
createDirectoryContents(path.join(templatePath, file), path.join(projectName, file), config);
|
|
187
|
+
createDirectoryContents(path.join(templatePath, file), path.join(projectName, file), config, author);
|
|
180
188
|
}
|
|
181
189
|
});
|
|
182
190
|
}
|
package/src/utils/template.ts
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
parser: '@typescript-eslint/parser',
|
|
3
|
+
parserOptions: {
|
|
4
|
+
project: 'tsconfig.json',
|
|
5
|
+
sourceType: 'module',
|
|
6
|
+
},
|
|
7
|
+
plugins: ['@typescript-eslint/eslint-plugin'],
|
|
8
|
+
extends: [
|
|
9
|
+
'plugin:@typescript-eslint/recommended',
|
|
10
|
+
'plugin:prettier/recommended',
|
|
11
|
+
],
|
|
12
|
+
root: true,
|
|
13
|
+
env: {
|
|
14
|
+
node: true,
|
|
15
|
+
jest: true,
|
|
16
|
+
},
|
|
17
|
+
ignorePatterns: ['.eslintrc.js'],
|
|
18
|
+
rules: {
|
|
19
|
+
'@typescript-eslint/interface-name-prefix': 'off',
|
|
20
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
21
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
22
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 KnowYourself
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
MAKEFILE := $(abspath $(lastword $(MAKEFILE_LIST)))
|
|
2
|
+
ROOT_PATH := $(shell pwd)
|
|
3
|
+
|
|
4
|
+
.PHONY: test
|
|
5
|
+
|
|
6
|
+
version-major: #version-sync
|
|
7
|
+
@npm -s version major --no-git-tag-version
|
|
8
|
+
|
|
9
|
+
version-minor: #version-sync
|
|
10
|
+
@npm -s version minor --no-git-tag-version
|
|
11
|
+
|
|
12
|
+
version-patch: #version-sync
|
|
13
|
+
@npm -s version patch --no-git-tag-version
|
|
14
|
+
|
|
15
|
+
version-prerelease: #version-sync
|
|
16
|
+
@npm -s version prerelease --preid=rc --no-git-tag-version
|
|
17
|
+
|
|
18
|
+
version-latest:
|
|
19
|
+
@(git tag --sort=-creatordate || echo) | awk 'NR==1 { \
|
|
20
|
+
split($$0, n, "-"); \
|
|
21
|
+
if (n[1] != "") { \
|
|
22
|
+
split(n[1], v, "."); \
|
|
23
|
+
if (v[1] ~ /^[0-9]+$$/ && v[2] ~ /^[0-9]+$$/ && v[3] ~ /^[0-9]+$$/) { \
|
|
24
|
+
print $$0; \
|
|
25
|
+
exit 0; \
|
|
26
|
+
} \
|
|
27
|
+
} \
|
|
28
|
+
print "1.0.0-rc.0"; \
|
|
29
|
+
} \
|
|
30
|
+
END { \
|
|
31
|
+
if (NR == 0) { \
|
|
32
|
+
print "1.0.0-rc.0"; \
|
|
33
|
+
} \
|
|
34
|
+
}'
|
|
35
|
+
|
|
36
|
+
version-sync:
|
|
37
|
+
@git checkout $(CI_COMMIT_BRANCH)
|
|
38
|
+
@git pull --tags 2&>/dev/null || true
|
|
39
|
+
@git tag --sort=-creatordate | head -10
|
|
40
|
+
@cat package.json | jq -r --arg PKG_VERSION `make --no-print-directory -f$(MAKEFILE) version-latest` '.version=$$PKG_VERSION' > package.json;
|
|
41
|
+
@echo -n "Current Git tag: "; cat package.json | jq -r '.version'
|
|
42
|
+
|
|
43
|
+
version:
|
|
44
|
+
@echo $(shell node -p "require('$(ROOT_PATH)/package.json').version")
|
|
45
|
+
|
|
46
|
+
name:
|
|
47
|
+
@echo $(SERVICE_NAME)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
test:
|
|
51
|
+
@echo "Skipped"
|
|
52
|
+
|
|
53
|
+
build-prerelease: version-prerelease
|
|
54
|
+
@npm run build
|
|
55
|
+
|
|
56
|
+
build: version-patch
|
|
57
|
+
@npm run build
|
|
58
|
+
|
|
59
|
+
release:
|
|
60
|
+
@npm publish --access public
|
|
61
|
+
|
|
62
|
+
publish-prerelease: build-prerelease
|
|
63
|
+
@make --no-print-directory release
|
|
64
|
+
|
|
65
|
+
publish: build
|
|
66
|
+
@make --no-print-directory release
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Library
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./dist";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "<%= projectName %>",
|
|
3
|
+
"version": "1.0.0-rc.0",
|
|
4
|
+
"description": "na-cli generated ts-library 1.0.0",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "rimraf dist && tsc -p tsconfig.json",
|
|
7
|
+
"precommit": "lint-staged",
|
|
8
|
+
"prepublish": "npm run build",
|
|
9
|
+
"publish-public": "npm publish --access public",
|
|
10
|
+
"test": "jest",
|
|
11
|
+
"test:watch": "jest --watch",
|
|
12
|
+
"test:cov": "jest --coverage",
|
|
13
|
+
"test:e2e": "jest --config ./test/jest-e2e.json",
|
|
14
|
+
"lint": "eslint -c .eslintrc.js"
|
|
15
|
+
},
|
|
16
|
+
"author": "<%= author %>",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/jest": "^28.1.6",
|
|
20
|
+
"@types/node": "^18.11.18",
|
|
21
|
+
"@typescript-eslint/eslint-plugin": "^4.3.5",
|
|
22
|
+
"@typescript-eslint/parser": "^4.3.5",
|
|
23
|
+
"eslint": "*",
|
|
24
|
+
"eslint-config-prettier": "^6",
|
|
25
|
+
"eslint-plugin-prettier": "^3",
|
|
26
|
+
"jest": "^28.1.3",
|
|
27
|
+
"prettier": "^2",
|
|
28
|
+
"ts-jest": "^28.0.7",
|
|
29
|
+
"typescript": "^4.3.5"
|
|
30
|
+
},
|
|
31
|
+
"types": "./index.d.ts",
|
|
32
|
+
"main": "index.js",
|
|
33
|
+
"directories": {
|
|
34
|
+
"lib": "lib"
|
|
35
|
+
}
|
|
36
|
+
}
|