class Dopstick::Generator::NPM::Generator

Attributes

options[RW]

Public Class Methods

exit_on_failure?() click to toggle source
# File lib/dopstick/generator/npm/generator.rb, line 16
def self.exit_on_failure?
  true
end
source_paths() click to toggle source
# File lib/dopstick/generator/npm/generator.rb, line 20
def self.source_paths
  [
    source_root,
    File.join(__dir__, "../base/templates")
  ]
end
source_root() click to toggle source
# File lib/dopstick/generator/npm/generator.rb, line 27
def self.source_root
  File.join(__dir__, "templates")
end

Public Instance Methods

copy_generic_templates() click to toggle source
# File lib/dopstick/generator/npm/generator.rb, line 44
def copy_generic_templates
  template "license.erb", "LICENSE.md"
  template "coc.erb", "CODE_OF_CONDUCT.md"
  template "readme.erb", "README.md"
  template "changelog.erb", "CHANGELOG.md"
  template "contributing.erb", "CONTRIBUTING.md"
  template "gitignore.erb", ".gitignore"
end
copy_github_templates() click to toggle source
# File lib/dopstick/generator/npm/generator.rb, line 53
def copy_github_templates
  template "funding.erb", ".github/FUNDING.yml"
  template "bug_report.erb", ".github/ISSUE_TEMPLATE/bug_report.md"
  template "feature_request.erb",
           ".github/ISSUE_TEMPLATE/feature_request.md"
  template "pull_request.erb", ".github/PULL_REQUEST_TEMPLATE.md"
  template "dependabot.erb", ".github/dependabot.yml"
  template "codeowners.erb", ".github/CODEOWNERS"
end
copy_npm_templates() click to toggle source
# File lib/dopstick/generator/npm/generator.rb, line 31
def copy_npm_templates
  template "package.erb", "package.json"
  template "tests_workflow.erb", ".github/workflows/js-tests.yml"
  template "tsconfig.erb", "tsconfig.json"
  template "prettier.erb", "prettier.config.js"
  template "jest.erb", "jest.config.js"
  template "eslint.erb", ".eslintrc.js"
  template "webpack.erb", "webpack.config.js"
  template "babel.erb", "babel.config.json"
  template "index.erb", "src/index.ts"
  template "index_test.erb", "src/index.test.ts"
end
initialize_repo() click to toggle source
# File lib/dopstick/generator/npm/generator.rb, line 91
def initialize_repo
  in_root do
    run "git init --initial-branch=main", capture: true
    run "git add .", capture: true
  end
end
install_dependencies() click to toggle source
# File lib/dopstick/generator/npm/generator.rb, line 63
def install_dependencies
  return if options.skip_install?

  in_root do
    %w[
      @babel/core
      @babel/preset-env
      @fnando/codestyle
      @fnando/eslint-config-codestyle
      @typescript-eslint/eslint-plugin
      @typescript-eslint/parser
      babel-loader
      babel-plugin-module-resolver
      eslint
      jest
      jest-filename-transform
      prettier
      ts-jest
      ts-loader
      typescript
      webpack
      webpack-cli
    ].each do |dep|
      run "yarn add --dev #{dep}", capture: true
    end
  end
end