-
-
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 c5c00a5
Showing
22 changed files
with
512 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,10 @@ | ||
{ | ||
"extends": [ | ||
"plugin:n/recommended", | ||
"plugin:putout/recommended" | ||
], | ||
"plugins": [ | ||
"putout", | ||
"n" | ||
] | ||
} |
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 @@ | ||
github: coderaiser | ||
patreon: coderaiser | ||
open_collective: cloudcmd | ||
ko_fi: coderaiser |
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,10 @@ | ||
<!-- | ||
Thank you for reporting an issue. Please fill in the template below. If unsure | ||
about something, just do as best as you're able. | ||
--> | ||
|
||
- **Version** (`npm -v`): | ||
- **Node Version** `node -v`: | ||
- **OS** (`uname -a` on Linux): | ||
- **Browser name/version**: | ||
- **Used Command Line Parameters**: |
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 @@ | ||
<!-- | ||
Thank you for making pull request. Please fill in the template below. If unsure | ||
about something, just do as best as you're able. | ||
--> | ||
|
||
- [ ] commit message named according to [Contributing Guide](https://github.com/coderaiser/cloudcmd/blob/master/CONTRIBUTING.md "Contributting Guide") | ||
- [ ] `npm run codestyle` is OK | ||
- [ ] `npm test` is OK |
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 @@ | ||
name: Node CI | ||
on: | ||
- push | ||
- pull_request | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
env: | ||
NAME: madrun | ||
strategy: | ||
matrix: | ||
node-version: | ||
- 16.x | ||
- 18.x | ||
- 20.x | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Install Redrun | ||
run: npm i redrun -g | ||
- name: Install | ||
run: npm install | ||
- name: Lint | ||
run: redrun fix:lint | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
- uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
target/ | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
- name: Typos Install | ||
run: cargo install typos-cli || echo 'already installed' | ||
- name: Typos | ||
run: typos --write-changes | ||
- name: Commit fixes | ||
uses: EndBug/add-and-commit@v9 | ||
with: | ||
message: "chore: ${{ env.NAME }}: lint using actions ☘️" | ||
- name: Coverage | ||
run: redrun coverage | ||
- name: Coveralls | ||
uses: coverallsapp/github-action@v2 | ||
with: | ||
github-token: ${{ secrets.GITHUB_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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
*.swp | ||
.*.swp | ||
.idea | ||
|
||
node_modules | ||
package-lock.json | ||
npm-debug.log | ||
.nyc_output | ||
coverage | ||
|
||
yarn-error.log |
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,31 @@ | ||
import { | ||
run, | ||
cutEnv, | ||
} from './lib/madrun.js'; | ||
|
||
const noop = () => {}; | ||
|
||
const NODE_OPTIONS = `'--loader mock-import --no-warnings'`; | ||
|
||
const env = { | ||
SUPERTAPE_PROGRESS_BAR_MIN: 20, | ||
NODE_OPTIONS, | ||
}; | ||
|
||
export default { | ||
'lint': () => 'putout .', | ||
'fresh:lint': () => run('lint', '--fresh'), | ||
'lint:fresh': () => run('lint', '--fresh'), | ||
'fix:lint': () => run('lint', '--fix'), | ||
'test:only': () => `tape 'test/**/*.js' '{lib,bin}/**/*.spec.{js,mjs}'`, | ||
'test': async () => [env, await run('test:only')], | ||
'watch:test': async () => await run('watcher', await cutEnv('test')), | ||
'watch:tape': () => 'nodemon -w test -w lib --exec tape', | ||
'watch:lint': async () => await run('watcher', await run('lint')), | ||
'watcher': () => 'nodemon -w test -w lib -w bin --exec', | ||
'coverage': async () => `escover ${await run('test:only')}`, | ||
'coverage:old': async () => [`c8 ${await run('test:only')}`, env], | ||
'report': () => 'c8 report --reporter=lcov', | ||
'postpublish': () => 'npm i -g', | ||
'hello': noop, | ||
}; |
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 @@ | ||
.* | ||
*.spec.* | ||
|
||
test | ||
fixture | ||
coverage | ||
yarn-error.log | ||
|
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 @@ | ||
package-lock=false |
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,16 @@ | ||
{ | ||
"extension": [".mjs"], | ||
"check-coverage": false, | ||
"all": true, | ||
"exclude": [ | ||
".*", | ||
"bin/madrun.mjs", | ||
"**/*.spec.*", | ||
"test", | ||
"**/fixture" | ||
], | ||
"branches": 100, | ||
"lines": 100, | ||
"functions": 100, | ||
"statements": 100 | ||
} |
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,3 @@ | ||
{ | ||
"printer": "putout" | ||
} |
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 @@ | ||
# Contributor Covenant Code of Conduct | ||
|
||
## Our Pledge | ||
|
||
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. | ||
|
||
## Our Standards | ||
|
||
Examples of behavior that contributes to creating a positive environment include: | ||
|
||
- Using welcoming and inclusive language | ||
- Being respectful of differing viewpoints and experiences | ||
- Gracefully accepting constructive criticism | ||
- Focusing on what is best for the community | ||
- Showing empathy towards other community members | ||
|
||
Examples of unacceptable behavior by participants include: | ||
|
||
- The use of sexualized language or imagery and unwelcome sexual attention or advances | ||
- Trolling, insulting/derogatory comments, and personal or political attacks | ||
- Public or private harassment | ||
- Publishing others' private information, such as a physical or electronic address, without explicit permission | ||
- Other conduct which could reasonably be considered inappropriate in a professional setting | ||
|
||
## Our Responsibilities | ||
|
||
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. | ||
|
||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. | ||
|
||
## Scope | ||
|
||
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. | ||
|
||
## Enforcement | ||
|
||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. | ||
|
||
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. | ||
|
||
## Attribution | ||
|
||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] | ||
|
||
[homepage]: http://contributor-covenant.org | ||
[version]: http://contributor-covenant.org/version/1/4/ |
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,25 @@ | ||
## Commit | ||
|
||
Format of the commit message: **type: scope: subject** | ||
|
||
**Type**: | ||
|
||
- **feature: scope: subject** | ||
- **fix: scope: subject** | ||
- **docs: scope: subject** | ||
- **refactor: scope: subject** | ||
- **test: scope: subject** | ||
- **chore: scope: subject** | ||
|
||
**Scope**: | ||
Scope could be anything specifying place of the commit change. | ||
For example util, console, view, edit, style etc... | ||
|
||
**Subject text**: | ||
|
||
- use imperative, present tense: “change” not “changed” nor “changes” | ||
- don't capitalize first letter | ||
- no dot (.) at the end | ||
**Message body**: | ||
- just as in <subject> use imperative, present tense: “change” not “changed” nor “changes” | ||
- includes motivation for the change and contrasts with previous behavior |
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,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016-now coderaiser | ||
|
||
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. |
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,34 @@ | ||
# redput [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL] | ||
|
||
![image](https://user-images.githubusercontent.com/1573141/223524904-4175548f-1e30-4745-bf2e-c2f4ea39fef5.png) | ||
|
||
[NPMURL]: https://npmjs.org/package/redput "npm" | ||
[NPMIMGURL]: https://img.shields.io/npm/v/redput.svg?style=flat | ||
[BuildStatusURL]: https://github.com/coderaiser/redput/actions?query=workflow%3A%22Node+CI%22 "Build Status" | ||
[BuildStatusIMGURL]: https://github.com/coderaiser/redput/workflows/Node%20CI/badge.svg | ||
[LicenseURL]: https://tldrlegal.com/license/mit-license "MIT License" | ||
[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat | ||
[CoverageURL]: https://coveralls.io/github/coderaiser/redput?branch=master | ||
[CoverageIMGURL]: https://coveralls.io/repos/coderaiser/redput/badge.svg?branch=master&service=github | ||
|
||
CLI tool to download rule and fixture from 🐊**Putout Editor**. | ||
|
||
## Install | ||
|
||
``` | ||
npm i redput -g | ||
``` | ||
|
||
# Usage | ||
|
||
```sh | ||
GITHUB_TOKEN=github-token redput [putout-editor-url] | ||
``` | ||
|
||
`redput` determines where it located and does one of two: | ||
- when finds `index.js` it creates rule inside nested plugin; | ||
- create directory with a plugin name and fiils `lib`, `test` and `fixture`; | ||
|
||
## 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,22 @@ | ||
#!/usr/bin/env node | ||
|
||
import {redput} from '../lib/redput.js'; | ||
|
||
const {GITHUB_TOKEN} = process.env; | ||
const [url] = process.argv.slice(2); | ||
|
||
if (!url) { | ||
console.error('redput [putout-editor-url]') | ||
process.exit(1); | ||
} | ||
|
||
const [error, result] = await redput(url, { | ||
token: GITHUB_TOKEN, | ||
}); | ||
|
||
if (error) { | ||
console.error('❌', error.message); | ||
process.exit(1); | ||
} | ||
|
||
console.log('✅', result); |
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,29 @@ | ||
import putout, {operator} from 'putout'; | ||
|
||
const {getTemplateValues} = operator; | ||
|
||
const REPORT = 'export const report = () => __a'; | ||
|
||
export const getReport = (rule) => { | ||
let result; | ||
|
||
putout(rule, { | ||
fix: false, | ||
plugins: [ | ||
['read-report', { | ||
report: () => {}, | ||
fix: () => {}, | ||
traverse: () => ({ | ||
[REPORT](path) { | ||
const {__a} = getTemplateValues(path, REPORT); | ||
|
||
result = __a.quasis[0].value.cooked; | ||
path.stop(); | ||
} | ||
}), | ||
}], | ||
], | ||
}); | ||
|
||
return result; | ||
}; |
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,13 @@ | ||
import { Octokit, App } from "octokit"; | ||
|
||
export const readGist = async (url, {token}) => { | ||
const octokit = new Octokit({ | ||
auth: token, | ||
}) | ||
|
||
return await octokit.request(`GET /gists/${url}`, { | ||
headers: { | ||
'X-GitHub-Api-Version': '2022-11-28' | ||
} | ||
}) | ||
} |
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,34 @@ | ||
import tryToCatch from 'try-to-catch'; | ||
|
||
import {readGist} from './read-gist.js'; | ||
import {writeRule, writeFixtures, writeTestForNested} from './write.js'; | ||
import {getReport} from './get-report.js'; | ||
|
||
export const redput = async (link, {token}) => { | ||
const gistLink = link.replace('https://putout.cloudcmd.io/#/gist/', ''); | ||
const [error, result] = await tryToCatch(readGist, gistLink, { | ||
token, | ||
}); | ||
|
||
if (error) | ||
return [Error(error.response.data.message)]; | ||
|
||
const raw = result.data.files['transform.js'].content; | ||
const fixture = result.data.files['source.js'].content; | ||
|
||
const [comment, ...lines] = raw.split('\n'); | ||
const name = comment.replace(/\/\/\s+?/, ''); | ||
|
||
if (name.includes(':')) | ||
return [Error(`Bad name: ${name}`)]; | ||
|
||
const rule = lines.join('\n'); | ||
const report = getReport(rule); | ||
|
||
await writeRule(name, rule); | ||
await writeFixtures(name, fixture); | ||
await writeTestForNested(name, report); | ||
|
||
return [null, 'Done']; | ||
}; | ||
|
Oops, something went wrong.