Skip to content

Commit 1f47bc7

Browse files
authored
feat: added binaries package, migrate to monorepo (#22)
1 parent 037de2c commit 1f47bc7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+3320
-519
lines changed

README.md

+6-107
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,6 @@
1-
# buildstamp
2-
Utility for gathering build details
3-
# Installation
4-
```shell script
5-
yarn add buildstamp
6-
```
7-
```shell script
8-
npm i buildstamp
9-
```
10-
# Usage
11-
## CLI
12-
```shell script
13-
buildstamp --out.path=some/path/b.json --git --docker.imageTag=foo --date.format=iso
14-
```
15-
Output in `some/path/b.json`:
16-
```json
17-
{
18-
"timestamp": "2020-08-27T15:12:07.699Z",
19-
"gitInfo": {
20-
"commitId": "cd9660293d69a5ca7559197aedd1fa5de1a939fe",
21-
"repoName": "qiwi/buildstamp.git"
22-
}
23-
}
24-
```
25-
### Flags
26-
Output is always printed to stdout
27-
28-
| Option | Description | Default |
29-
|:--------------------|:--------------------------------------------------------|:---------------------------------------|
30-
| --out.path | path to generated file | output is not written to a file |
31-
| --out.jsonSeparator | one of `tab`, `space`, `double-space` | `tab` |
32-
| --git | add git data to output | git data is omitted |
33-
| --docker.imageTag | docker image tag, will be added to output, if exists | docker info is omitted |
34-
| --date.format | add date to output, one of `iso` or `instant` | date is omitted |
35-
| --date.value | any valid input for Date constructor | `Date.now()` |
36-
| --cwd | working directory | `process.cwd()` |
37-
38-
## API
39-
API functions accept the same options as cli
40-
### execute(options, env)
41-
Creates and returns buildstamp
42-
43-
Get buildstamp
44-
```javascript
45-
import { execute } from 'buildstamp'
46-
47-
const stamp = execute({
48-
git: true,
49-
date: { format: 'iso' },
50-
docker: { imageTag: 'foo', bar: 'bar'}
51-
})
52-
/*
53-
{
54-
git: {
55-
commitId: 'fc6e78b11ef4c7db1c8b89fa6b0d9b3ad4ad481d',
56-
repoName: 'qiwi/buildstamp.git'
57-
},
58-
docker: { imageTag: 'foo', bar: 'bar' },
59-
date: '2020-08-27T20:47:41.958Z'
60-
}
61-
*/
62-
```
63-
Write buildstamp to file
64-
```javascript
65-
import { execute } from 'buildstamp'
66-
67-
execute({
68-
git: true,
69-
date: { format: 'iso' },
70-
docker: { imageTag: 'foo', bar: 'bar'},
71-
out: {
72-
path: 'some/path/stamp.json'
73-
}
74-
})
75-
```
76-
Output in `some/path/stamp.json`:
77-
```json
78-
{
79-
"git": {
80-
"commitId": "19128459495e461b3c2b64704566f6aaac193ce1",
81-
"repoUrl": "https://github.com/qiwi/buildstamp.git",
82-
"repoName": "qiwi/buildstamp"
83-
},
84-
"docker": {
85-
"imageTag": "foo",
86-
"bar": "bar"
87-
},
88-
"date": "2020-09-04T19:53:03.790Z"
89-
}
90-
```
91-
### readBuildstamp(path)
92-
Safely parses and returns buildstamp by given path. Returns `undefined` on error.
93-
```javascript
94-
import { readBuildstamp } from 'buildstamp'
95-
96-
const stamp = getBuildstamp('some/path')
97-
/*
98-
{
99-
git: {
100-
commitId: 'fc6e78b11ef4c7db1c8b89fa6b0d9b3ad4ad481d',
101-
repoName: 'qiwi/buildstamp.git'
102-
},
103-
docker: { imageTag: 'foo', bar: 'bar' },
104-
date: '2020-08-27T20:47:41.958Z'
105-
}
106-
*/
107-
```
1+
# Buildstamp monorepo
2+
## Packages
3+
### core
4+
Package with buildstamp utility and API
5+
### binaries
6+
Buildstamp utility executables for different platforms

jest.config.json

+3-31
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,6 @@
11
{
2-
"transform": {
3-
"^.+\\.tsx?$": "ts-jest",
4-
"^.+\\.jsx?$": "@swissquote/crafty-preset-jest/src/esm-transformer"
5-
},
6-
"testEnvironment": "node",
72
"collectCoverage": true,
8-
"coveragePathIgnorePatterns": [],
9-
"collectCoverageFrom": [
10-
"<rootDir>/src/main/**/*.(j|t)s"
11-
],
12-
"testMatch": [
13-
"<rootDir>/src/test/js/**/*.js",
14-
"<rootDir>/src/test/ts/**/*.ts"
15-
],
16-
"testPathIgnorePatterns": [
17-
"/node_modules/",
18-
"<rootDir>/src/test/stub"
19-
],
20-
"moduleFileExtensions": [
21-
"ts",
22-
"tsx",
23-
"js",
24-
"jsx",
25-
"json",
26-
"node"
27-
],
28-
"globals": {
29-
"ts-jest": {
30-
"tsConfig": "<rootDir>/tsconfig.test.json"
31-
}
32-
}
33-
3+
"projects": [
4+
"<rootDir>/packages/core/jest.config.json"
5+
]
346
}

lerna.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"lerna": "2.2.0",
3+
"packages": [
4+
"packages/*"
5+
],
6+
"npmClient": "yarn",
7+
"useWorkspaces": true,
8+
"version": "1.0.0"
9+
}

