0.2.1 • Published 2 years ago

@aiou/mario v0.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@aiou/mario

Simple Manipulate syste mbased on gulp

npm GitHub

features

  • 🖐️ Similar syntax like github workflow, check supported syntax here
  • 📦 Builtin most use actions like replace/copy/clean/json-editor
  • 📝 Work with listr
  • ⚡ Support expression string like github-outputs

install

npm install @aiou/mario

usage

import { create } from '@aiou/mario'

const mario = await create(filepath)
await mario.start()

common options

common options for job

  • job.paths - Not required, in default will be all files under process.cwd(), auto ignore node_modules. If specific paths but not match files, will skip job.

common options for uses run in workflow

  • steps.continue-on-error - no exit if error
steps:
  - name: Setup Husky
    run: pnpx --yes husky-init
    continue-on-error: true

uses

only support builtin actions

replace

jobs:
  REPLACE:
    paths: "output/**/*.ts"
    steps:
      - name: Replace Action
      - uses: replace
        with:
          match: one
          replacement: target

      # batch replace
      - name: Replace Action
      - uses: replace
        with:
          pairs:
            - match: two
              replacement: target
            - match: three
              replacement: ${{ outputs.variable }}

json-editor

jobs:
  JSON EDITOR:
    paths: "output/**/*.json"
    steps:
      - name: Json Editor Action
      - uses: json-editor
        with:
          content:
            version: "1.0.0"
          pairs:
            - path: "scripts.ci:prepare"
              value: "pnpm publish"
            - path: "lint-staged"
              value:
                "**/**/*.{js,ts,tsx,vue,json}": ["eslint --fix"]
            
  • content - overwrite matched json file
  • pairs - partial updated json content
    • path - separator is . like lodash.set
    • value

clean

jobs:
  CLEAN:
    paths: "*.ts"
    steps:
      - name: Clean Action
      - uses: clean
        with:
          paths:
            - "output/*"
  • output - clean files matched output/**

copy

jobs:
  COPY:
    paths: "assets.ts"
    steps:
      - name: COPY
      - uses: copy
        with:
          output: output
  • output - copy paths files to output

run

jobs:
  RUN:
    paths: "output/*"
    steps:
      - name: Run Shell
        run: echo hello
        with:
          quiet: false
  • quiet - silent exec

how it work

jobs:
  //...
  Issue template:
    name: Setup github issue templates
    paths: .neo/**/assets/templates/ISSUE_TEMPLATE/*.md
    steps:
      - name: Issue templates
        uses: copy
        with:
          output: .github/ISSUE_TEMPLATE
  //...

will convert to

gulp.task('Setup github issue templates', function () {
  gulp.src('.neo/**/assets/templates/ISSUE_TEMPLATE/*.md')
    .pipe('copy to output')
    .dest('..')
})

TODO

  • dynamic load external uses action
  • more github workflow syntax, e.g. if

built with ❤️ by 😼