-
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.
- Loading branch information
0 parents
commit ad0345b
Showing
18 changed files
with
4,616 additions
and
0 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,48 @@ | ||
# | ||
# DO NOT MODIFY, WILL BE OVERWRITTEN BY @naturalcycles/dev-lib | ||
# | ||
# http://editorconfig.org | ||
# | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[**.md] | ||
trim_trailing_whitespace = false | ||
indent_size = 4 | ||
|
||
[**.html] | ||
indent_size = 2 | ||
|
||
[**.{css,scss}] | ||
indent_size = 2 | ||
|
||
[**.{js,ts}] | ||
indent_size = 2 | ||
|
||
[**.json] | ||
indent_size = 2 | ||
|
||
[**.xml] | ||
indent_size = 2 | ||
|
||
[**.java] | ||
indent_size = 4 | ||
|
||
[**.sql] | ||
indent_size = 2 | ||
|
||
[.eslintrc] | ||
indent_size = 2 | ||
|
||
[**.min.*] | ||
indent_style = ignore | ||
trim_trailing_whitespace = false | ||
insert_final_newline = 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,32 @@ | ||
name: release | ||
|
||
on: | ||
push: | ||
branches: [master, next, act] | ||
|
||
jobs: | ||
release-job: | ||
runs-on: ubuntu-latest | ||
if: "!contains(github.event.head_commit.message, 'skip ci')" | ||
env: { NODE_OPTIONS: '--max-old-space-size=3200' } | ||
steps: | ||
- { uses: actions/checkout@v2, with: { persist-credentials: true } } | ||
- { uses: actions/setup-node@v2, with: { node-version: 16 } } | ||
|
||
# Cache for npm/npx in ~/.npm | ||
- uses: actions/cache@v2 | ||
with: | ||
path: ~/.npm | ||
key: npm-v1-${{ runner.os }} | ||
|
||
- name: yarn | ||
run: yarn --frozen-lockfile | ||
|
||
- name: build | ||
run: yarn build-prod | ||
|
||
- name: release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
run: npx @naturalcycles/semantic-release |
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,53 @@ | ||
# | ||
# DO NOT MODIFY, WILL BE OVERWRITTEN BY @naturalcycles/dev-lib | ||
# | ||
# You can put more .gitignore files in your respective subfolders (e.g `src`) to ignore additional things. | ||
# Or PR to @naturalcycles/dev-lib if you want to ignore something generic. | ||
# | ||
|
||
# | ||
# Global (all dirs) | ||
# | ||
*.iml | ||
.idea | ||
.DS_Store | ||
node_modules | ||
.env | ||
.npmrc | ||
.classpath | ||
.project | ||
.settings | ||
.externalToolBuilders | ||
.cache | ||
.stencil | ||
.gitconfig | ||
.lighthouseci | ||
|
||
# | ||
# Root dir | ||
# | ||
/target | ||
/*.log | ||
/log.txt | ||
/.sass-cache | ||
/.sourcemaps | ||
/docs/.vuepress/dist | ||
|
||
/coverage | ||
/report | ||
|
||
/dist | ||
/dist-cjs | ||
/dist-esm | ||
/tmp | ||
|
||
# All secrets are ignored, except encrypted | ||
/secret/**/*.* | ||
!/secret/**/*.enc | ||
|
||
/scripts/try.* | ||
/logs | ||
/platforms | ||
/plugins | ||
/www/* | ||
!/www/.gitkeep |
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,6 @@ | ||
#!/bin/sh | ||
[ -n "$CI" ] && exit 0 | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
node_modules/.bin/commitlint-def $1 | ||
# exit 1 # uncomment to debug |
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 @@ | ||
#!/bin/sh | ||
[ -n "$CI" ] && exit 0 | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
node_modules/.bin/lint-staged-def |
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,49 @@ | ||
{ | ||
"name": "@naturalcycles/ktlint", | ||
"scripts": { | ||
"prepare": "husky install", | ||
"_postinstall": "node dist/install.js", | ||
"prepublishOnly": "pinst --enable", | ||
"postpublish": "pinst --disable" | ||
}, | ||
"dependencies": { | ||
"@naturalcycles/js-lib": "^14.78.0", | ||
"@naturalcycles/nodejs-lib": "^12.62.1" | ||
}, | ||
"devDependencies": { | ||
"@naturalcycles/dev-lib": "^12.14.2", | ||
"@types/node": "^16.11.12", | ||
"pinst": "^2.1.6" | ||
}, | ||
"files": [ | ||
"dist", | ||
"resources", | ||
"!src/test", | ||
"!src/**/*.test.ts", | ||
"!src/**/__snapshots__", | ||
"!src/**/__exclude" | ||
], | ||
"bin": { | ||
"run-ktlint": "dist/bin/run-ktlint.js" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/NaturalCycles/ktlint" | ||
}, | ||
"engines": { | ||
"node": ">=14.15.0" | ||
}, | ||
"version": "0.0.0", | ||
"description": "ktlint, conveniently published to npm registry", | ||
"keywords": [ | ||
"ktlint", | ||
"npm", | ||
"published", | ||
"lint" | ||
], | ||
"author": "Natural Cycles Team", | ||
"license": "MIT" | ||
} |
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,47 @@ | ||
## @naturalcycles/ktlint | ||
|
||
> [ktlint](https://github.com/pinterest/ktlint), conveniently published to npm registry | ||
[![npm](https://img.shields.io/npm/v/@naturalcycles/ktlint/latest.svg)](https://www.npmjs.com/package/@naturalcycles/ktlint) | ||
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) | ||
[![ktlint](https://img.shields.io/badge/code%20style-%E2%9D%A4-FF4081.svg)](https://ktlint.github.io/) | ||
|
||
Current ktlint version: `0.43.2` | ||
|
||
# Features | ||
|
||
## ktlint binary | ||
|
||
Hosts `ktlint` binary in the npm registry. | ||
|
||
So, you can install it as: | ||
|
||
```shell | ||
yarn add -D @naturalcycles/ktlint | ||
|
||
# or with npm | ||
npm i --save-dev @naturalcycles/ktlint | ||
``` | ||
|
||
And access it as `node_modules/@naturalcycles/ktlint/resources/ktlint`. | ||
|
||
E.g: | ||
|
||
```shell | ||
node_modules/@naturalcycles/ktlint/resources/ktlint --version | ||
``` | ||
|
||
## run-ktlint | ||
|
||
It exposes a `run-ktlint` CLI command, so you can run it like this (passing the arguments that you | ||
would pass to ktlint): | ||
|
||
```shell | ||
yarn run-ktlint -F | ||
|
||
# or | ||
|
||
yarn run-ktlint "someFile.kt" | ||
``` | ||
|
||
Test it with `yarn run-ktlint --version` |
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 @@ | ||
/ktlint |
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 @@ | ||
export {} |
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 @@ | ||
// | ||
// tsconfig.json for /scripts | ||
// | ||
{ | ||
"extends": "@naturalcycles/dev-lib/scripts/tsconfig.json", | ||
"compilerOptions": { | ||
"baseUrl": "./", | ||
"outDir": "../dist" | ||
}, | ||
"exclude": ["**/__exclude"] | ||
} |
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,32 @@ | ||
#!/usr/bin/env node | ||
|
||
/* | ||
yarn tsn ./src/bin/run-ktlint.ts --version | ||
*/ | ||
|
||
import { spawn } from 'child_process' | ||
import { ktlintPath } from '../paths' | ||
|
||
// argv[0] is /usr/local/bin/node | ||
// argv[1] is ./src/bin/run-ktlint.ts (when ran with `yarn tsn`) | ||
const args = process.argv.slice(2) | ||
// console.log({argv, argv0, args}) | ||
|
||
console.log(['ktlint', ...args].join(' ')) | ||
|
||
const p = spawn(ktlintPath, [...args], { | ||
stdio: 'inherit', | ||
shell: true, | ||
// env : { FORCE_COLOR: 'true' } | ||
}) | ||
|
||
// out.on('error', (error) => { | ||
// console.log(`error: ${error.message}`); | ||
// }); | ||
|
||
p.on('close', code => { | ||
// console.log(`child process exited with code ${code}`); | ||
process.exit(code || 0) | ||
}) |
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,46 @@ | ||
/* | ||
yarn tsn src/install | ||
*/ | ||
|
||
import * as fs from 'fs' | ||
import { _hb } from '@naturalcycles/js-lib' | ||
import { _pipeline, getGot, runScript } from '@naturalcycles/nodejs-lib' | ||
import { ktlintPath } from './paths' | ||
|
||
runScript(async () => { | ||
if (fs.existsSync(ktlintPath)) { | ||
// const {size, mode} = fs.statSync(ktlintPath) | ||
// return console.log(`ktlint exists, size: ${_hb(size)} mode ${mode}`) | ||
return | ||
} | ||
|
||
const got = getGot({ | ||
debug: true, | ||
logWithSearchParams: false, | ||
}) | ||
|
||
const ktlintVersion = '0.43.2' | ||
console.log(`downloading ktlint ${ktlintVersion} from github, may take some time...`) | ||
|
||
const url = `https://github.com/pinterest/ktlint/releases/download/${ktlintVersion}/ktlint` | ||
|
||
await _pipeline([got.stream.get(url), fs.createWriteStream(ktlintPath)]) | ||
|
||
console.log(`ktlint downloaded to ${ktlintPath}`) | ||
|
||
if (!fs.existsSync(ktlintPath)) { | ||
console.log(`something went wrong, ktlint not found at path: ${ktlintPath}`) | ||
return process.exit(15) | ||
} | ||
|
||
const { size } = fs.statSync(ktlintPath) | ||
console.log(`ktlint size: ${_hb(size)}`) | ||
|
||
chmod() | ||
}) | ||
|
||
function chmod() { | ||
fs.chmodSync(ktlintPath, '775') | ||
} |
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 @@ | ||
import * as path from 'path' | ||
|
||
export const projectDir = path.join(__dirname, '..') | ||
export const resourcesDir = `${projectDir}/resources` | ||
export const ktlintPath = `${resourcesDir}/ktlint` |
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 @@ | ||
|
||
fun main() { | ||
println("hello.kt") | ||
} |
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,2 @@ | ||
|
||
println("hello.kts") |
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,9 @@ | ||
{ | ||
"extends": "@naturalcycles/dev-lib/cfg/tsconfig.json", | ||
"compilerOptions": { | ||
"sourceMap": true, | ||
"outDir": "dist" | ||
}, | ||
"include": ["src"], | ||
"exclude": ["**/__exclude"] | ||
} |
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 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"declaration": false, | ||
"sourceMap": false | ||
}, | ||
"exclude": ["**/__exclude", "src/test", "src/**/*.test.*"] | ||
} |
Oops, something went wrong.