ethereal-design-tokens-teste 1.0.0
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/.github /workflows/_validate-json.yaml +19 -0
- package/.github /workflows/publish-package.yaml +49 -0
- package/.github /workflows/pull-request.yaml +8 -0
- package/.github /workflows/utils/executeSyntaxValidation.js +32 -0
- package/.github /workflows/utils/verifyJsonSyntax.js +14 -0
- package/index.js +1 -0
- package/package.json +24 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
name: Validate JSON Syntax
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_call:
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
check-json:
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
steps:
|
|
10
|
+
- name: Checkout code
|
|
11
|
+
uses: actions/checkout@v4
|
|
12
|
+
|
|
13
|
+
- name: Configure Node.js
|
|
14
|
+
uses: actions/setup-node@v4
|
|
15
|
+
with:
|
|
16
|
+
node-version: "20"
|
|
17
|
+
|
|
18
|
+
- name: Execute JSON format validation script
|
|
19
|
+
run: node .github/workflows/utils/executeSyntaxValidation tokens.json
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
name: Publish package
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
id-token: write
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
validate-json:
|
|
14
|
+
uses: ./.github/workflows/_validate-json.yaml
|
|
15
|
+
|
|
16
|
+
increase-and-publish:
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
needs: validate-json
|
|
19
|
+
steps:
|
|
20
|
+
- name: Checkout Code
|
|
21
|
+
uses: actions/checkout@v4
|
|
22
|
+
with:
|
|
23
|
+
token: ${{ secrets.BOT_GITHUB_TOKEN }}
|
|
24
|
+
|
|
25
|
+
- name: Configure Node.js
|
|
26
|
+
uses: actions/setup-node@v4
|
|
27
|
+
with:
|
|
28
|
+
node-version: "24.x"
|
|
29
|
+
registry-url: "https://registry.npmjs.org"
|
|
30
|
+
|
|
31
|
+
- name: Configure Git Bot
|
|
32
|
+
run: |
|
|
33
|
+
git config --global user.name "github-actions[bot]"
|
|
34
|
+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
35
|
+
|
|
36
|
+
- name: Increase version
|
|
37
|
+
run: npm run increase-version
|
|
38
|
+
|
|
39
|
+
- name: Check package.json content
|
|
40
|
+
run: cat package.json
|
|
41
|
+
|
|
42
|
+
- name: Publish package
|
|
43
|
+
run: npm publish --access public --provenance
|
|
44
|
+
|
|
45
|
+
- name: Push changes
|
|
46
|
+
run: |
|
|
47
|
+
git push
|
|
48
|
+
git push --tags
|
|
49
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
export function executeSyntaxValidation() {
|
|
5
|
+
/**Get filename add as param in GitHub Actions*/
|
|
6
|
+
const gthActFileName = process.argv[2];
|
|
7
|
+
|
|
8
|
+
if (!gthActFileName) {
|
|
9
|
+
console.error("No files were specified in the workflow!");
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const filePath = path.resolve(gthActFileName);
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
const fileContent = fs.readFileSync(filePath, "utf8");
|
|
17
|
+
|
|
18
|
+
const isAValidJson = verifyJsonSyntax(fileContent);
|
|
19
|
+
|
|
20
|
+
if (isAValidJson) {
|
|
21
|
+
console.log(`The file '${gthActFileName}' is a valid JSON.`);
|
|
22
|
+
process.exit(0);
|
|
23
|
+
} else {
|
|
24
|
+
console.error(`Syntax error foude at '${gthActFileName}':`);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
} catch (error) {
|
|
28
|
+
console.error(`Error to read '${gthActFileName}':`);
|
|
29
|
+
console.error(error);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
export function verifyJsonSyntax(json) {
|
|
5
|
+
try {
|
|
6
|
+
const jsonString = typeof json !== "string" ? JSON.stringify(json) : json;
|
|
7
|
+
JSON.parse(json);
|
|
8
|
+
return true;
|
|
9
|
+
} catch (e) {
|
|
10
|
+
console.error({ e });
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './tokens.json'
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ethereal-design-tokens-teste",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"increase-version": "npm version minor -m 'chore(package): update version to %s [skip ci]' "
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/Ethereal-Design-System/ethereal-design-tokens-teste.git"
|
|
11
|
+
},
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public",
|
|
14
|
+
"registry": "https://registry.npmjs.org/"
|
|
15
|
+
},
|
|
16
|
+
"author": "",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/Ethereal-Design-System/ethereal-design-tokens-teste/issues"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/Ethereal-Design-System/ethereal-design-tokens-teste#readme",
|
|
22
|
+
"description": ""
|
|
23
|
+
}
|
|
24
|
+
|