From 6ac9d260a29555ac040134c4e0ab5c3c20e41bf2 Mon Sep 17 00:00:00 2001 From: Artak Date: Tue, 18 Jun 2024 23:26:21 +0400 Subject: [PATCH] init --- .editorconfig | 22 +++++++++ .github/lock.yml | 26 +++++++++++ .github/stale.yml | 24 ++++++++++ .github/workflows/test.yml | 60 +++++++++++++++++++++++++ .gitignore | 14 ++++++ .npmrc | 1 + .prettierignore | 4 ++ LICENSE.md | 9 ++++ README.md | 7 +++ bin/test.ts | 11 +++++ configure.ts | 17 +++++++ index.ts | 10 +++++ package.json | 91 ++++++++++++++++++++++++++++++++++++++ providers/README.md | 5 +++ stubs/README.md | 6 +++ stubs/main.ts | 8 ++++ tests/example.spec.ts | 7 +++ tsconfig.json | 7 +++ tsnode.esm.js | 18 ++++++++ 19 files changed, 347 insertions(+) create mode 100644 .editorconfig create mode 100644 .github/lock.yml create mode 100644 .github/stale.yml create mode 100644 .github/workflows/test.yml create mode 100644 .gitignore create mode 100644 .npmrc create mode 100644 .prettierignore create mode 100644 LICENSE.md create mode 100644 README.md create mode 100644 bin/test.ts create mode 100644 configure.ts create mode 100644 index.ts create mode 100644 package.json create mode 100644 providers/README.md create mode 100644 stubs/README.md create mode 100644 stubs/main.ts create mode 100644 tests/example.spec.ts create mode 100644 tsconfig.json create mode 100644 tsnode.esm.js diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..1dfdf29 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,22 @@ +# http://editorconfig.org + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.json] +insert_final_newline = ignore + +[**.min.js] +indent_style = ignore +insert_final_newline = ignore + +[MakeFile] +indent_style = space + +[*.md] +trim_trailing_whitespace = false diff --git a/.github/lock.yml b/.github/lock.yml new file mode 100644 index 0000000..ea7cf67 --- /dev/null +++ b/.github/lock.yml @@ -0,0 +1,26 @@ +--- +ignoreUnless: {{ STALE_BOT }} +--- +# Configuration for Lock Threads - https://github.com/dessant/lock-threads-app + +# Number of days of inactivity before a closed issue or pull request is locked +daysUntilLock: 60 + +# Skip issues and pull requests created before a given timestamp. Timestamp must +# follow ISO 8601 (`YYYY-MM-DD`). Set to `false` to disable +skipCreatedBefore: false + +# Issues and pull requests with these labels will be ignored. Set to `[]` to disable +exemptLabels: ['Type: Security'] + +# Label to add before locking, such as `outdated`. Set to `false` to disable +lockLabel: false + +# Comment to post before locking. Set to `false` to disable +lockComment: > + This thread has been automatically locked since there has not been + any recent activity after it was closed. Please open a new issue for + related bugs. + +# Assign `resolved` as the reason for locking. Set to `false` to disable +setLockReason: false diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 0000000..d21cf6c --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,24 @@ +--- +ignoreUnless: {{ STALE_BOT }} +--- +# Number of days of inactivity before an issue becomes stale +daysUntilStale: 60 + +# Number of days of inactivity before a stale issue is closed +daysUntilClose: 7 + +# Issues with these labels will never be considered stale +exemptLabels: + - 'Type: Security' + +# Label to use when marking an issue as stale +staleLabel: 'Status: Abandoned' + +# Comment to post when marking an issue as stale. Set to `false` to disable +markComment: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. Thank you + for your contributions. + +# Comment to post when closing a stale issue. Set to `false` to disable +closeComment: false diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..6e82cdd --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,60 @@ +name: test + +on: + - push + - pull_request + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install + run: npm install + - name: Run lint + run: npm run lint + + typecheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install + run: npm install + - name: Run typecheck + run: npm run typecheck + + tests: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + node-version: + - 20.10.0 + - 21.x + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: Install + run: npm install + - name: Run tests + run: npm test + windows: + runs-on: windows-latest + strategy: + matrix: + node-version: + - 20.10.0 + - 21.x + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: Install + run: npm install + - name: Run tests + run: npm test diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..966cd35 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +node_modules +coverage +.DS_STORE +.nyc_output +.idea +.vscode/ +*.sublime-project +*.sublime-workspace +*.log +build +dist +yarn.lock +shrinkwrap.yaml +package-lock.json diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..43c97e7 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..da1f07a --- /dev/null +++ b/.prettierignore @@ -0,0 +1,4 @@ +build +docs +coverage +*.html diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..1bb5ef3 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,9 @@ +# The MIT License + +Copyright (c) 2023 + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..7748e7d --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# AdonisJS activity log + + + + +### License +MIT diff --git a/bin/test.ts b/bin/test.ts new file mode 100644 index 0000000..7978bf2 --- /dev/null +++ b/bin/test.ts @@ -0,0 +1,11 @@ +import { assert } from '@japa/assert' +import { configure, processCLIArgs, run } from '@japa/runner' + +processCLIArgs(process.argv.splice(2)) + +configure({ + files: ['tests/**/*.spec.ts'], + plugins: [assert()], +}) + +run() diff --git a/configure.ts b/configure.ts new file mode 100644 index 0000000..4982733 --- /dev/null +++ b/configure.ts @@ -0,0 +1,17 @@ +/* +|-------------------------------------------------------------------------- +| Configure hook +|-------------------------------------------------------------------------- +| +| The configure hook is called when someone runs "node ace configure " +| command. You are free to perform any operations inside this function to +| configure the package. +| +| To make things easier, you have access to the underlying "ConfigureCommand" +| instance and you can use codemods to modify the source files. +| +*/ + +import ConfigureCommand from '@adonisjs/core/commands/configure' + +export async function configure(_command: ConfigureCommand) {} diff --git a/index.ts b/index.ts new file mode 100644 index 0000000..5843ae1 --- /dev/null +++ b/index.ts @@ -0,0 +1,10 @@ +/* +|-------------------------------------------------------------------------- +| Package entrypoint +|-------------------------------------------------------------------------- +| +| Export values from the package entrypoint as you see fit. +| +*/ + +export { configure } from './configure.js' diff --git a/package.json b/package.json new file mode 100644 index 0000000..e203301 --- /dev/null +++ b/package.json @@ -0,0 +1,91 @@ +{ + "name": "@holoyan/adonis-activitylog", + "description": "AdonisJs activity log", + "version": "0.0.0", + "engines": { + "node": ">=20.6.0" + }, + "type": "module", + "files": [ + "build/src", + "build/providers", + "build/stubs", + "build/index.d.ts", + "build/index.js", + "build/configure.d.ts", + "build/configure.js" + ], + "exports": { + ".": "./build/index.js", + "./types": "./build/src/types.js" + }, + "scripts": { + "clean": "del-cli build", + "copy:templates": "copyfiles \"stubs/**/*.stub\" build", + "typecheck": "tsc --noEmit", + "lint": "eslint . --ext=.ts", + "format": "prettier --write .", + "quick:test": "node --import=./tsnode.esm.js --enable-source-maps bin/test.ts", + "pretest": "npm run lint", + "test": "c8 npm run quick:test", + "prebuild": "npm run lint && npm run clean", + "build": "tsc", + "postbuild": "npm run copy:templates", + "release": "np", + "version": "npm run build", + "prepublishOnly": "npm run build" + }, + "keywords": [], + "author": "", + "license": "MIT", + "devDependencies": { + "@adonisjs/assembler": "^7.2.3", + "@adonisjs/core": "^6.3.1", + "@adonisjs/eslint-config": "^1.3.0", + "@adonisjs/lucid": "^21.0.0", + "@adonisjs/prettier-config": "^1.3.0", + "@adonisjs/tsconfig": "^1.3.0", + "@japa/assert": "^2.1.0", + "@japa/runner": "^3.1.1", + "@swc/core": "^1.4.6", + "@types/luxon": "^3.4.2", + "@types/node": "^20.11.25", + "c8": "^9.1.0", + "copyfiles": "^2.4.1", + "del-cli": "^5.1.0", + "eslint": "^8.57.0", + "luxon": "^3.4.4", + "np": "^10.0.0", + "prettier": "^3.2.5", + "ts-node": "^10.9.2", + "typescript": "^5.4.2" + }, + "peerDependencies": { + "@adonisjs/core": "^6.2.0", + "@adonisjs/lucid": "^21.0.0", + "luxon": "^3.4.4" + }, + "publishConfig": { + "access": "public", + "tag": "latest" + }, + "np": { + "message": "chore(release): %s", + "tag": "latest", + "branch": "main", + "anyBranch": false + }, + "c8": { + "reporter": [ + "text", + "html" + ], + "exclude": [ + "tests/**" + ] + }, + "eslintConfig": { + "extends": "@adonisjs/eslint-config/package" + }, + "prettier": "@adonisjs/prettier-config" +} diff --git a/providers/README.md b/providers/README.md new file mode 100644 index 0000000..ac2ab06 --- /dev/null +++ b/providers/README.md @@ -0,0 +1,5 @@ +# The providers directory + +The `providers` directory contains the service providers exported by your application. Make sure to register these providers within the `exports` collection (aka package entrypoints) defined within the `package.json` file. + +Learn more about [package entrypoints](https://nodejs.org/api/packages.html#package-entry-points). diff --git a/stubs/README.md b/stubs/README.md new file mode 100644 index 0000000..4dd2dac --- /dev/null +++ b/stubs/README.md @@ -0,0 +1,6 @@ +# The stubs directory + +The `stubs` directory stores all the stubs needed by your package. It could be config files you will publish during the initial setup or stubs you want to use within the scaffolding commands. + +- Inside the `package.json` file, we have defined a `copy:templates` script that copies the `stubs` folder to the `build` folder. +- Ensure the `build/stubs` are always published to npm via the `files` array inside the `package.json` file. diff --git a/stubs/main.ts b/stubs/main.ts new file mode 100644 index 0000000..361d6cd --- /dev/null +++ b/stubs/main.ts @@ -0,0 +1,8 @@ +import { dirname } from 'node:path' +import { fileURLToPath } from 'node:url' + +/** + * Path to the root directory where the stubs are stored. We use + * this path within commands and the configure hook + */ +export const stubsRoot = dirname(fileURLToPath(import.meta.url)) diff --git a/tests/example.spec.ts b/tests/example.spec.ts new file mode 100644 index 0000000..893ea1a --- /dev/null +++ b/tests/example.spec.ts @@ -0,0 +1,7 @@ +import { test } from '@japa/runner' + +test.group('Example', () => { + test('add two numbers', ({ assert }) => { + assert.equal(1 + 1, 2) + }) +}) diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..0cfd318 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "@adonisjs/tsconfig/tsconfig.package.json", + "compilerOptions": { + "rootDir": "./", + "outDir": "./build", + } +} diff --git a/tsnode.esm.js b/tsnode.esm.js new file mode 100644 index 0000000..0cce922 --- /dev/null +++ b/tsnode.esm.js @@ -0,0 +1,18 @@ +/* +|-------------------------------------------------------------------------- +| TS-Node ESM hook +|-------------------------------------------------------------------------- +| +| Importing this file before any other file will allow you to run TypeScript +| code directly using TS-Node + SWC. For example +| +| node --import="./tsnode.esm.js" bin/test.ts +| node --import="./tsnode.esm.js" index.ts +| +| +| Why not use "--loader=ts-node/esm"? +| Because, loaders have been deprecated. +*/ + +import { register } from 'node:module' +register('ts-node/esm', import.meta.url)