Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
chore: init project
Browse files Browse the repository at this point in the history
  • Loading branch information
norskeld committed Apr 14, 2023
0 parents commit 30e2e79
Show file tree
Hide file tree
Showing 25 changed files with 19,527 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
coverage
dist
27 changes: 27 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"env": {
"node": true
},
"rules": {
"semi": ["error", "never"],
"quotes": ["error", "single", { "allowTemplateLiterals": true }],
"no-constant-condition": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
"args": "after-used",
"argsIgnorePattern": "_",
"varsIgnorePattern": "_"
}
]
}
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.husky/* linguist-detectable=false
29 changes: 29 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: release

on:
workflow_run:
workflows: ['test']
branches: [master]
types: [completed]

jobs:
release:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use Node Active LTS
uses: actions/setup-node@v2
with:
node-version: '16'
cache: 'npm'
- name: Install Deps
run: npm ci
- name: Build & Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npm run build
npm run release
24 changes: 24 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: test

on:
push:
pull_request:
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use Node Active LTS
uses: actions/setup-node@v2
with:
node-version: '16'
cache: 'npm'
- name: Install Deps
run: npm ci
- name: Build & Test
run: |
npm run build
npm run test
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
node_modules
dist

# macOS
.DS_Store

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Editor directories & files
.idea

# Coverage reports
coverage

# NPM
.npm

# Dotenv files
.env.local
.env.*.local
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install commitlint --edit "$1"
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install lint-staged
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
registry=https://registry.npmjs.org
access=public
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
coverage
dist
16 changes: 16 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"semi": false,
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"trailingComma": "none",
"overrides": [
{
"files": ["*.ts"],
"options": {
"parser": "typescript"
}
}
]
}
22 changes: 22 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "angular",
"releaseRules": [{ "scope": "no-release", "release": false }]
}
],
"@semantic-release/release-notes-generator",
["@semantic-release/changelog", { "changelogFile": "CHANGELOG.md" }],
["@semantic-release/npm", { "pkgRoot": "dist" }],
[
"@semantic-release/git",
{
"assets": ["package.json", "package-lock.json", "CHANGELOG.md"],
"message": "chore(release): release ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
],
"@semantic-release/github"
]
}
102 changes: 102 additions & 0 deletions .scripts/release.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import { access, copyFile } from 'fs/promises'
import { constants } from 'fs'
import { resolve } from 'path'

interface Success {
kind: 'success'
message: string
}

interface Failure {
kind: 'failure'
reason: string
}

type Result = Success | Failure
type Actions = Record<string, () => Promise<Result>>

async function actions(actions: Actions): Promise<Result> {
const [passed] = process.argv.slice(2)
const resolved = actions[passed]

if (resolved) {
return await resolved()
}

return {
kind: 'failure',
reason: `Action '${passed}' is not defined.`
}
}

async function run(result: Result) {
switch (result.kind) {
case 'success': {
console.log(result.message)
return
}

case 'failure': {
console.error(result.reason)
process.exit(1)
}
}
}

async function main() {
const cwd = process.cwd()

await run(
await actions({
/** This should be called in `prerelease`. */
async prepare() {
try {
// Just double-check for `dist` directory.
await access(`${cwd}/package.json`, constants.F_OK)

// Copy necessary files.
await copyFile(`${cwd}/package.json`, `${cwd}/dist/package.json`)
await copyFile(`${cwd}/package-lock.json`, `${cwd}/dist/package-lock.json`)
await copyFile(`${cwd}/CHANGELOG.md`, `${cwd}/dist/CHANGELOG.md`)
await copyFile(`${cwd}/README.md`, `${cwd}/dist/README.md`)
await copyFile(`${cwd}/LICENSE`, `${cwd}/dist/LICENSE`)

// This is kinda needed for local publishes to `verdaccio`, so I do not accidentally
// publish my experiments to the actual `npm` registry.
await copyFile(`${cwd}/.npmrc`, `${cwd}/dist/.npmrc`)

return {
kind: 'success',
message: 'Successfully prepared files for a release.'
}
} catch (error) {
return {
kind: 'failure',
reason: (error as Error).message
}
}
},

/** This should be called in `postversion`. Here we actually are inside the `dist`. */
async restore() {
try {
// Copy back.
await copyFile(`${cwd}/package.json`, resolve(cwd, '..', 'package.json'))
await copyFile(`${cwd}/package-lock.json`, resolve(cwd, '..', 'package-lock.json'))

return {
kind: 'success',
message: 'Successfully restored `package.json`.'
}
} catch (error) {
return {
kind: 'failure',
reason: (error as Error).message
}
}
}
})
)
}

main()
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"EditorConfig.EditorConfig"
]
}
15 changes: 15 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"typescript.tsdk": "node_modules/typescript/lib",
"editor.rulers": [100],
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"json.schemas": [
{
"fileMatch": ["/.prettierrc", "/.prettierrc.json"],
"url": "http://json.schemastore.org/prettierrc"
}
]
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Vladislav Mamon

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.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# astrowind

[![Build/Test](https://img.shields.io/github/actions/workflow/status/norskeld/astrowind/test.yml?style=flat-square&colorA=22272d&colorB=22272d)](https://github.com/norskeld/astrowind/actions 'Build and test workflows')
[![NPM](https://img.shields.io/npm/v/@nrsk/astrowind?style=flat-square&colorA=22272d&colorB=22272d)](https://npm.im/@nrsk/astrowind 'This package on NPM')
[![Supported Node Versions](https://img.shields.io/static/v1?label=node&message=14+|+16+|+18&style=flat-square&colorA=22272d&colorB=22272d)](https://github.com/norskeld/astrowind/blob/master/package.json#L35 'Supported Node versions')
[![Semantic Release](https://img.shields.io/static/v1?label=semantic+release&message=✔&style=flat-square&colorA=22272d&colorB=22272d)](https://github.com/semantic-release/semantic-release 'This package uses semantic release to handle releasing, versioning, changelog generation and tagging')

Tailwind integration for Astro with support for TS configs.

## License

[MIT](LICENSE).

0 comments on commit 30e2e79

Please sign in to comment.