Add initial JS setup

This commit is contained in:
Luc Perkins 2024-04-21 19:17:03 -03:00
parent cc5f064749
commit cf6776dfd1
No known key found for this signature in database
GPG key ID: 16DB1108FB591835
15 changed files with 4046 additions and 39 deletions

73
.eslintrc.json Normal file
View file

@ -0,0 +1,73 @@
{
"plugins": ["@typescript-eslint"],
"extends": ["plugin:github/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module",
"project": "./tsconfig.json"
},
"settings": {
"import/resolver": {
"typescript": {}
}
},
"rules": {
"i18n-text/no-en": "off",
"eslint-comments/no-use": "off",
"import/no-namespace": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_"
}
],
"@typescript-eslint/explicit-member-accessibility": [
"error",
{
"accessibility": "no-public"
}
],
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/ban-ts-comment": "error",
"camelcase": "error",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/explicit-function-return-type": [
"error",
{
"allowExpressions": true
}
],
"@typescript-eslint/func-call-spacing": ["error", "never"],
"@typescript-eslint/no-array-constructor": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-extraneous-class": "error",
"@typescript-eslint/no-for-in-array": "error",
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/no-unnecessary-qualifier": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/no-useless-constructor": "error",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-for-of": "warn",
"@typescript-eslint/prefer-function-type": "warn",
"@typescript-eslint/prefer-includes": "error",
"@typescript-eslint/prefer-string-starts-ends-with": "error",
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/require-array-sort-compare": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unbound-method": "error"
},
"env": {
"node": true,
"es6": true
}
}

View file

@ -2,7 +2,7 @@ name: update-flake-lock
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0'
- cron: "0 0 * * 0"
jobs:
lockfile:

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
# JS dependencies
node_modules/

5
.prettierignore Normal file
View file

@ -0,0 +1,5 @@
dist/
lib/
node_modules/
pnpm-lock.yaml
README.md

View file

