Skip to content

Commit 1308a71

Browse files
committed
Merge branch 'beta'
2 parents 8a6cba8 + 29bb1a6 commit 1308a71

File tree

7 files changed

+57
-35
lines changed

7 files changed

+57
-35
lines changed

CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1-
# v2.0.3 (January 14, 2022)
1+
# v2.0.4 (January 14, 2022)
22

3-
- Fix: vanilla import with require()
3+
- Fix: scripts
4+
- Feature: examples
5+
- Refactor: removed console.log()
46

57
<!-- all-shields/sponsors-badges:START -->
68

79
[![Donate Paypal](https://img.shields.io/badge/donate-paypal-005EA6.svg?style=for-the-badge&logo=paypal)](https://www.paypal.me/ptkdev) [![Donate Ko-Fi](https://img.shields.io/badge/donate-ko--fi-29abe0.svg?style=for-the-badge&logo=ko-fi)](https://ko-fi.com/ptkdev) [![Donate Github Sponsors](https://img.shields.io/badge/donate-sponsors-ea4aaa.svg?style=for-the-badge&logo=github)](https://github.com/sponsors/ptkdev) [![Donate Patreon](https://img.shields.io/badge/donate-patreon-F87668.svg?style=for-the-badge&logo=patreon)](https://www.patreon.com/join/ptkdev) [![Donate Bitcoin](https://img.shields.io/badge/BTC-35jQmZCy4nsxoMM3QPFrnZePDVhdKaHMRH-E38B29.svg?style=flat-square&logo=bitcoin)](https://ptk.dev/img/icons/menu/bitcoin_wallet.png) [![Donate Ethereum](https://img.shields.io/badge/ETH-0x8b8171661bEb032828e82baBb0B5B98Ba8fBEBFc-4E8EE9.svg?style=flat-square&logo=ethereum)](https://ptk.dev/img/icons/menu/ethereum_wallet.png)
810

911
<!-- all-shields/sponsors-badges:END -->
1012

13+
# v2.0.3 (January 14, 2022)
14+
15+
- Fix: vanilla import with require()
16+
1117
# v2.0.2 (January 14, 2022)
1218

1319
- Refactor: code quality, scripts and interfaces

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<!-- all-shields/header-badges:START -->
44

5-
[![v2.0.3](https://img.shields.io/badge/version-v2.0.3-lightgray.svg?style=flat&logo=)](https://github.com/ptkdev-boilerplate/node-module-boilerplate/blob/main/CHANGELOG.md) [![](https://img.shields.io/npm/v/@ptkdev/node-module-boilerplate?color=CC3534&logo=npm)](https://www.npmjs.com/package/@ptkdev/node-module-boilerplate) [![License: MIT](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat&logo=license)](https://github.com/ptkdev-boilerplate/node-module-boilerplate/blob/main/LICENSE.md) [![Language: TypeScript](https://img.shields.io/badge/language-typescript-blue.svg?style=flat&logo=typescript)](https://www.typescriptlang.org/) [![ECMAScript: 2019](https://img.shields.io/badge/ES-9-F7DF1E.svg?style=flat&logo=javascript)](https://github.com/tc39/ecma262) [![Discord Server](https://discordapp.com/api/guilds/383373985666301975/embed.png)](https://discord.ptkdev.io)
5+
[![v2.0.4-beta.1](https://img.shields.io/badge/version-v2.0.4--beta.1-lightgray.svg?style=flat&logo=)](https://github.com/ptkdev-boilerplate/node-module-boilerplate/blob/main/CHANGELOG.md) [![](https://img.shields.io/npm/v/@ptkdev/node-module-boilerplate?color=CC3534&logo=npm)](https://www.npmjs.com/package/@ptkdev/node-module-boilerplate) [![License: MIT](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat&logo=license)](https://github.com/ptkdev-boilerplate/node-module-boilerplate/blob/main/LICENSE.md) [![Language: TypeScript](https://img.shields.io/badge/language-typescript-blue.svg?style=flat&logo=typescript)](https://www.typescriptlang.org/) [![ECMAScript: 2019](https://img.shields.io/badge/ES-9-F7DF1E.svg?style=flat&logo=javascript)](https://github.com/tc39/ecma262) [![Discord Server](https://discordapp.com/api/guilds/383373985666301975/embed.png)](https://discord.ptkdev.io)
66

77
<!-- all-shields/header-badges:END -->
88

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@ptkdev/node-module-boilerplate",
33
"displayName": "Node NPM Library Boilerplate",
44
"description": "Create your npm library with this friendly boilerplate. Use this respository as template for your new node library/module",
5-
"version": "2.0.3",
5+
"version": "2.0.4-beta.1",
66
"main": "dist/functions/module.js",
77
"publishConfig": {
88
"access": "public"

scripts/changelog_release.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,21 @@
99
*
1010
*/
1111
import * as fs from "fs";
12+
import Logger from "@ptkdev/logger";
13+
14+
const logger = new Logger();
1215

1316
if (fs.existsSync("./CHANGELOG.md")) {
14-
fs.readFile("./CHANGELOG.md", "utf8", (err, data) => {
15-
if (err) {
16-
console.log(err);
17+
fs.readFile("./CHANGELOG.md", "utf8", (error, data) => {
18+
if (error) {
19+
logger.error(JSON.stringify(error));
1720
}
1821

1922
const changelog = data.match(/\n([\s\S]*)-->\n/gm);
2023
changelog?.forEach((c) => {
21-
fs.writeFile("./CHANGELOG_RELEASE.txt", c, function writeJSON(err) {
22-
if (err) {
23-
console.log(err);
24+
fs.writeFile("./CHANGELOG_RELEASE.txt", c, function writeJSON(error) {
25+
if (error) {
26+
logger.error(JSON.stringify(error));
2427
}
2528
});
2629
});

scripts/githash.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,31 @@
88
* @license: MIT License
99
*
1010
*/
11+
import Logger from "@ptkdev/logger";
1112
import fs from "fs";
1213
import path from "path";
1314
import { execSync } from "child_process";
1415
import semver from "../package.json";
1516

17+
const gitdotfile = `${__dirname}/../.git/config`;
18+
const logger = new Logger();
19+
let branch = "";
20+
let hash = "";
21+
1622
const execSyncWrapper = (command: string) => {
17-
let stdout: string | null = null;
23+
let stdout = "";
1824
try {
1925
stdout = execSync(command).toString().trim();
2026
} catch (error) {
21-
console.error(error);
27+
logger.error(JSON.stringify(error));
2228
}
2329
return stdout;
2430
};
2531

26-
const branch = execSyncWrapper("git rev-parse --abbrev-ref HEAD");
27-
const hash = execSyncWrapper("git rev-parse --short=7 HEAD");
32+
if (fs.existsSync(gitdotfile)) {
33+
branch = execSyncWrapper("git rev-parse --abbrev-ref HEAD");
34+
hash = execSyncWrapper("git rev-parse --short=7 HEAD");
35+
}
2836

2937
const obj = {
3038
semver: semver.version.split("-")[0],

scripts/setup.ts

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111
* @license: MIT License
1212
*
1313
*/
14-
import * as shell from "shelljs";
14+
import Logger from "@ptkdev/logger";
1515
const replace = require("replace-in-file");
1616
const setup = require("../setup.json");
1717
const pkg = require("../package.json");
1818

19+
const logger = new Logger();
20+
1921
(async () => {
2022
try {
2123
await replace({
@@ -25,7 +27,7 @@ const pkg = require("../package.json");
2527
to: setup.github_full_repository_url,
2628
});
2729
} catch (error) {
28-
console.error("Error occurred:", error);
30+
logger.error(JSON.stringify(error));
2931
}
3032

3133
try {
@@ -36,7 +38,7 @@ const pkg = require("../package.json");
3638
to: setup.github_full_repository_url,
3739
});
3840
} catch (error) {
39-
console.error("Error occurred:", error);
41+
logger.error(JSON.stringify(error));
4042
}
4143

4244
try {
@@ -47,7 +49,7 @@ const pkg = require("../package.json");
4749
to: setup.github_repository_url.replace("github.com", "githubusercontent.com"),
4850
});
4951
} catch (error) {
50-
console.error("Error occurred:", error);
52+
logger.error(JSON.stringify(error));
5153
}
5254

5355
try {
@@ -58,7 +60,7 @@ const pkg = require("../package.json");
5860
to: setup.github_repository_url.replace("github.com", "githubusercontent.com"),
5961
});
6062
} catch (error) {
61-
console.error("Error occurred:", error);
63+
logger.error(JSON.stringify(error));
6264
}
6365

6466
try {
@@ -69,7 +71,7 @@ const pkg = require("../package.json");
6971
to: setup.github_repository_url,
7072
});
7173
} catch (error) {
72-
console.error("Error occurred:", error);
74+
logger.error(JSON.stringify(error));
7375
}
7476

7577
try {
@@ -80,7 +82,7 @@ const pkg = require("../package.json");
8082
to: setup.github_repository_url,
8183
});
8284
} catch (error) {
83-
console.error("Error occurred:", error);
85+
logger.error(JSON.stringify(error));
8486
}
8587

8688
try {
@@ -91,7 +93,7 @@ const pkg = require("../package.json");
9193
to: setup.package_org !== "" ? `${setup.package_org}/${setup.package_name}` : setup.package_name,
9294
});
9395
} catch (error) {
94-
console.error("Error occurred:", error);
96+
logger.error(JSON.stringify(error));
9597
}
9698

9799
try {
@@ -102,7 +104,7 @@ const pkg = require("../package.json");
102104
to: setup.display_name,
103105
});
104106
} catch (error) {
105-
console.error("Error occurred:", error);
107+
logger.error(JSON.stringify(error));
106108
}
107109

108110
try {
@@ -113,7 +115,7 @@ const pkg = require("../package.json");
113115
to: setup.description,
114116
});
115117
} catch (error) {
116-
console.error("Error occurred:", error);
118+
logger.error(JSON.stringify(error));
117119
}
118120

119121
try {
@@ -124,7 +126,7 @@ const pkg = require("../package.json");
124126
to: setup.author,
125127
});
126128
} catch (error) {
127-
console.error("Error occurred:", error);
129+
logger.error(JSON.stringify(error));
128130
}
129131

130132
try {
@@ -135,7 +137,7 @@ const pkg = require("../package.json");
135137
to: setup.author_markdown,
136138
});
137139
} catch (error) {
138-
console.error("Error occurred:", error);
140+
logger.error(JSON.stringify(error));
139141
}
140142

