Skip to content

Commit

Permalink
feat: init project
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunqing committed Apr 13, 2022
1 parent 90483c2 commit 92d2abe
Show file tree
Hide file tree
Showing 27 changed files with 6,306 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
8 changes: 8 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"env": {
"jest": true
},
"extends": ["@antfu"],
"plugins": ["jest"],
"rules": {}
}
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: [antfu]
27 changes: 27 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Release

on:
push:
tags:
- 'v*'

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v2
with:
node-version: '14'
registry-url: https://registry.npmjs.org/
- run: npm i -g pnpm @antfu/ni
- run: nci
- run: nr test --if-present
# - run: npm publish --access public
# env:
# NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- run: npx conventional-github-releaser -p angular
env:
CONVENTIONAL_GITHUB_RELEASER_TOKEN: ${{secrets.GITHUB_TOKEN}}
42 changes: 42 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Test

on:
push:
branches:
- main
- master

pull_request:
branches:
- main
- master

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
matrix:
node-version: [12.x, 14.x]
os: [ubuntu-latest, windows-latest, macos-latest]
fail-fast: false

steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Setup
run: npm i -g pnpm @antfu/ni

- name: Install
run: nci

# - name: Lint
# run: nr lint --if-present

- name: Test
run: nr test --if-present
82 changes: 82 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Created by .ignore support plugin (hsz.mobi)
### Node template
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# 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

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://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/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

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

# next.js build output
.next

# nuxt.js build output
.nuxt

# Nuxt generate
dist

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless

# IDE
.idea
/*.d.ts
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignore-workspace-root-check=true
shamefully-hoist=true
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 dengqing
Copyright (c) 2022 dengqing <https://github.com/1247748612>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
108 changes: 108 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# unplugin-moment-to-dayjs

[![NPM version](https://img.shields.io/npm/v/unplugin-moment-to-dayjs?color=a1b858&label=)](https://www.npmjs.com/package/unplugin-moment-to-dayjs)

Starter template for [unplugin](https://github.com/unjs/unplugin).

## Template Usage

To use this template, clone it down using:

```bash
npx degit antfu/unplugin-moment-to-dayjs my-unplugin
```

And do a global replace of `unplugin-moment-to-dayjs` with your plugin name.

Then you can start developing your unplugin 🔥

To test your plugin, run: `pnpm run dev`
To release a new version, run: `pnpm run release`

## Install

```bash
npm i unplugin-moment-to-dayjs
```

<details>
<summary>Vite</summary><br>

```ts
// vite.config.ts
import Starter from 'unplugin-moment-to-dayjs/vite'

export default defineConfig({
plugins: [
Starter({ /* options */ }),
],
})
```

Example: [`playground/`](./playground/)

<br></details>

<details>
<summary>Rollup</summary><br>

```ts
// rollup.config.js
import Starter from 'unplugin-moment-to-dayjs/rollup'

export default {
plugins: [
Starter({ /* options */ }),
],
}
```

<br></details>


<details>
<summary>Webpack</summary><br>

```ts
// webpack.config.js
module.exports = {
/* ... */
plugins: [
require('unplugin-moment-to-dayjs/webpack')({ /* options */ })
]
}
```

<br></details>

<details>
<summary>Nuxt</summary><br>

```ts
// nuxt.config.js
export default {
buildModules: [
['unplugin-moment-to-dayjs/nuxt', { /* options */ }],
],
}
```

> This module works for both Nuxt 2 and [Nuxt Vite](https://github.com/nuxt/vite)
<br></details>

<details>
<summary>Vue CLI</summary><br>

```ts
// vue.config.js
module.exports = {
configureWebpack: {
plugins: [
require('unplugin-moment-to-dayjs/webpack')({ /* options */ }),
],
},
}
```

<br></details>
12 changes: 12 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
roots: [
'<rootDir>/test',
],
testMatch: [
'**/__tests__/**/*.+(ts|tsx|js)',
'**/?(*.)+(spec|test).+(ts|tsx|js)',
],
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest',
},
}
90 changes: 90 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"name": "unplugin-moment-to-dayjs",
"version": "0.1.0",
"description": "Register global imports on demand for Vite and Webpack",
"keywords": [
"unplugin",
"vite",
"webpack",
"rollup",
"transform"
],
"homepage": "https://github.com/antfu/unplugin-moment-to-dayjs#readme",
"bugs": {
"url": "https://github.com/antfu/unplugin-moment-to-dayjs/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/antfu/unplugin-moment-to-dayjs.git"
},
"license": "MIT",
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/index.mjs"
},
"./vite": {
"require": "./dist/vite.js",
"import": "./dist/vite.mjs"
},
"./webpack": {
"require": "./dist/webpack.js",
"import": "./dist/webpack.mjs"
},
"./rollup": {
"require": "./dist/rollup.js",
"import": "./dist/rollup.mjs"
},
"./nuxt": {
"require": "./dist/nuxt.js",
"import": "./dist/nuxt.mjs"
},
"./types": {
"require": "./dist/types.js",
"import": "./dist/types.mjs"
},
"./*": "./*"
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"dist",
"*.d.ts"
],
"scripts": {
"build": "tsup",
"dev": "tsup --watch src",
"build:fix": "esno scripts/postbuild.ts",
"lint": "eslint \"{src,test}/**/*.ts\"",
"lint:fix": "npm run lint -- --fix",
"play": "npm -C playground run dev",
"prepublishOnly": "npm run build",
"release": "bumpp --commit --push --tag && pnpm publish",
"start": "esno src/index.ts",
"test": "jest",
"test:update": "jest -u"
},
"dependencies": {
"unplugin": "^0.6.1"
},
"devDependencies": {
"@antfu/eslint-config": "^0.20.2",
"@types/jest": "^27.4.1",
"@types/node": "^16.11.26",
"bumpp": "^6.1.0",
"eslint": "^8.13.0",
"eslint-plugin-jest": "^26.1.4",
"esno": "^0.14.1",
"fast-glob": "^3.2.11",
"jest": "^27.5.1",
"nodemon": "^2.0.15",
"rimraf": "^3.0.2",
"rollup": "^2.70.1",
"ts-jest": "^27.1.4",
"tsup": "^5.12.5",
"typescript": "^4.6.3",
"vite": "^2.9.1",
"webpack": "^5.72.0"
}
}

0 comments on commit 92d2abe

Please sign in to comment.