From 005852e3a2e5aa31d457452bd8602df4e05675c5 Mon Sep 17 00:00:00 2001 From: afeiship <1290657123@qq.com> Date: Wed, 3 Mar 2021 09:54:00 +0800 Subject: [PATCH] chore: use jswork scope --- .babelrc | 21 ++-- .gitignore | 4 + .npmignore | 17 +++- .prettierrc | 1 + .release-it.json | 14 +++ Gemfile | 5 - LICENSE.txt | 21 ++++ README.md | 88 ++++++++++++++--- Rakefile | 4 - __tests__/basic.test.js | 12 --- __tests__/index.spec.js | 12 +++ bin/docs.rb | 48 +++++++++ build/TEMPLATE.md | 50 ++++++++++ build/base.js | 29 ++++++ build/build.js | 21 ---- build/{dev.js => development.js} | 10 +- build/docs.js | 20 +++- build/index.js | 15 --- build/markdown.js | 30 ++++++ build/production.js | 22 +++++ build/release.js | 6 -- dist/index.js | 11 ++- dist/style.scss | 1 + docs/assets/bundle.543799c6ea8bb88b1d33.js | 35 ------- docs/assets/bundle.cd333132d4f9a48f679b.js | 71 ++++++++++++++ .../styles/main.31d4a06ab3a4445442c3.css | 2 + .../styles/main.aef6c218a0305c7bb1f1.css | 2 - docs/index.html | 17 +--- docs/sw.js | 3 + jest.config.js | 10 ++ jest.setup.js | 3 + jsconfig.json | 5 + package.json | 97 ++++++++++++------- public/assets/style.scss | 37 ++----- public/index.ejs | 7 +- public/index.js | 48 ++++++--- src/components/index.js | 27 ++++-- src/components/style.scss | 1 + webpack.config.babel.js | 3 +- 39 files changed, 589 insertions(+), 241 deletions(-) create mode 100644 .release-it.json delete mode 100644 Gemfile create mode 100644 LICENSE.txt delete mode 100644 Rakefile delete mode 100644 __tests__/basic.test.js create mode 100644 __tests__/index.spec.js create mode 100755 bin/docs.rb create mode 100644 build/TEMPLATE.md create mode 100644 build/base.js delete mode 100644 build/build.js rename build/{dev.js => development.js} (62%) delete mode 100644 build/index.js create mode 100644 build/markdown.js create mode 100644 build/production.js delete mode 100644 build/release.js delete mode 100644 docs/assets/bundle.543799c6ea8bb88b1d33.js create mode 100644 docs/assets/bundle.cd333132d4f9a48f679b.js create mode 100644 docs/assets/styles/main.31d4a06ab3a4445442c3.css delete mode 100644 docs/assets/styles/main.aef6c218a0305c7bb1f1.css create mode 100644 docs/sw.js create mode 100644 jest.config.js create mode 100644 jest.setup.js create mode 100644 jsconfig.json diff --git a/.babelrc b/.babelrc index c8c5fe5..ed26ba0 100644 --- a/.babelrc +++ b/.babelrc @@ -1,17 +1,14 @@ { - "presets": ["@babel/preset-env", "@babel/react"], - "plugins": [ - [ - "@babel/plugin-proposal-decorators", - { - "legacy": true - } - ], - [ - "@babel/plugin-proposal-class-properties", + "presets": [[ + "@babel/preset-env", { - "loose": true + "targets": { "browsers": [ "last 2 versions" ] } } - ] + ], "@babel/react"], + "plugins": [ + [ "@babel/plugin-proposal-decorators", { "legacy": true } ], + [ "@babel/plugin-proposal-class-properties", { "loose": true } ], + "@babel/plugin-proposal-optional-chaining", + "@babel/plugin-transform-parameters" ] } diff --git a/.gitignore b/.gitignore index 736ebbc..dfc9f5b 100644 --- a/.gitignore +++ b/.gitignore @@ -7,5 +7,9 @@ Gemfile.lock yarn-error.log package-lock.json .DS_Store +dist + +# editor .idea .vscode +.history diff --git a/.npmignore b/.npmignore index 71025a2..6289597 100644 --- a/.npmignore +++ b/.npmignore @@ -8,9 +8,8 @@ postcss.config.js Rakefile **/npm-debug.log **/node_modules -test -__test__ -__tests__ + +bin src docs build @@ -19,6 +18,18 @@ public tests postcss.config.js webpack.config.babel.js +example +examples +# vscode +jsconfig.json +.history +# tests +test +__test__ +__tests__ +jest.config.js +jest.setup.js +.release-it.json diff --git a/.prettierrc b/.prettierrc index cc1879e..afe7997 100644 --- a/.prettierrc +++ b/.prettierrc @@ -6,6 +6,7 @@ "jsxBracketSameLine": true, "tabWidth": 2, "semi": true, + "quoteProps": "consistent", "singleQuote": true, "overrides": [ { diff --git a/.release-it.json b/.release-it.json new file mode 100644 index 0000000..ed9a004 --- /dev/null +++ b/.release-it.json @@ -0,0 +1,14 @@ +{ + "hooks": { + "after:init": [ + "t2k" + ], + "after:bump": [ + "npm run docs", + "npm run build" + ] + }, + "github": { + "release": true + } +} \ No newline at end of file diff --git a/Gemfile b/Gemfile deleted file mode 100644 index 2b5ea5a..0000000 --- a/Gemfile +++ /dev/null @@ -1,5 +0,0 @@ -source 'https://rubygems.org' - -gem 'fileutils' -gem 'sshkit' -gem 'semver' diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..be1fbb9 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2020 afei <1290657123@qq.com> + +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. diff --git a/README.md b/README.md index 81114d0..bc7edd6 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,43 @@ # react-status-manager > React component for status manager. -## install +[![version][version-image]][version-url] +[![license][license-image]][license-url] +[![size][size-image]][size-url] +[![download][download-image]][download-url] + +## installation ```shell -npm install -S afeiship/react-status-manager +npm install -S @jswork/react-status-manager ``` +## properties +| Name | Type | Required | Default | Description | +| --------- | ------ | -------- | ------- | ------------------------------------- | +| className | string | false | - | The extended className for component. | +| items | array | false | [] | The status list. | +| value | any | false | - | Current status value. | +| nodeName | any | false | 'div' | The node name. | +| virtual | bool | false | false | If use React.Fragment element. | + + ## usage 1. import css ```scss - @import "~react-status-manager/style.scss"; + @import "~@jswork/react-status-manager/dist/style.css"; + + // or use sass + @import "~@jswork/react-status-manager/dist/style.scss"; // customize your styles: $react-status-manager-options: () ``` 2. import js ```js - import ReactStatusManager from '../src/main'; - import ReactDOM from 'react-dom'; + import ReactDemokit from '@jswork/react-demokit'; import React from 'react'; + import ReactDOM from 'react-dom'; + import ReactStatusManager from '@jswork/react-status-manager'; import './assets/style.scss'; class App extends React.Component { @@ -63,7 +82,9 @@ npm install -S afeiship/react-status-manager render() { return ( -
+ 已经结束 - - - - - - + + + + +

Wizard

- +
step1,input password
step2,input phone
@@ -106,7 +150,7 @@ npm install -S afeiship/react-status-manager step4,do submit!
- + ); } } @@ -117,3 +161,19 @@ npm install -S afeiship/react-status-manager ## documentation - https://afeiship.github.io/react-status-manager/ + + +## license +Code released under [the MIT license](https://github.com/afeiship/react-status-manager/blob/master/LICENSE.txt). + +[version-image]: https://img.shields.io/npm/v/@jswork/react-status-manager +[version-url]: https://npmjs.org/package/@jswork/react-status-manager + +[license-image]: https://img.shields.io/npm/l/@jswork/react-status-manager +[license-url]: https://github.com/afeiship/react-status-manager/blob/master/LICENSE.txt + +[size-image]: https://img.shields.io/bundlephobia/minzip/@jswork/react-status-manager +[size-url]: https://github.com/afeiship/react-status-manager/blob/master/dist/react-status-manager.min.js + +[download-image]: https://img.shields.io/npm/dm/@jswork/react-status-manager +[download-url]: https://www.npmjs.com/package/@jswork/react-status-manager diff --git a/Rakefile b/Rakefile deleted file mode 100644 index 3b186fa..0000000 --- a/Rakefile +++ /dev/null @@ -1,4 +0,0 @@ - -Dir["./node_modules/rake-*/index.rake"].each do |task| - load task -end diff --git a/__tests__/basic.test.js b/__tests__/basic.test.js deleted file mode 100644 index 00b7ed3..0000000 --- a/__tests__/basic.test.js +++ /dev/null @@ -1,12 +0,0 @@ -import React from 'react'; -import { render } from 'react-testing-library'; -import BoilerplateReactCompnent from '../src/main'; - -describe('Basic Test', () => { - it('renders to document', () => { - const { container } = render(); - const cnt = container.querySelector('.react-status-manager') - .innerHTML; - expect(cnt).toMatch(/Hello React/); - }); -}); diff --git a/__tests__/index.spec.js b/__tests__/index.spec.js new file mode 100644 index 0000000..624cbe1 --- /dev/null +++ b/__tests__/index.spec.js @@ -0,0 +1,12 @@ +import React from 'react'; +import { shallow } from 'enzyme'; +import BoilerplateReactCompnent from '../src/main'; + +describe('Basic Test', () => { + test('renders to document', () => { + const component = shallow(); + const cnt = component.find('.react-component'); + cnt.simulate('click'); + expect(cnt).toMatch(/Hello React/); + }); +}); diff --git a/bin/docs.rb b/bin/docs.rb new file mode 100755 index 0000000..0877a86 --- /dev/null +++ b/bin/docs.rb @@ -0,0 +1,48 @@ +#!/usr/bin/env ruby +require "net/http" +require "json" + +TOKEN = ENV["GITHUB_API_TOKEN"] + +class DocApp + def initialize + @uri = URI("https://api.github.com/repos/afeiship/react-status-manager/pages") + @http = Net::HTTP.new(@uri.host, @uri.port) + @http.use_ssl = true + + @header = { + 'Accept': "application/vnd.github.switcheroo-preview+json", + 'Authorization': "token #{TOKEN}", + 'Content-Type': "application/vnd.api+json", + } + + @data = { + "source": { + "branch": "master", + "path": "/docs", + }, + } + end + + def del + @req = Net::HTTP::Delete.new(@uri.path, @header) + @http.request(@req) + end + + def create + @req = Net::HTTP::Post.new(@uri.path, @header) + @req.body = @data.to_json + @http.request(@req) + end + + def set_doc + del + create + + puts "Has set master/docs to gh-pages!" + end +end + +# start app: +app = DocApp.new +app.set_doc diff --git a/build/TEMPLATE.md b/build/TEMPLATE.md new file mode 100644 index 0000000..b30224a --- /dev/null +++ b/build/TEMPLATE.md @@ -0,0 +1,50 @@ +# react-status-manager +> React component for status manager. + +[![version][version-image]][version-url] +[![license][license-image]][license-url] +[![size][size-image]][size-url] +[![download][download-image]][download-url] + +## installation +```shell +npm install -S @jswork/react-status-manager +``` + +## properties +__GENERATE_DOCS__ + +## usage +1. import css + ```scss + @import "~@jswork/react-status-manager/dist/style.css"; + + // or use sass + @import "~@jswork/react-status-manager/dist/style.scss"; + + // customize your styles: + $react-status-manager-options: () + ``` +2. import js + ```js +__GENERATE_DAPP__ + ``` + +## documentation +- https://afeiship.github.io/react-status-manager/ + + +## license +Code released under [the MIT license](https://github.com/afeiship/react-status-manager/blob/master/LICENSE.txt). + +[version-image]: https://img.shields.io/npm/v/@jswork/react-status-manager +[version-url]: https://npmjs.org/package/@jswork/react-status-manager + +[license-image]: https://img.shields.io/npm/l/@jswork/react-status-manager +[license-url]: https://github.com/afeiship/react-status-manager/blob/master/LICENSE.txt + +[size-image]: https://img.shields.io/bundlephobia/minzip/@jswork/react-status-manager +[size-url]: https://github.com/afeiship/react-status-manager/blob/master/dist/react-status-manager.min.js + +[download-image]: https://img.shields.io/npm/dm/@jswork/react-status-manager +[download-url]: https://www.npmjs.com/package/@jswork/react-status-manager diff --git a/build/base.js b/build/base.js new file mode 100644 index 0000000..b0af4d4 --- /dev/null +++ b/build/base.js @@ -0,0 +1,29 @@ +import { + configs, + inputs, + loaders, + outputs, + plugins +} from '@jswork/webpack-lib-kits'; + +export default { + mode: configs.mode(), + entry: inputs.build(), + output: outputs.dev(), + resolve: { + extensions: configs.extensions(), + alias: configs.alias() + }, + module: { + rules: [ + loaders.babel(), + loaders.image(), + loaders.sass(), + loaders.version() + ] + }, + plugins: [ + plugins.progressBar(), + plugins.minCssExtract() + ] +}; diff --git a/build/build.js b/build/build.js deleted file mode 100644 index d22edcc..0000000 --- a/build/build.js +++ /dev/null @@ -1,21 +0,0 @@ -import baseConfig from '.'; -import merge from 'webpack-merge'; -import { - configs, - inputs, - outputs, - loaders, - plugins, - externals -} from '@feizheng/webpack-lib-kits'; - -export default merge(baseConfig, { - entry: inputs.build(), - output: outputs.build({ - library: 'ReactStatusManager' - }), - externals: externals.base({ - '@feizheng/noop': '@feizheng/noop' - }), - plugins: [plugins.clean(), plugins.copyStyles()] -}); diff --git a/build/dev.js b/build/development.js similarity index 62% rename from build/dev.js rename to build/development.js index a8205cf..2307ba7 100644 --- a/build/dev.js +++ b/build/development.js @@ -1,12 +1,6 @@ -import baseConfig from '.'; +import baseConfig from './base'; import merge from 'webpack-merge'; -import { - configs, - inputs, - outputs, - loaders, - plugins -} from '@feizheng/webpack-lib-kits'; +import { configs, inputs, outputs, loaders, plugins } from '@jswork/webpack-lib-kits'; export default merge(baseConfig, { entry: inputs.docs(), diff --git a/build/docs.js b/build/docs.js index 94c2fcd..d40e8e4 100644 --- a/build/docs.js +++ b/build/docs.js @@ -1,9 +1,23 @@ -import baseConfig from '.'; +import { + inputs, + outputs, + + plugins +} from '@jswork/webpack-lib-kits'; +import OfflinePlugin from 'offline-plugin'; import merge from 'webpack-merge'; -import { configs, inputs, outputs, loaders, plugins } from '@feizheng/webpack-lib-kits'; +import baseConfig from './base'; export default merge(baseConfig, { entry: inputs.docs(), output: outputs.docs(), - plugins: [plugins.clean(), plugins.html()] + plugins: [ + plugins.clean(), + plugins.html(), + new OfflinePlugin({ + ServiceWorker: { + events: true + } + }) + ] }); diff --git a/build/index.js b/build/index.js deleted file mode 100644 index 6c29a82..0000000 --- a/build/index.js +++ /dev/null @@ -1,15 +0,0 @@ -import { configs, inputs, outputs, loaders, plugins } from '@feizheng/webpack-lib-kits'; - -export default { - mode: configs.mode(), - entry: inputs.build(), - output: outputs.dev(), - resolve: { - extensions: configs.extensions(), - alias: configs.alias() - }, - module: { - rules: [loaders.babel(), loaders.image(), loaders.sass()] - }, - plugins: [plugins.minCssExtract()] -}; diff --git a/build/markdown.js b/build/markdown.js new file mode 100644 index 0000000..35ba0c2 --- /dev/null +++ b/build/markdown.js @@ -0,0 +1,30 @@ +const rmp = require('@jswork/react-markdown-props'); +const fs = require('fs'); +const indentString = require('indent-string'); + +require('@jswork/next'); +require('@jswork/next-replace-in-file'); + +nx.declare({ + statics: { + init: function() { + var instance = new this(); + instance.reset(); + instance.replace(); + } + }, + methods: { + reset: function() { + fs.copyFileSync('./build/TEMPLATE.md', './README.md'); + }, + replace: function() { + const docApp = fs.readFileSync('./public/index.js').toString(); + + nx.replaceInFile('README.md', [ + ['__GENERATE_DOCS__', rmp('./src/components/index.js')], + ['__GENERATE_DAPP__', indentString(docApp, 2)], + ['../src/main', '@jswork/react-status-manager'] + ]); + } + } +}); diff --git a/build/production.js b/build/production.js new file mode 100644 index 0000000..7ff7c95 --- /dev/null +++ b/build/production.js @@ -0,0 +1,22 @@ +import { + externals, + inputs, + outputs, + plugins +} from '@jswork/webpack-lib-kits'; +import merge from 'webpack-merge'; +import baseConfig from './base'; + +export default merge(baseConfig, { + entry: inputs.build(), + output: outputs.build({ + library: 'ReactStatusManager' + }), + devtool: 'source-map', + externals: externals.node(), + plugins: [ + plugins.banner(), + plugins.clean(), + plugins.copyStyles(), + ] +}); diff --git a/build/release.js b/build/release.js deleted file mode 100644 index e7523f4..0000000 --- a/build/release.js +++ /dev/null @@ -1,6 +0,0 @@ -import buildConfig from './build'; -import merge from 'webpack-merge'; -import { configs, inputs, outputs, loaders, plugins } from '@feizheng/webpack-lib-kits'; -export default merge(buildConfig, { - plugins: [plugins.semver()] -}); diff --git a/dist/index.js b/dist/index.js index d1e79fc..c2887e9 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1 +1,10 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("prop-types"),require("react"),require("react-dom"),require("classnames"),require("@feizheng/noop"),require("object-assign")):"function"==typeof define&&define.amd?define(["prop-types","react","react-dom","classnames","@feizheng/noop","object-assign"],t):"object"==typeof exports?exports.ReactStatusManager=t(require("prop-types"),require("react"),require("react-dom"),require("classnames"),require("@feizheng/noop"),require("object-assign")):e.ReactStatusManager=t(e["prop-types"],e.react,e["react-dom"],e.classnames,e["@feizheng/noop"],e["object-assign"])}(window,(function(e,t,r,n,o,i){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=6)}([function(t,r){t.exports=e},function(e,r){e.exports=t},function(e,t){e.exports=r},function(e,t){e.exports=n},function(e,t){e.exports=o},function(e,t){e.exports=i},function(e,t,r){"use strict";r.r(t);var n=r(1),o=r.n(n),i=(r(2),r(0)),u=r.n(i);r(3),r(4),r(5);function c(e){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function f(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function p(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function l(e,t){for(var r=0;r=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function p(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var r=0;rz.length&&z.push(e)}function I(e,t,n){return null==e?0:function e(t,n,r,l){var o=typeof t;"undefined"!==o&&"boolean"!==o||(t=null);var u=!1;if(null===t)u=!0;else switch(o){case"string":case"number":u=!0;break;case"object":switch(t.$$typeof){case a:case i:u=!0}}if(u)return r(l,t,""===n?"."+U(t,0):n),1;if(u=0,n=""===n?".":n+":",Array.isArray(t))for(var c=0;c