Skip to content

Commit

Permalink
feat: Add script to check if packages pass publint (#523)
Browse files Browse the repository at this point in the history
* Add zod schemas for CI validation

* Require npm field for components.json

* Remove svelte-layout-resizable

* Stricter Zod validation

* Stricter repository field validation

* Implement requested changes

* Add back accidentally removed field

* Move SvelteStore to templates.json

* Update category and tags

* Add script to get npm data

* Add script to get publint data

* Re-run updateNpm.js

* Re-run updatePublint.js

* Implement initial feedback

* Use npm.json data

* Update npm.js

* Switch async/await to then/catch

Co-authored-by: MacFJA <[email protected]>

* Fix prettier

* Run script

* Re-run updateNpm

* Also read tools.json

* Add @types/node

* Restructure npm.json output

* Fix updatePublint.js

* Display last update on components page

* Add to weekly workflow

* Clarify updating npm data

* Update src/lib/utils/injectNpmData.ts

Co-authored-by: MacFJA <[email protected]>

* Smaller date font, add version

* Improve error text

* Fix property title

* Move json to lib/data directory

* Fix npm.json path

* Also check tools.json

* Add to automated PR

* Add injectPublintData function

* Update publint

---------

Co-authored-by: MacFJA <[email protected]>
  • Loading branch information
lachlancollins and MacFJA authored Dec 18, 2023
1 parent 02dc9df commit 156f654
Show file tree
Hide file tree
Showing 10 changed files with 894 additions and 4 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/fetch-latest-data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Update npm data
run: node scripts/updateNpm.js
- name: Update publint data
run: node scripts/updatePublint.js
- name: Run format
run: pnpm run format
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
commit-message: "(AUTO) Update data"
title: "🤖 Update data"
body: Automatically fetch latest data from NPM, GitHub and GitLab
body: Automatically fetch latest data from GitHub, GitLab, NPM and Publint.
branch: ci-update-data
add-paths: src/lib/data/npm.json,src/lib/data/stars.json
add-paths: src/lib/data/npm.json,src/lib/data/publint.json,src/lib/data/stars.json
delete-branch: true
token: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.35.1",
"get-npm-tarball-url": "^2.1.0",
"highlight.js": "^11.9.0",
"itemsjs": "^2.1.24",
"mdsvex": "^0.11.0",
"package-name-regex": "^3.1.1",
"pako": "^2.1.0",
"prettier": "^3.1.1",
"prettier-plugin-svelte": "^3.1.2",
"publint": "^0.2.6",
"rehype-slug": "^6.0.0",
"svelte": "^4.2.8",
"svelte-check": "^3.6.2",
Expand Down
82 changes: 82 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions scripts/tarball.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// @ts-check
// Source: https://github.com/bluwy/publint/blob/master/site/src/utils/tarball.js

/** @typedef {{ name: string, buffer: ArrayBuffer }} TarballFile */

/**
* @param {TarballFile[]} files
* @return {import('publint').Vfs}
* */
export function createTarballVfs(files) {
return {
getDirName: (path) => path.replace(/\/[^/]*$/, ''),
getExtName: (path) => path.replace(/^.*\./, '.'),
isPathDir: async (path) => {
path = path.endsWith('/') ? path : path + '/';
return files.some((file) => file.name.startsWith(path));
},
isPathExist: async (path) => {
const pathDirVariant = path.endsWith('/') ? path : path + '/';
return files.some((file) => file.name === path || file.name.startsWith(pathDirVariant));
},
pathJoin: (...parts) =>
parts
.map((v) => (v.startsWith('./') ? v.slice(2) : v))
.join('/')
.replace('///', '/')
.replace('//', '/'), // TODO: optimize this please
pathRelative: (from, to) => to.replace(from, '').slice(1),
readDir: async (path) => {
path = path.endsWith('/') ? path : path + '/';
return files
.filter((file) => file.name.startsWith(path) && file.name !== path)
.map((file) => file.name.slice(path.length));
},
readFile: async (path) => {
const file = files.find((file) => file.name === path);
if (file) {
return new TextDecoder('utf-8').decode(file.buffer);
} else {
throw new Error(`Unable to read file at path: ${path}`);
}
}
};
}
Loading

0 comments on commit 156f654

Please sign in to comment.