Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
renxia committed Feb 21, 2024
0 parents commit 43c4d01
Show file tree
Hide file tree
Showing 11 changed files with 404 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# http://editorconfig.org
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 140
trim_trailing_whitespace = true

[*.md]
max_line_length = 0
trim_trailing_whitespace = false
77 changes: 77 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages

name: NPM Publish

on:
push:
tags:
- "v*.*.*"

jobs:
npm-publish:
runs-on: ubuntu-latest
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: 'recursive'

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: https://registry.npmjs.com

- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --no-frozen-lockfile --ignore-scripts

# - name: Build and npm-publish
# run: npm run release

- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

# - name: GitHub Pages action
# uses: peaceiris/actions-gh-pages@v3
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# publish_dir: ./docs

- name: Github Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
draft: false
prerelease: false
# tag_name: ${{ github.ref }}
# name: Release ${{ github.ref }}
# body: TODO New Release.
# files: |
# ${{ secrets.ReleaseZipName }}.zip
# LICENSE
112 changes: 112 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# manager
package-lock.json
yarn.lock
yarn-error.log
pnpm-lock.yaml
.pnpm-debug.log

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache
\#cache
cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# build output
dist
tmp
output
cron.config.mjs
6 changes: 6 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

registry="https://registry.npmmirror.com"

# for pnpm
strict-peer-dependencies=false
shamefully-hoist=true
18 changes: 18 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"printWidth": 140,
"singleQuote": true,
"trailingComma": "es5",
"proseWrap": "preserve",
"semi": true,
"bracketSpacing": true,
"arrowParens": "avoid",
"tabWidth": 2,
"overrides": [
{
"files": ".prettierrc",
"options": {
"parser": "json"
}
}
]
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 gflizhiwen

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.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# @lzwme/cron-tasks

> npx @lzwme/cron-tasks
This is a simple cron tasks manager based on Node.js.

## Installation

```bash
npm i -g @lzwme/cron-tasks
```

## Usage

```bash
tcron
```

## License

`@lzwme/cron-tasks` is released under the [MIT](./LICENSE) license.

该插件由[志文工作室](https://lzw.me)开发和维护。
3 changes: 3 additions & 0 deletions bin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

import('./src/index.mjs');
26 changes: 26 additions & 0 deletions cron.config.sample.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { color, execSync } from '@lzwme/fe-utils';

export default ({ logger }) => {
return {
/** @type { import('cron').CronJobParams[] } */
configList: [
{
desc: 'chatgpt-sites 每日更新',
cronTime: '0 0 8 * * *',
// onTick: {
// command: 'tsx',
// args: ['src/index.ts','--no-bot', '--ci'],
// options: {
// cwd: 'D:\\coding\\lzwme\\_archive\\chatgpt-sites',
// stdio: 'inherit',
// windowsHide: true,
// }
// },
onTick: () => {
const r = execSync('tsx src/index.ts --no-bot --ci', null, 'D:\\coding\\chatgpt-sites');
if (r.stderr) logger.error(r.stderr);
},
},
],
};
};
48 changes: 48 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "@lzwme/cron-tasks",
"version": "1.0.0",
"description": "A simple cron tasks manager based on Node.js",
"main": "src/index.mjs",
"bin": {
"tcron": "bin.js"
},
"type": "module",
"scripts": {
"version": "standard-version",
"release": "npm run version",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"cron",
"crontab",
"schedule",
"node-cron",
"cronjob"
],
"repository": "https://github.com/lzwme/cron-tasks.git",
"author": {
"name": "renxia",
"email": "[email protected]",
"url": "https://lzw.me"
},
"license": "MIT",
"engines": {
"node": ">=16.0.0"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.com"
},
"files": [
"src",
"bin.js",
"cron.config.sample.mjs"
],
"dependencies": {
"@lzwme/fe-utils": "^1.6.0",
"cron": "^3.1.6"
},
"devDependencies": {
"standard-version": "^9.5.0"
}
}
Loading

0 comments on commit 43c4d01

Please sign in to comment.