@ -1,35 +1,35 @@
name: 'Update Nix Flake Lock'
description: 'Update your Nix flake.lock and send a PR'
name: "Update Nix Flake Lock"
description: "Update your Nix flake.lock and send a PR"
inputs:
inputs:
description: 'A space-separated list of inputs to update. Leave empty to update all inputs.'
description: "A space-separated list of inputs to update. Leave empty to update all inputs."
required: false
default: ''
default: ""
token:
description: 'GITHUB_TOKEN or a `repo` scoped Personal Access Token (PAT)'
description: "GITHUB_TOKEN or a `repo` scoped Personal Access Token (PAT)"
required: false
default: ${{ github.token }}
commit-msg:
description: 'The message provided with the commit'
description: "The message provided with the commit"
required: false
default: "flake.lock: Update"
base:
description: "Sets the pull request base branch. Defaults to the branch checked out in the workflow."
required: false
branch:
description: 'The branch of the PR to be created'
description: "The branch of the PR to be created"
required: false
default: "update_flake_lock_action"
path-to-flake-dir:
description: 'The path of the directory containing `flake.nix` file within your repository. Useful when `flake.nix` cannot reside at the root of your repository.'
description: "The path of the directory containing `flake.nix` file within your repository. Useful when `flake.nix` cannot reside at the root of your repository."
required: false
default: ''
default: ""
pr-title:
description: 'The title of the PR to be created'
description: "The title of the PR to be created"
required: false
default: "flake.lock: Update"
pr-body:
description: 'The body of the PR to be created'
description: "The body of the PR to be created"
required: false
default: |
Automated changes by the [update-flake-lock](https://github.com/DeterminateSystems/update-flake-lock) GitHub Action.
@ -53,58 +53,58 @@ inputs:
```
pr-labels:
description: 'A comma or newline separated list of labels to set on the Pull Request to be created'
description: "A comma or newline separated list of labels to set on the Pull Request to be created"
required: false
default: ''
default: ""
pr-assignees:
description: 'A comma or newline separated list of assignees (GitHub usernames).'
description: "A comma or newline separated list of assignees (GitHub usernames)."
required: false
default: ''
default: ""
pr-reviewers:
description: 'A comma or newline separated list of reviewers (GitHub usernames) to request a review from.'
description: "A comma or newline separated list of reviewers (GitHub usernames) to request a review from."
required: false
default: ''
default: ""
git-author-name:
description: 'Author name used for commit. Only used if sign-commits is false.'
description: "Author name used for commit. Only used if sign-commits is false."
required: false
default: 'github-actions[bot]'
default: "github-actions[bot]"
git-author-email:
description: 'Author email used for commit. Only used if sign-commits is false.'
description: "Author email used for commit. Only used if sign-commits is false."
required: false
default: 'github-actions[bot]@users.noreply.github.com'
default: "github-actions[bot]@users.noreply.github.com"
git-committer-name:
description: 'Committer name used for commit. Only used if sign-commits is false.'
description: "Committer name used for commit. Only used if sign-commits is false."
required: false
default: 'github-actions[bot]'
default: "github-actions[bot]"
git-committer-email:
description: 'Committer email used for commit. Only used if sign-commits is false.'
description: "Committer email used for commit. Only used if sign-commits is false."
required: false
default: 'github-actions[bot]@users.noreply.github.com'
default: "github-actions[bot]@users.noreply.github.com"
sign-commits:
description: 'Set to true if the action should sign the commit with GPG'
description: "Set to true if the action should sign the commit with GPG"
required: false
default: 'false'
default: "false"
gpg-private-key:
description: 'GPG Private Key with which to sign the commits in the PR to be created'
description: "GPG Private Key with which to sign the commits in the PR to be created"
required: false
default: ''
default: ""
gpg-fingerprint:
description: 'Fingerprint of specific GPG subkey to use'
description: "Fingerprint of specific GPG subkey to use"
required: false
gpg-passphrase:
description: 'GPG Private Key Passphrase for the GPG Private Key with which to sign the commits in the PR to be created'
description: "GPG Private Key Passphrase for the GPG Private Key with which to sign the commits in the PR to be created"
required: false
default: ''
default: ""
nix-options:
description: 'A space-separated list of options to pass to the nix command'
description: "A space-separated list of options to pass to the nix command"
required: false
default: ''
default: ""
outputs:
pull-request-number:
description: 'The number of the opened pull request'
description: "The number of the opened pull request"
value: ${{ steps.create-pr.outputs.pull-request-number }}
pull-request-operation:
description: 'The pull request operation performed by the action, `created`, `updated` or `closed`.'
description: "The pull request operation performed by the action, `created`, `updated` or `closed`."
value: ${{ steps.create-pr.outputs.pull-request-operation }}
runs:
using: "composite"
@ -172,8 +172,8 @@ runs:
- name: Interpolate PR Body
uses: pedrolamas/handlebars-action@v2.4.0
with:
files: 'pr_body.template'
output-filename: 'pr_body.txt'
files: "pr_body.template"
output-filename: "pr_body.txt"
- name: Read pr_body.txt
id: pr_body
uses: juliangruber/read-file-action@v1

2
dist/index.d.ts vendored Normal file
View file

@ -0,0 +1,2 @@
export { }

11
dist/index.js vendored Normal file
View file

@ -0,0 +1,11 @@
/******/ /* webpack/runtime/compat */
/******/
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = new URL('.', import.meta.url).pathname.slice(import.meta.url.match(/^file:\/\/\/\w:/) ? 1 : 0, -1) + "/";
/******/
/************************************************************************/
var __webpack_exports__ = {};
// src/index.ts
function main() {
}
main();
//# sourceMappingURL=index.js.map

1
dist/index.js.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["function main(): void {}\n\nmain();\n"],"mappings":";AAAA,SAAS,OAAa;AAAC;AAEvB,KAAK;","names":[]}

3
dist/package.json vendored Normal file
View file

@ -0,0 +1,3 @@
{
"type": "module"
}

45
package.json Normal file
View file

@ -0,0 +1,45 @@
{
"name": "update-flake-lock",
"version": "1.0.0",
"description": "",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"type": "module",
"scripts": {
"build": "tsup",
"format": "prettier --write .",
"lint": "eslint src/**/*.ts",
"package": "ncc build",
"all": "pnpm run format && pnpm run lint && pnpm run build && pnpm run package"
},
"repository": {
"type": "git",
"url": "git+https://github.com/DeterminateSystems/update-flake-lock.git"
},
"keywords": [],
"author": "",
"license": "MIT",
"bugs": {
"url": "https://github.com/DeterminateSystems/update-flake-lock/issues"
},
"homepage": "https://github.com/DeterminateSystems/update-flake-lock#readme",
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/exec": "^1.1.1",
"detsys-ts": "github:DeterminateSystems/detsys-ts"
},
"devDependencies": {
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/node": "^20.12.7",
"@typescript-eslint/eslint-plugin": "^7.7.0",
"@vercel/ncc": "^0.38.1",
"eslint": "^8.57.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-github": "^4.10.2",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.1.3",
"prettier": "^3.2.5",
"tsup": "^8.0.2",
"typescript": "^5.4.5"
}
}

3819
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load diff

12
prettier.config.cjs Normal file
View file

@ -0,0 +1,12 @@
/** @type {import('prettier').Config} */
module.exports = {
plugins: [require.resolve("@trivago/prettier-plugin-sort-imports")],
semi: true,
singleQuote: false,
tabWidth: 2,
trailingComma: "all",
useTabs: false,
// Import sorting
importOrderSeparation: true,
importOrderSortSpecifiers: true,
};

3
src/index.ts Normal file
View file

@ -0,0 +1,3 @@
function main(): void {}
main();

15
tsconfig.json Normal file
View file

@ -0,0 +1,15 @@
{
"compilerOptions": {
"target": "ES2020" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
"module": "Node16",
"moduleResolution": "NodeNext",
"outDir": "./dist",
"rootDir": "./src",
"strict": true /* Enable all strict type-checking options. */,
"noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */,
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
"resolveJsonModule": true,
"declaration": true
},
"exclude": ["node_modules", "**/*.test.ts", "dist"]
}

16
tsup.config.ts Normal file
View file

@ -0,0 +1,16 @@
import { name } from "./package.json";
import { defineConfig } from "tsup";
export default defineConfig({
name,
entry: ["src/index.ts"],
format: ["esm"],
target: "node20",
bundle: true,
splitting: false,
sourcemap: true,
clean: true,
dts: {
resolve: true,
},
});