@gooddaydev/common 1.0.2 → 1.0.4

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.
@@ -5,7 +5,9 @@ on:
5
5
  branches:
6
6
  - main
7
7
 
8
- permissions: write-all
8
+ permissions:
9
+ contents: write
10
+ packages: write
9
11
 
10
12
  jobs:
11
13
  release:
@@ -13,25 +15,35 @@ jobs:
13
15
  runs-on: ubuntu-latest
14
16
  steps:
15
17
  - name: checkout
16
- uses: actions/checkout@v3.6.0
18
+ uses: actions/checkout@v3
19
+ with:
20
+ fetch-depth: 0 # Ensure we get all commit history
21
+
17
22
  - name: setup nodejs environment
18
- uses: actions/setup-node@v3.8.1
23
+ uses: actions/setup-node@v3
19
24
  with:
20
25
  node-version: 20
21
26
  registry-url: https://registry.npmjs.org
27
+
22
28
  - name: install dependencies
23
- run: yarn
29
+ run: yarn install --frozen-lockfile
30
+
24
31
  - name: build
25
32
  run: yarn build
33
+
26
34
  - name: 'Automated Version Bump'
27
35
  id: version-bump
28
36
  uses: 'phips28/gh-action-bump-version@master'
29
37
  env:
30
38
  GITHUB_TOKEN: ${{ secrets.TOKEN }}
31
- with:
32
- skip-push: 'true'
39
+
40
+ - name: Push new tags
41
+ run: |
42
+ git push origin --tags
43
+ env:
44
+ GITHUB_TOKEN: ${{ secrets.TOKEN }}
45
+
33
46
  - name: publish
34
47
  run: npm publish --access public
35
- working-directory: .
36
48
  env:
37
- NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
49
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @gooddaydev/common v1.0.1
2
+ * @gooddaydev/common v1.0.3
3
3
  * (c) undefined
4
4
  * Released under the MIT License.
5
5
  */
package/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @gooddaydev/common v1.0.1
2
+ * @gooddaydev/common v1.0.3
3
3
  * (c) undefined
4
4
  * Released under the MIT License.
5
5
  */
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @gooddaydev/common v1.0.1
2
+ * @gooddaydev/common v1.0.3
3
3
  * (c) undefined
4
4
  * Released under the MIT License.
5
5
  */
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @gooddaydev/common v1.0.1
2
+ * @gooddaydev/common v1.0.3
3
3
  * (c) undefined
4
4
  * Released under the MIT License.
5
5
  */
package/dist/index.umd.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @gooddaydev/common v1.0.1
2
+ * @gooddaydev/common v1.0.3
3
3
  * (c) undefined
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @gooddaydev/common v1.0.1
2
+ * @gooddaydev/common v1.0.3
3
3
  * (c) undefined
4
4
  * Released under the MIT License.
5
5
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gooddaydev/common",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Common utilities for TypeScript projects with CI/CD",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -25,8 +25,10 @@
25
25
  "@types/jest": "^29.5.14",
26
26
  "@types/mongoose-delete": "^1.0.6",
27
27
  "@types/node": "^22.10.2",
28
+ "@types/prettier": "^3.0.0",
28
29
  "eslint": "^9.16.0",
29
30
  "jest": "^29.7.0",
31
+ "prettier": "^3.5.3",
30
32
  "rollup": "^4.28.1",
31
33
  "rollup-plugin-typescript2": "^0.36.0",
32
34
  "typescript": "^5.7.2"