package.json

+25-78
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,30 @@
11
{
2-
"name": "buildstamp",
3-
"version": "1.1.0",
4-
"private": false,
2+
"name": "buildstamp-monorepo",
3+
"version": "0.0.0",
4+
"private": true,
55
"publishConfig": {
66
"access": "public"
77
},
8-
"description": "Buildstamp",
9-
"source": "src/main/ts/index.ts",
10-
"main": "target/es5/index.js",
11-
"types": "typings/index.d.ts",
12-
"typescript": {
13-
"definition": "typings/index.d.ts"
14-
},
8+
"workspaces": [
9+
"packages/*"
10+
],
11+
"description": "Buildstamp monorepo",
1512
"scripts": {
16-
"lint": "eslint src/**/*.ts",
17-
"jest": "jest -w 1 --config=jest.config.json",
18-
"test": "yarn lint && yarn jest",
19-
"clean": "rimraf target typings flow-typed buildcache",
20-
"build": "yarn clean && yarn build:es5 && yarn build:es6 && yarn build:ts && yarn build:libdef && yarn docs",
21-
"build:es5": "mkdirp target/es5 && tsc -p tsconfig.es5.json",
22-
"build:es6": "mkdirp target/es6 && tsc -p tsconfig.es6.json",
23-
"build:ts": "cp -r src/main/ts/ target/ts/",
24-
"build:libdef": "libdefkit --tsconfig=tsconfig.es5.json --tsconfig=tsconfig.es6.json",
25-
"test:report": "yarn test && yarn push:report",
26-
"push:report": "yarn coveralls:push",
27-
"coveralls:push": "cat ./coverage/lcov.info | coveralls || exit 0",
28-
"docs": "typedoc --readme README.md --tsconfig tsconfig.json src/main --ignoreCompilerErrors || exit 0",
29-
"uglify": "for f in $(find target -name '*.js'); do short=${f%.js}; terser -c -m -o $short.js -- $f; done",
30-
"postupdate": "yarn && npx yarn-audit-fix && yarn build && yarn test",
31-
"format": "prettier --write \"src/**/*.ts\""
13+
"clean": "lerna clean --yes && lerna run clean",
14+
"build": "yarn clean && lerna run build --stream --concurrency 2",
15+
"bootstrap": "lerna bootstrap",
16+
"jest": "jest",
17+
"test": "yarn jest",
18+
"test:report": "yarn test && yarn coveralls:push",
19+
"test:concurrent": "lerna run test --concurrency 1 --stream --no-prefix && yarn coverage:merge",
20+
"coverage:merge": "node scripts/js/coverage-merge.js",
21+
"codeclimate:push": "codeclimate-test-reporter < ./coverage/lcov.info",
22+
"coveralls:push": "cat ./coverage/lcov.info | coveralls || echo 'coveralls push failed :(' && exit 0",
23+
"docs": "typedoc packages/**/src/main --ignoreCompilerErrors || exit 0",
24+
"postupdate": "yarn && yarn bootstrap && npx yarn-audit-fix && yarn build && yarn test",
25+
"release": "multi-semantic-release",
26+
"lint": "lerna run lint",
27+
"format": "lerna run format"
3228
},
3329
"repository": {
3430
"type": "git",
@@ -38,71 +34,22 @@
3834
"build-info",
3935
"buildstamp"
4036
],
41-
"files": [
42-
"README.md",
43-
"CHANGELOG.md",
44-
"target",
45-
"typings",
46-
"flow-typed"
47-
],
48-
"author": "Anton Golub <[email protected]>",
4937
"license": "MIT",
5038
"devDependencies": {
51-
"@qiwi/libdefkit": "^2.0.1",
5239
"@qiwi/license": "^1.1.3",
53-
"@qiwi/semantic-release-gh-pages-plugin": "^4.0.3",
54-
"@semantic-release/changelog": "^5.0.1",
55-
"@semantic-release/git": "^9.0.0",
56-
"@semantic-release/github": "^7.1.1",
57-
"@semantic-release/npm": "^7.0.6",
58-
"@swissquote/crafty-preset-jest": "^1.12.0",
59-
"@types/jest": "^26.0.14",
60-
"@types/mkdirp": "^1.0.1",
61-
"@types/node": "^14.11.2",
62-
"@types/rimraf": "^3.0.0",
40+
"@qiwi/multi-semantic-release": "^3.8.5",
6341
"@typescript-eslint/eslint-plugin": "^4.2.0",
6442
"@typescript-eslint/parser": "^4.2.0",
6543
"coveralls": "^3.1.0",
6644
"eslint": "^7.9.0",
6745
"eslint-config-qiwi": "^1.7.0",
6846
"jest": "^26.4.2",
47+
"lerna": "^3.22.1",
6948
"prettier": "^2.1.2",
7049
"rimraf": "^3.0.2",
71-
"semantic-release": "^17.1.2",
72-
"terser": "^5.3.2",
73-
"ts-jest": "^26.4.0",
74-
"tslint-config-qiwi": "^1.5.0",
75-
"typedoc": "^0.19.2",
76-
"typedoc-plugin-external-module-name": "^4.0.3",
7750
"typescript": "4.0.3"
7851
},
79-
"dependencies": {
80-
"find-git-root": "^1.0.4",
81-
"meow": "^7.1.1",
82-
"tslib": "^2.0.1"
83-
},
84-
"bin": {
85-
"buildstamp": "target/es5/cli.js"
86-
},
87-
"release": {
88-
"branch": "master",
89-
"verifyConditions": [
90-
"@semantic-release/changelog",
91-
"@semantic-release/npm",
92-
"@semantic-release/git",
93-
"@qiwi/semantic-release-gh-pages-plugin"
94-
],
95-
"prepare": [
96-
"@semantic-release/changelog",
97-
"@semantic-release/npm",
98-
"@semantic-release/git"
99-
],
100-
"publish": [
101-
"@semantic-release/npm",
102-
"@semantic-release/github",
103-
"@qiwi/semantic-release-gh-pages-plugin"
104-
]
105-
},
52+
"dependencies": {},
10653
"engines": {
10754
"node": ">=12.18.0"
10855
}

packages/bin/.releaserc

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"branch": "master",
3+
"verifyConditions": [
4+
"@semantic-release/changelog",
5+
"@semantic-release/npm",
6+
"@semantic-release/git"
7+
],
8+
"prepare": [
9+
"@semantic-release/changelog",
10+
"@semantic-release/npm",
11+
"@semantic-release/git"
12+
],
13+
"publish": [
14+
"@semantic-release/npm",
15+
"@semantic-release/github"
16+
]
17+
}

