dopstick 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +4 -0
- data/.rubocop.yml +11 -6
- data/CHANGELOG.md +11 -0
- data/CONTRIBUTING.md +1 -1
- data/README.md +6 -3
- data/dopstick.gemspec +2 -1
- data/lib/dopstick.rb +7 -1
- data/lib/dopstick/cli.rb +40 -11
- data/lib/dopstick/generator.rb +3 -208
- data/lib/dopstick/{templates → generator/base/templates}/bug_report.erb +1 -1
- data/lib/dopstick/{templates/CHANGELOG.md → generator/base/templates/changelog.erb} +0 -0
- data/lib/dopstick/{templates → generator/base/templates}/coc.erb +1 -1
- data/lib/dopstick/generator/base/templates/codeowners.erb +4 -0
- data/lib/dopstick/{templates → generator/base/templates}/contributing.erb +5 -5
- data/lib/dopstick/generator/base/templates/dependabot.erb +15 -0
- data/lib/dopstick/{templates → generator/base/templates}/feature_request.erb +0 -0
- data/lib/dopstick/generator/base/templates/funding.erb +4 -0
- data/lib/dopstick/{templates → generator/base/templates}/gitignore.erb +0 -0
- data/lib/dopstick/{templates → generator/base/templates}/issue.erb +0 -0
- data/lib/dopstick/{templates → generator/base/templates}/license.erb +1 -1
- data/lib/dopstick/{templates → generator/base/templates}/pull_request.erb +0 -0
- data/lib/dopstick/{templates → generator/base/templates}/setup.erb +0 -0
- data/lib/dopstick/generator/gem/generator.rb +160 -0
- data/lib/dopstick/generator/gem/options.rb +34 -0
- data/lib/dopstick/{templates → generator/gem/templates}/active_record.erb +25 -0
- data/lib/dopstick/generator/gem/templates/bin.erb +5 -0
- data/lib/dopstick/{templates → generator/gem/templates}/cli.erb +0 -0
- data/lib/dopstick/{templates → generator/gem/templates}/cli_class.erb +0 -0
- data/lib/dopstick/{templates → generator/gem/templates}/console.erb +1 -1
- data/lib/dopstick/generator/gem/templates/entry_file.erb +3 -0
- data/lib/dopstick/generator/gem/templates/gem_entry_file.erb +3 -0
- data/lib/dopstick/{templates → generator/gem/templates}/gemfile.erb +0 -0
- data/lib/dopstick/{templates → generator/gem/templates}/gemspec.erb +14 -14
- data/lib/dopstick/{templates → generator/gem/templates}/generator.erb +0 -0
- data/lib/dopstick/{templates → generator/gem/templates}/generator_class.erb +0 -0
- data/lib/dopstick/{templates → generator/gem/templates}/rakefile.erb +0 -0
- data/lib/dopstick/generator/gem/templates/readme.erb +50 -0
- data/lib/dopstick/generator/gem/templates/rubocop.erb +12 -0
- data/lib/dopstick/{templates → generator/gem/templates}/test_file.erb +1 -1
- data/lib/dopstick/{templates → generator/gem/templates}/test_helper.erb +1 -1
- data/lib/dopstick/{templates → generator/gem/templates}/tests_workflow.erb +6 -4
- data/lib/dopstick/{templates → generator/gem/templates}/version.erb +0 -0
- data/lib/dopstick/generator/npm/generator.rb +100 -0
- data/lib/dopstick/generator/npm/options.rb +26 -0
- data/lib/dopstick/generator/npm/templates/babel.erb +15 -0
- data/lib/dopstick/generator/npm/templates/eslint.erb +4 -0
- data/lib/dopstick/generator/npm/templates/index.erb +12 -0
- data/lib/dopstick/generator/npm/templates/index_test.erb +7 -0
- data/lib/dopstick/generator/npm/templates/jest.erb +12 -0
- data/lib/dopstick/generator/npm/templates/package.erb +42 -0
- data/lib/dopstick/generator/npm/templates/prettier.erb +1 -0
- data/lib/dopstick/generator/npm/templates/readme.erb +52 -0
- data/lib/dopstick/generator/npm/templates/tests_workflow.erb +46 -0
- data/lib/dopstick/generator/npm/templates/tsconfig.erb +14 -0
- data/lib/dopstick/generator/npm/templates/webpack.erb +33 -0
- data/lib/dopstick/generator/options.rb +65 -0
- data/lib/dopstick/version.rb +1 -1
- metadata +56 -37
- data/lib/dopstick/templates/bin.erb +0 -5
- data/lib/dopstick/templates/entry_file.erb +0 -3
- data/lib/dopstick/templates/funding.erb +0 -4
- data/lib/dopstick/templates/gem_entry_file.erb +0 -3
- data/lib/dopstick/templates/readme.erb +0 -50
- data/lib/dopstick/templates/rubocop.erb +0 -12
@@ -0,0 +1,12 @@
|
|
1
|
+
---
|
2
|
+
inherit_gem:
|
3
|
+
rubocop-fnando: .rubocop.yml
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
TargetRubyVersion: <%= options.oldest_ruby_version.split(".").take(2).join(".") %>
|
7
|
+
NewCops: enable
|
8
|
+
<%- if options.package_name.include?("-") -%>
|
9
|
+
Naming/FileName:
|
10
|
+
Exclude:
|
11
|
+
- lib/<%= options.package_name %>.rb
|
12
|
+
<%- end -%>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
name:
|
1
|
+
name: ruby-tests
|
2
2
|
|
3
3
|
on:
|
4
4
|
pull_request:
|
@@ -18,11 +18,11 @@ jobs:
|
|
18
18
|
strategy:
|
19
19
|
fail-fast: false
|
20
20
|
matrix:
|
21
|
-
ruby: [<%= ruby_versions.map {|v| [*Gem::Version.new(v).canonical_segments, "x"].take(3).join(".") }.join(", ") %>]
|
21
|
+
ruby: [<%= options.ruby_versions.map {|v| [*Gem::Version.new(v).canonical_segments, "x"].take(3).join(".") }.join(", ") %>]
|
22
22
|
gemfile:
|
23
23
|
- Gemfile
|
24
24
|
|
25
|
-
<%- if options
|
25
|
+
<%- if options.active_record? -%>
|
26
26
|
services:
|
27
27
|
postgres:
|
28
28
|
image: postgres:11.5
|
@@ -48,7 +48,7 @@ jobs:
|
|
48
48
|
with:
|
49
49
|
ruby-version: ${{ matrix.ruby }}
|
50
50
|
|
51
|
-
<%- if options
|
51
|
+
<%- if options.active_record? -%>
|
52
52
|
- name: Install PostgreSQL client
|
53
53
|
env:
|
54
54
|
PGHOST: localhost
|
@@ -68,6 +68,8 @@ jobs:
|
|
68
68
|
|
69
69
|
- name: Run Tests
|
70
70
|
env:
|
71
|
+
PGHOST: localhost
|
72
|
+
PGUSER: postgres
|
71
73
|
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
72
74
|
run: |
|
73
75
|
bundle exec rake
|
File without changes
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Dopstick
|
4
|
+
module Generator
|
5
|
+
module NPM
|
6
|
+
Generator.registered["npm"] = self
|
7
|
+
|
8
|
+
class Generator < Thor::Group
|
9
|
+
using Dopstick::Refinements
|
10
|
+
include Thor::Actions
|
11
|
+
|
12
|
+
attr_accessor :options
|
13
|
+
|
14
|
+
desc "Generate a new npm folder structure"
|
15
|
+
|
16
|
+
def self.exit_on_failure?
|
17
|
+
true
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.source_paths
|
21
|
+
[
|
22
|
+
source_root,
|
23
|
+
File.join(__dir__, "../base/templates")
|
24
|
+
]
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.source_root
|
28
|
+
File.join(__dir__, "templates")
|
29
|
+
end
|
30
|
+
|
31
|
+
def copy_npm_templates
|
32
|
+
template "package.erb", "package.json"
|
33
|
+
template "tests_workflow.erb", ".github/workflows/js-tests.yml"
|
34
|
+
template "tsconfig.erb", "tsconfig.json"
|
35
|
+
template "prettier.erb", "prettier.config.js"
|
36
|
+
template "jest.erb", "jest.config.js"
|
37
|
+
template "eslint.erb", ".eslintrc.js"
|
38
|
+
template "webpack.erb", "webpack.config.js"
|
39
|
+
template "babel.erb", "babel.config.json"
|
40
|
+
template "index.erb", "src/index.ts"
|
41
|
+
template "index_test.erb", "src/index.test.ts"
|
42
|
+
end
|
43
|
+
|
44
|
+
def copy_generic_templates
|
45
|
+
template "license.erb", "LICENSE.md"
|
46
|
+
template "coc.erb", "CODE_OF_CONDUCT.md"
|
47
|
+
template "readme.erb", "README.md"
|
48
|
+
template "changelog.erb", "CHANGELOG.md"
|
49
|
+
template "contributing.erb", "CONTRIBUTING.md"
|
50
|
+
template "gitignore.erb", ".gitignore"
|
51
|
+
end
|
52
|
+
|
53
|
+
def copy_github_templates
|
54
|
+
template "funding.erb", ".github/FUNDING.yml"
|
55
|
+
template "bug_report.erb", ".github/ISSUE_TEMPLATE/bug_report.md"
|
56
|
+
template "feature_request.erb",
|
57
|
+
".github/ISSUE_TEMPLATE/feature_request.md"
|
58
|
+
template "pull_request.erb", ".github/PULL_REQUEST_TEMPLATE.md"
|
59
|
+
template "dependabot.erb", ".github/dependabot.yml"
|
60
|
+
template "codeowners.erb", ".github/CODEOWNERS"
|
61
|
+
end
|
62
|
+
|
63
|
+
def install_dependencies
|
64
|
+
return if options.skip_install?
|
65
|
+
|
66
|
+
in_root do
|
67
|
+
%w[
|
68
|
+
@babel/core
|
69
|
+
@babel/preset-env
|
70
|
+
@fnando/codestyle
|
71
|
+
@fnando/eslint-config-codestyle
|
72
|
+
@typescript-eslint/eslint-plugin
|
73
|
+
@typescript-eslint/parser
|
74
|
+
babel-loader
|
75
|
+
babel-plugin-module-resolver
|
76
|
+
eslint
|
77
|
+
jest
|
78
|
+
jest-filename-transform
|
79
|
+
prettier
|
80
|
+
ts-jest
|
81
|
+
ts-loader
|
82
|
+
typescript
|
83
|
+
webpack
|
84
|
+
webpack-cli
|
85
|
+
].each do |dep|
|
86
|
+
run "yarn add --dev #{dep}", capture: true
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def initialize_repo
|
92
|
+
in_root do
|
93
|
+
run "git init --initial-branch=main", capture: true
|
94
|
+
run "git add .", capture: true
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Dopstick
|
4
|
+
module Generator
|
5
|
+
module NPM
|
6
|
+
class Options < Generator::Options
|
7
|
+
using Refinements
|
8
|
+
|
9
|
+
def user_name
|
10
|
+
`npm get init.author.name`.chomp.presence ||
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
def user_email
|
15
|
+
`npm get init.author.email`.chomp.presence ||
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
def user_url
|
20
|
+
`npm get init.author.url`.chomp.presence ||
|
21
|
+
"https://github.com/#{github_user}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
// To import modules, you can use ~/:path, where `:path` must be reflect the
|
2
|
+
// structure you define inside `./src`. For instance, if you have a
|
3
|
+
// `src/utils.ts` file that exports some functions, you can import it with this:
|
4
|
+
//
|
5
|
+
// ```ts
|
6
|
+
// import { func } from "~/utils";
|
7
|
+
// ```
|
8
|
+
//
|
9
|
+
// To export your final bundle, use `yarn build`. This will ensure that all
|
10
|
+
// files point to the right place, considering the `~/` alias.
|
11
|
+
//
|
12
|
+
export const name = "<%= options.package_name %>";
|
@@ -0,0 +1,12 @@
|
|
1
|
+
const config = require("@fnando/codestyle/jest");
|
2
|
+
|
3
|
+
module.exports = {
|
4
|
+
...config,
|
5
|
+
testRegex: ".*?\\.test\\.ts",
|
6
|
+
roots: ["<rootDir>/src"],
|
7
|
+
modulePaths: ["src"],
|
8
|
+
moduleNameMapper: {
|
9
|
+
"^~/": "<rootDir>/src/",
|
10
|
+
},
|
11
|
+
testPathIgnorePatterns: ["/vendor/bundle/", "node_modules"],
|
12
|
+
};
|
@@ -0,0 +1,42 @@
|
|
1
|
+
<%= JSON.pretty_generate(
|
2
|
+
name: options.package_name,
|
3
|
+
version: options.version,
|
4
|
+
private: true,
|
5
|
+
description: options.description,
|
6
|
+
author: {
|
7
|
+
name: options.user_name,
|
8
|
+
email: options.user_email,
|
9
|
+
url: options.user_url,
|
10
|
+
},
|
11
|
+
homepage: options.github_url,
|
12
|
+
license: "MIT",
|
13
|
+
bugs: "#{options.github_url}/issues",
|
14
|
+
repository: "#{options.github_url}.git",
|
15
|
+
scripts: {
|
16
|
+
test: "jest --watch",
|
17
|
+
"test:ci" => "jest && yarn lint",
|
18
|
+
lint: "yarn lint:ts && yarn lint:eslint",
|
19
|
+
"lint:ts" => "tsc --noEmit",
|
20
|
+
"lint:eslint" => "eslint src --max-warnings 0",
|
21
|
+
build: "rm -rf dist && webpack"
|
22
|
+
},
|
23
|
+
devDependencies: {
|
24
|
+
"@babel/core" => "*",
|
25
|
+
"@babel/preset-env" => "*",
|
26
|
+
"@fnando/codestyle" => "*",
|
27
|
+
"@fnando/eslint-config-codestyle" => "*",
|
28
|
+
"@typescript-eslint/eslint-plugin" => "*",
|
29
|
+
"@typescript-eslint/parser" => "*",
|
30
|
+
"babel-loader" => "*",
|
31
|
+
"babel-plugin-module-resolver" => "*",
|
32
|
+
"eslint" => "*",
|
33
|
+
"jest" => "*",
|
34
|
+
"jest-filename-transform" => "*",
|
35
|
+
"prettier" => "*",
|
36
|
+
"ts-jest" => "*",
|
37
|
+
"ts-loader" => "*",
|
38
|
+
"typescript" => "*",
|
39
|
+
"webpack" => "*",
|
40
|
+
"webpack-cli" => "*"
|
41
|
+
}
|
42
|
+
) %>
|
@@ -0,0 +1 @@
|
|
1
|
+
module.exports = require("@fnando/codestyle/prettier.json");
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# <%= options.package_name %>
|
2
|
+
|
3
|
+
[![Tests](<%= options.github_url %>/workflows/node-tests/badge.svg)](https://github.com/fnando/<%= options.package_name %>)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/<%= options.github_user %>/<%= options.package_name %>/badges/gpa.svg)](https://codeclimate.com/github/<%= options.github_user %>/<%= options.package_name %>)
|
5
|
+
[![NPM](https://img.shields.io/npm/v/<%= options.package_name %>.svg)](https://npmjs.org/packages/<%= options.package_name %>)
|
6
|
+
[![NPM](https://img.shields.io/npm/dt/<%= options.package_name %>.svg)](https://npmjs.org/packages/<%= options.package_name %>)
|
7
|
+
|
8
|
+
<%= options.description %>
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
This package is available as a NPM package. To install it, use the following command:
|
13
|
+
|
14
|
+
```bash
|
15
|
+
npm install <%= options.package_name %> --save
|
16
|
+
```
|
17
|
+
|
18
|
+
If you're using Yarn (and you should):
|
19
|
+
|
20
|
+
```bash
|
21
|
+
yarn add <%= options.package_name %>
|
22
|
+
```
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
TODO: Write gem usage
|
27
|
+
|
28
|
+
## Maintainer
|
29
|
+
|
30
|
+
- [<%= options.user_name %>](https://github.com/<%= options.github_user %>)
|
31
|
+
|
32
|
+
## Contributors
|
33
|
+
|
34
|
+
- <%= options.github_url %>/contributors
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
For more details about how to contribute, please read
|
39
|
+
<%= options.github_url %>/blob/main/CONTRIBUTING.md.
|
40
|
+
|
41
|
+
|
42
|
+
## License
|
43
|
+
|
44
|
+
The gem is available as open source under the terms of the
|
45
|
+
[MIT License](https://opensource.org/licenses/MIT). A copy of the license can be
|
46
|
+
found at <%= options.github_url %>/blob/main/LICENSE.md.
|
47
|
+
|
48
|
+
## Code of Conduct
|
49
|
+
|
50
|
+
Everyone interacting in the <%= options.package_name %> project's codebases, issue trackers,
|
51
|
+
chat rooms and mailing lists is expected to follow the
|
52
|
+
[code of conduct](<%= options.github_url %>/blob/main/CODE_OF_CONDUCT.md).
|
@@ -0,0 +1,46 @@
|
|
1
|
+
name: node-tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
push:
|
8
|
+
branches:
|
9
|
+
- main
|
10
|
+
|
11
|
+
schedule:
|
12
|
+
- cron: "0 10 * * *"
|
13
|
+
|
14
|
+
jobs:
|
15
|
+
build:
|
16
|
+
name: Tests with Node ${{ matrix.node }}
|
17
|
+
runs-on: "ubuntu-latest"
|
18
|
+
strategy:
|
19
|
+
fail-fast: false
|
20
|
+
matrix:
|
21
|
+
node: [<%= options.node_versions.map {|v| Gem::Version.new(v).canonical_segments.first.to_s.inspect }.join(", ") %>]
|
22
|
+
|
23
|
+
steps:
|
24
|
+
- uses: actions/checkout@v1
|
25
|
+
|
26
|
+
- uses: actions/cache@v2
|
27
|
+
with:
|
28
|
+
path: vendor/bundle
|
29
|
+
key: >
|
30
|
+
${{ runner.os }}-${{ matrix.node }}-npm-${{ hashFiles("package.json") }}
|
31
|
+
restore-keys: >
|
32
|
+
${{ runner.os }}-${{ matrix.node }}-npm-${{ hashFiles("package.json") }}
|
33
|
+
|
34
|
+
- name: Set up Node
|
35
|
+
uses: actions/setup-node@v2-beta
|
36
|
+
with:
|
37
|
+
node-version: ${{ matrix.node }}
|
38
|
+
|
39
|
+
- name: Install npm dependencies
|
40
|
+
run: |
|
41
|
+
yarn install
|
42
|
+
|
43
|
+
- name: Run Tests
|
44
|
+
run: |
|
45
|
+
yarn test:ci
|
46
|
+
yarn lint
|
@@ -0,0 +1,33 @@
|
|
1
|
+
/* eslint-env node */
|
2
|
+
|
3
|
+
const path = require("path");
|
4
|
+
|
5
|
+
module.exports = {
|
6
|
+
mode: "production",
|
7
|
+
entry: {
|
8
|
+
index: "./src/index.ts",
|
9
|
+
},
|
10
|
+
devtool: "source-map",
|
11
|
+
output: {
|
12
|
+
filename: "[name].js",
|
13
|
+
path: path.resolve(__dirname, "dist"),
|
14
|
+
},
|
15
|
+
module: {
|
16
|
+
rules: [
|
17
|
+
{
|
18
|
+
test: /\.ts$/,
|
19
|
+
use: [{ loader: "ts-loader" }, { loader: "babel-loader" }],
|
20
|
+
exclude: /node_modules/,
|
21
|
+
},
|
22
|
+
{
|
23
|
+
test: /\.js$/,
|
24
|
+
use: [{ loader: "babel-loader" }],
|
25
|
+
exclude: /node_modules/,
|
26
|
+
},
|
27
|
+
],
|
28
|
+
},
|
29
|
+
resolve: {
|
30
|
+
alias: { "~/": path.resolve(__dirname, "src/") },
|
31
|
+
extensions: [".tsx", ".ts", ".js"],
|
32
|
+
},
|
33
|
+
};
|