@@ -0,0 +1,15 @@
1
+ // @ts-check
2
+ /* eslint-env node */
3
+
4
+ /**
5
+ * An object with Prettier.js options.
6
+ * @type {import('prettier').Options}
7
+ */
8
+ const options = {
9
+ bracketSameLine: true,
10
+ quoteProps: 'consistent',
11
+ singleQuote: true,
12
+ trailingComma: 'all',
13
+ };
14
+
15
+ module.exports = options;
package/setup.js ADDED
@@ -0,0 +1,128 @@
1
+ /* eslint-env node */
2
+ /* eslint-disable @typescript-eslint/no-var-requires */
3
+
4
+ const fs = require('fs/promises');
5
+ const path = require('path');
6
+ const readline = require('readline');
7
+
8
+ const resolveToFiles = (directory) => async (dirent) => {
9
+ if (
10
+ dirent.name === '.git' ||
11
+ dirent.name === 'setup.js' ||
12
+ dirent.name === 'node_modules'
13
+ )
14
+ return [];
15
+ if (dirent.isFile()) return [path.resolve(directory, dirent.name)];
16
+ if (dirent.isDirectory())
17
+ return await getFiles(path.resolve(directory, dirent.name));
18
+ return [];
19
+ };
20
+
21
+ const getFiles = async (directory) => {
22
+ const filesWithTypes = await fs.readdir(directory, {
23
+ encoding: 'utf-8',
24
+ withFileTypes: true,
25
+ });
26
+
27
+ const resolutions = filesWithTypes.map(resolveToFiles(directory));
28
+
29
+ const files = await Promise.all(resolutions);
30
+
31
+ return files.flat(1);
32
+ };
33
+
34
+ const gettingFiles = getFiles(path.resolve(__dirname));
35
+
36
+ const replaceInFile = (matcher, replacer) => async (path) => {
37
+ const contents = await fs.readFile(path, { encoding: 'utf-8' });
38
+ await fs.writeFile(path, contents.replace(matcher, replacer));
39
+ };
40
+
41
+ const rl = readline.createInterface({
42
+ input: process.stdin,
43
+ output: process.stdout,
44
+ });
45
+
46
+ const replaceVariable = async (variable, value) => {
47
+ const files = await gettingFiles;
48
+
49
+ const matcher = new RegExp(`\\[${variable}\\]`, 'g');
50
+
51
+ await Promise.all(files.map(replaceInFile(matcher, value)));
52
+ };
53
+
54
+ const fillTemplateVariable = (variable, question, defaultValue = '') =>
55
+ new Promise((resolve) => {
56
+ rl.question(question, async (receivedValue) => {
57
+ const value = receivedValue?.trim() || defaultValue;
58
+
59
+ replaceVariable(variable, value);
60
+
61
+ rl.write(`Replaced ${variable} to "${value}".\n`);
62
+
63
+ resolve();
64
+ });
65
+ });
66
+
67
+ replaceVariable('year', new Date().getFullYear())
68
+ .then(() =>
69
+ fillTemplateVariable(
70
+ 'libraryNameWithSpacesAndUpperCases',
71
+ `
72
+ Library name (can have upper/lower case letters, spaces, numbers and special characters)
73
+ Ex. React.js, Vue.js, Fetch Interceptors, GraphQL Loader for Webpack etc.
74
+ > `,
75
+ ),
76
+ )
77
+ .then(() =>
78
+ fillTemplateVariable(
79
+ 'libraryName',
80
+ `
81
+ Module name (only lower case letters, "." or "-") and optionally with scope.
82
+ Ex. react, vue, fetch-interceptors, @webpack/graphql-loader etc.
83
+ > `,
84
+ ),
85
+ )
86
+ .then(() =>
87
+ fillTemplateVariable(
88
+ 'libraryCamelCaseName',
89
+ `
90
+ What is you library name in camel-case for UMD bundles?
91
+ Ex. React, Vue, fetchInterceptors, graphqlLoaderForWebpack etc.
92
+ > `,
93
+ ),
94
+ )
95
+ .then(() =>
96
+ fillTemplateVariable(
97
+ 'repositoryOwner',
98
+ `
99
+ What is your nickname on GitHub?
100
+ > `,
101
+ '',
102
+ ),
103
+ )
104
+ .then(() =>
105
+ fillTemplateVariable(
106
+ 'repositoryName',
107
+ `
108
+ What will be this repository name on GitHub?
109
+ > `,
110
+ ),
111
+ )
112
+ .then(() =>
113
+ fillTemplateVariable(
114
+ 'authorFullName',
115
+ `
116
+ What is your full name? (used in MIT License)
117
+ > `,
118
+ '',
119
+ ),
120
+ )
121
+ .then(() => {
122
+ rl.close();
123
+ fs.unlink(path.resolve(__filename));
124
+ })
125
+ .catch((error) => {
126
+ console.error(error?.message ?? error ?? 'Unknown error.');
127
+ rl.close();
128
+ });
package/index.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import { Plugin } from 'rollup';
2
-
3
- declare module 'rollup-plugin-terser' {
4
-
5
- export interface TerserOptions {
6
- // Add any specific options you need here
7
- }
8
-
9
- export default function terser(options?: TerserOptions): Plugin;
10
- }