packages/bin/README.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# buildstamp-binaries
2+
Buildstamp binaries for MacOS, Linux and Windows
3+
4+
## Downloading
5+
Get download links
6+
```shell script
7+
curl https://registry.npmjs.org/buildstamp | grep -E -o 'https://registry.npmjs.org/buildstamp-bins/-/buildstamp-bins-\d+.\d+.\d+.tgz'
8+
```
9+
Download package by one of the links
10+
```shell script
11+
curl -o=buildstamp.tgz https://registry.npmjs.org/buildstamp-bins/-/buildstamp-bins-1.0.0.tgz
12+
```
13+
Extract binaries
14+
```shell script
15+
tar --extract --file buildstamp.tgz
16+
```

packages/bin/package.json

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "buildstamp-bin",
3+
"version": "0.0.0",
4+
"private": false,
5+
"publishConfig": {
6+
"access": "public"
7+
},
8+
"description": "Buildstamp binaries for MacOS, Linux and Windows",
9+
"scripts": {
10+
"clean": "rimraf target",
11+
"build:bins": "pkg --out-path=./target/bin --targets=node14-linux-x64,node14-macos-x64,node14-win-x64 ../core",
12+
"build": "yarn clean && yarn build:bins"
13+
},
14+
"repository": {
15+
"type": "git",
16+
"url": "https://github.com/qiwi/buildstamp.git"
17+
},
18+
"keywords": [
19+
"build-info",
20+
"buildstamp"
21+
],
22+
"files": [
23+
"README.md",
24+
"CHANGELOG.md",
25+
"target"
26+
],
27+
"license": "MIT",
28+
"devDependencies": {
29+
"pkg": "^4.4.9",
30+
"rimraf": "^3.0.2",
31+
"@semantic-release/changelog": "^5.0.1",
32+
"@semantic-release/git": "^9.0.0",
33+
"@semantic-release/github": "^7.1.1",
34+
"@semantic-release/npm": "^7.0.6"
35+
},
36+
"dependencies": {
37+
"buildstamp": "^1.0.4"
38+
}
39+
}

packages/core/.releaserc

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"branch": "master",
3+
"verifyConditions": [
4+
"@semantic-release/changelog",
5+
"@semantic-release/npm",
6+
"@semantic-release/git"
7+
],
8+
"prepare": [
9+
"@semantic-release/changelog",
10+
"@semantic-release/npm",
11+
"@semantic-release/git"
12+
],
13+
"publish": [
14+
"@semantic-release/npm",
15+
"@semantic-release/github"
16+
]
17+
}
File renamed without changes.

0 commit comments

Comments
 (0)