141143
try {
@@ -146,7 +148,7 @@ const pkg = require("../package.json");
146148
to: `"projectName": "${setup.github_full_repository_url.replace("github.com/", "")}"`,
147149
});
148150
} catch (error) {
149-
console.error("Error occurred:", error);
151+
logger.error(JSON.stringify(error));
150152
}
151153

152154
try {
@@ -157,7 +159,7 @@ const pkg = require("../package.json");
157159
to: `"projectOwner": "${setup.github_nickname}"`,
158160
});
159161
} catch (error) {
160-
console.error("Error occurred:", error);
162+
logger.error(JSON.stringify(error));
161163
}
162164

163165
try {
@@ -168,7 +170,7 @@ const pkg = require("../package.json");
168170
to: setup.github_nickname,
169171
});
170172
} catch (error) {
171-
console.error("Error occurred:", error);
173+
logger.error(JSON.stringify(error));
172174
}
173175

174176
try {
@@ -179,7 +181,7 @@ const pkg = require("../package.json");
179181
to: setup.package_name.replace(setup.package_org),
180182
});
181183
} catch (error) {
182-
console.error("Error occurred:", error);
184+
logger.error(JSON.stringify(error));
183185
}
184186

185187
try {
@@ -190,7 +192,7 @@ const pkg = require("../package.json");
190192
to: setup.email,
191193
});
192194
} catch (error) {
193-
console.error("Error occurred:", error);
195+
logger.error(JSON.stringify(error));
194196
}
195197

196198
try {
@@ -201,6 +203,6 @@ const pkg = require("../package.json");
201203
to: "1.0.0",
202204
});
203205
} catch (error) {
204-
console.error("Error occurred:", error);
206+
logger.error(JSON.stringify(error));
205207
}
206208
})();

scripts/version.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99
*
1010
*/
1111
import * as fs from "fs";
12+
import Logger from "@ptkdev/logger";
1213
import { argv } from "yargs";
1314
import pkg from "../package.json";
1415

16+
const logger = new Logger();
17+
1518
const version = pkg.version.split(".");
1619
let next_version, patch;
1720

@@ -43,9 +46,9 @@ switch (argv.cmd) {
4346
pkg.version = next_version;
4447

4548
if (fs.existsSync("./package.json")) {
46-
fs.writeFile("./package.json", JSON.stringify(pkg), function writeJSON(err) {
47-
if (err) {
48-
console.log(err);
49+
fs.writeFile("./package.json", JSON.stringify(pkg), function writeJSON(error) {
50+
if (error) {
51+
logger.error(JSON.stringify(error));
4952
}
5053
});
5154
}

0 commit comments

Comments
 (0)