Skip to content

Commit

Permalink
chore: prepare sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
Airkro committed Oct 18, 2023
1 parent 071368d commit bae4ef7
Show file tree
Hide file tree
Showing 15 changed files with 341 additions and 99 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/bring-it.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
uses: airkro/bring-it@actions
with:
npm-token: ${{ secrets.NPM_TOKEN }}
publish-command: npx @bring-it/npm@0.2.10 npm
publish-command: npx @bring-it/npm@0.3.5 npm
custom-command: |
cd packages
mkdir -p sftp/dist
Expand All @@ -22,3 +22,5 @@ jobs:
touch $_/cli.mjs
mkdir -p sample/dist
touch $_/cli.mjs
mkdir -p sentry/dist
touch $_/cli.mjs
212 changes: 125 additions & 87 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
"packages/*"
],
"devDependencies": {
"@nice-move/cli": "^0.10.11",
"@nice-move/eslint-config-base": "^0.9.20",
"@nice-move/prettier-config": "^0.9.6",
"@nice-move/cli": "^0.10.13",
"@nice-move/eslint-config-base": "^0.9.22",
"@nice-move/prettier-config": "^0.9.7",
"best-shot": "^0.4.2",
"eslint": "^8.50.0",
"garou": "^0.6.14",
"playwright-core": "^1.38.1",
"eslint": "^8.51.0",
"garou": "^0.6.17",
"playwright-core": "^1.39.0",
"prettier": "^3.0.3"
},
"engines": {
Expand Down
1 change: 1 addition & 0 deletions packages/npm/lib/bin.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ new Cheetor('../package.json', import.meta.url)
.command(pack)
.command(npm)
.commandSafe('@bring-it/sample/dist/sub.mjs')
.commandSafe('@bring-it/sentry/dist/sub.mjs')
.commandSafe('@bring-it/sftp/dist/sub.mjs')
.config((cli) => cli.wrap(null))
.setup();
2 changes: 1 addition & 1 deletion packages/npm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bring-it/npm",
"version": "0.3.5",
"version": "0.3.6",
"description": "Publish npm packages when needed",
"license": "MIT",
"author": {
Expand Down
1 change: 1 addition & 0 deletions packages/sample/lib/bin.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ new Cheetor('../package.json', import.meta.url)
.command(pack)
.command(main)
.commandSafe('@bring-it/npm/dist/sub.mjs')
.commandSafe('@bring-it/sentry/dist/sub.mjs')
.commandSafe('@bring-it/sftp/dist/sub.mjs')
.config((cli) => cli.wrap(null))
.setup();
11 changes: 8 additions & 3 deletions packages/sample/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bring-it/sample",
"version": "0.2.3",
"version": "0.2.4",
"description": "Generate code sample files",
"license": "MIT",
"author": {
Expand Down Expand Up @@ -43,10 +43,15 @@
"devDependencies": {
"@bring-it/utils": "*",
"cheetor": "^0.13.0",
"globby": "^13.2.1"
"globby": "^13.2.2"
},
"peerDependencies": {
"playwright-core": "^1.33.0"
"playwright-core": "^1.39.0"
},
"peerDependenciesMeta": {
"playwright-core": {
"optional": true
}
},
"engines": {
"node": "^16.15.0 || ^18.0.0",
Expand Down
15 changes: 15 additions & 0 deletions packages/sentry/.best-shot/config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export const config = {
target: 'node16',
output: {
path: 'dist',
module: true,
},
entry: {
cli: './lib/bin.mjs',
sub: './lib/cmd.mjs',
},
externals: {
yargs: 'yargs',
'@sentry/cli': '@sentry/cli',
},
};
34 changes: 34 additions & 0 deletions packages/sentry/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# @bring-it/sentry

Update sentry artifacts.

[![npm][npm-badge]][npm-url]
[![github][github-badge]][github-url]
![node][node-badge]

[npm-url]: https://www.npmjs.com/package/@bring-it/sentry
[npm-badge]: https://img.shields.io/npm/v/@bring-it/sentry.svg?style=flat-square&logo=npm
[github-url]: https://github.com/airkro/bring-it/tree/master/packages/sentry
[github-badge]: https://img.shields.io/npm/l/@bring-it/sentry.svg?style=flat-square&colorB=blue&logo=github
[node-badge]: https://img.shields.io/node/v/@bring-it/sentry.svg?style=flat-square&colorB=green&logo=node.js

## Installation

```bash
npm install @bring-it/sentry @sentry/cli -g
```

## Usage

```bash
npm x bring-it sentry
```

## Config

```jsonc
// .bring-it/sentry.config.json
{
"*": {}
}
```
13 changes: 13 additions & 0 deletions packages/sentry/lib/bin.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as pack from '@bring-it/utils/cmd/pack.mjs';
import { Cheetor } from 'cheetor';

import * as main from './cmd.mjs';

new Cheetor('../package.json', import.meta.url)
.command(pack)
.command(main)
.commandSafe('@bring-it/npm/dist/sub.mjs')
.commandSafe('@bring-it/sample/dist/sub.mjs')
.commandSafe('@bring-it/sftp/dist/sub.mjs')
.config((cli) => cli.wrap(null))
.setup();
23 changes: 23 additions & 0 deletions packages/sentry/lib/cmd.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { action } from './utils.mjs';

export const command = 'sentry';

export const describe = 'Update sentry artifacts';

export function builder(cli) {
cli
.option('config', {
describe: 'Config file path',
default: '.bring-it/sentry.config.json',
type: 'string',
})
.option('mode', {
describe: 'deploy mode',
default: 'development',
type: 'string',
});
}

export function handler(io) {
action(io).catch(console.error);
}
45 changes: 45 additions & 0 deletions packages/sentry/lib/utils.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { execFileSync } from 'node:child_process';
import { readFile } from 'node:fs/promises';

import { Logger } from '@bring-it/utils';

const logger = new Logger('sentry');

function commitHash() {
return execFileSync('git', ['rev-parse', '--short', 'HEAD'], {
encoding: 'utf8',
}).trim();
}

function readConfig(configName) {
return readFile(configName, 'utf8')
.then((text) => JSON.parse(text))
.catch((error) => {
logger.warn(error.message);
logger.info('Fallback to default configuration');

return {};
});
}

export async function action({ config, mode }) {
const { '*': all, [mode]: current } = await readConfig(config);

const { url, org, project, authToken, globs } = { ...all, ...current };

const io = {
url,
org,
project,
authToken,
globs,
release: {
name: commitHash(),
deploy: {
env: mode,
},
},
};

console.log(io);
}
64 changes: 64 additions & 0 deletions packages/sentry/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"private": true,
"name": "@bring-it/sentry",
"version": "0.0.0-beta",
"description": "Update sentry artifacts",
"license": "MIT",
"author": {
"name": "Eric Chen",
"email": "[email protected]"
},
"keywords": [
"bring-it",
"ci",
"cli",
"code",
"sentry",
"sourcemap",
"sourcemaps"
],
"homepage": "https://github.com/airkro/bring-it/tree/master/packages/sentry",
"repository": {
"type": "git",
"url": "https://github.com/airkro/bring-it.git",
"directory": "packages/sentry"
},
"bugs": {
"url": "https://github.com/airkro/bring-it/issues"
},
"bin": {
"bring-it": "dist/cli.mjs"
},
"files": [
"dist"
],
"type": "module",
"scripts": {
"build": "best-shot prod",
"prepublishOnly": "npm run build"
},
"dependencies": {
"yargs": "^17.7.2"
},
"devDependencies": {
"@bring-it/utils": "*",
"cheetor": "^0.13.0",
"globby": "^13.2.2"
},
"peerDependencies": {
"@sentry/cli": "^2.21.2"
},
"peerDependenciesMeta": {
"@sentry/cli": {
"optional": true
}
},
"engines": {
"node": "^16.15.0 || ^18.0.0",
"npm": ">=9.4.0"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
}
}
1 change: 1 addition & 0 deletions packages/sftp/lib/bin.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ new Cheetor('../package.json', import.meta.url)
.command(main)
.commandSafe('@bring-it/npm/dist/sub.mjs')
.commandSafe('@bring-it/sample/dist/sub.mjs')
.commandSafe('@bring-it/sentry/dist/sub.mjs')
.config((cli) => cli.wrap(null))
.setup();
2 changes: 1 addition & 1 deletion packages/sftp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bring-it/sftp",
"version": "0.1.4",
"version": "0.1.5",
"description": "SFTP deployment tool for frontend",
"license": "MIT",
"author": {
Expand Down

0 comments on commit bae4ef7

Please sign in to comment.