-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from stevent-team/feat/installable
Make library installable
- Loading branch information
Showing
15 changed files
with
1,647 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Changesets | ||
|
||
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works | ||
with multi-package repos, or single-package repos to help you version and publish your code. You can | ||
find the full documentation for it [in our repository](https://github.com/changesets/changesets) | ||
|
||
We have a quick list of common questions to get you started engaging with this project in | ||
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json", | ||
"changelog": "@changesets/cli/changelog", | ||
"commit": false, | ||
"fixed": [], | ||
"linked": [], | ||
"access": "public", | ||
"baseBranch": "main", | ||
"updateInternalDependencies": "patch", | ||
"ignore": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@stevent-team/favicon-scout": minor | ||
--- | ||
|
||
Add changesets for managing NPM releases |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@stevent-team/favicon-scout": major | ||
--- | ||
|
||
Favicon Scout released as a stable command line application! See the README for instructions on how to start the server and get those favicons. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"env": { | ||
"node": true | ||
}, | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": "latest", | ||
"sourceType": "module" | ||
}, | ||
"plugins": [ | ||
"@typescript-eslint" | ||
], | ||
"rules": { | ||
"@typescript-eslint/ban-ts-comment": "off", | ||
"indent": [ | ||
"error", | ||
2 | ||
], | ||
"linebreak-style": [ | ||
"error", | ||
"unix" | ||
], | ||
"quotes": [ | ||
"error", | ||
"single" | ||
], | ||
"semi": [ | ||
"error", | ||
"never" | ||
], | ||
"eqeqeq": 2, | ||
"no-return-await": 1, | ||
"no-var": 2, | ||
"prefer-const": 1, | ||
"yoda": 2, | ||
"no-trailing-spaces": 1, | ||
"eol-last": [1, "always"], | ||
"no-unused-vars": [ | ||
1, | ||
{ | ||
"args": "all", | ||
"argsIgnorePattern": "^_", | ||
"ignoreRestSiblings": true | ||
} | ||
], | ||
"arrow-parens": [ | ||
"error", | ||
"as-needed" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: ['main'] | ||
paths: | ||
- '**/package.json' | ||
- '.changeset/**' | ||
- '.github/workflows/release.yml' | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 17 | ||
cache: 'yarn' | ||
cache-dependency-path: '**/yarn.lock' | ||
- run: yarn install --immutable | ||
- uses: changesets/action@v1 | ||
with: | ||
publish: yarn ci:release | ||
commit: 'ci: release' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
/node_modules | ||
/dist | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.DS_Store | ||
.vscode | ||
/node_modules | ||
/test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,34 @@ | ||
import dotenv from 'dotenv' | ||
#!/usr/bin/env node | ||
import { InvalidArgumentError, program } from 'commander' | ||
import createApp from './server' | ||
import { version } from '../package.json' | ||
|
||
dotenv.config() | ||
const startServer = ({ port, host, origins }) => { | ||
// If origins is an array, transform regexes | ||
const origin: (string | RegExp)[] | string = Array.isArray(origins) ? origins.map(o => (o.startsWith('/') && o.endsWith('/')) ? new RegExp(o.slice(1,-1)) : o) : origins | ||
|
||
// Pull list of allowed origins from .env, default to * if not set | ||
const origin: (string | RegExp)[] | string = process.env.ALLOWED_ORIGINS?.split(',').map(o => o.trim()).map(o => (o.startsWith('/') && o.endsWith('/')) ? new RegExp(o.slice(1,-1)) : o) ?? '*' | ||
const port: number = parseInt(process.env.PORT ?? '3000') | ||
const app = createApp(origin) | ||
|
||
const app = createApp(origin) | ||
app.listen({ port, host }).then(() => { | ||
console.log(`🧭 Favicon Scout v${version} running at http://${host}:${port}`) | ||
console.log(`Allowing requests from: ${origin}`) | ||
}).catch(e => { | ||
app.log.error(e) | ||
process.exit(1) | ||
}) | ||
} | ||
|
||
app.listen({ port }).then(() => { | ||
console.log(`🧭 Favicon Scout v${version} running at http://localhost:${port}`) | ||
console.log(`Allowing requests from: ${origin}`) | ||
}).catch(e => { | ||
app.log.error(e) | ||
process.exit(1) | ||
}) | ||
program | ||
.name('favicon-scout') | ||
.description('Start a favicon scout web server') | ||
.version(version) | ||
.option('-p, --port <port>', 'port to use for http server', v => { | ||
const parsed = parseInt(v) | ||
if (isNaN(parsed)) throw new InvalidArgumentError('Not a valid number') | ||
return parsed | ||
}, 3000) | ||
.option('-h, --host <url>', 'host to use for http server', 'localhost') | ||
.option('-o, --origins <urls...>', 'urls or regexes allowed by CORS', '*') | ||
.action(startServer) | ||
|
||
program.parse() |
File renamed without changes.
Oops, something went wrong.