Skip to content

Commit

Permalink
feat: use new structure
Browse files Browse the repository at this point in the history
  • Loading branch information
afeiship committed Jul 25, 2024
1 parent aae8a58 commit debbcc7
Show file tree
Hide file tree
Showing 18 changed files with 69 additions and 196 deletions.
7 changes: 0 additions & 7 deletions .babelrc

This file was deleted.

11 changes: 0 additions & 11 deletions .editorconfig

This file was deleted.

9 changes: 6 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
node_modules
bower_components
coverage
npm-debug.log
yarn.lock
package-lock.json
.DS_Store
.idea
.vscode

# vscode localhistory
.history
dist

# package manager
npm-debug.log
yarn.lock
package-lock.json
pnpm-lock.yaml
5 changes: 5 additions & 0 deletions .ncurc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"upgrade": true,
"filter": "/^@jswork|@afeiship/",
"registry": "https://registry.npmjs.org"
}
27 changes: 0 additions & 27 deletions .npmignore

This file was deleted.

10 changes: 0 additions & 10 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,11 +1 @@
registry=https://registry.npm.taobao.org
disturl=https://npm.taobao.org/dist
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
phantomjs_cdnurl=https://npm.taobao.org/mirrors/phantomjs/
electron_mirror=https://npm.taobao.org/mirrors/electron/
chromedriver_cdnurl=https://npm.taobao.org/mirrors/chromedriver
operadriver_cdnurl=https://npm.taobao.org/mirrors/operadriver
selenium_cdnurl=https://npm.taobao.org/mirrors/selenium
node_inspector_cdnurl=https://npm.taobao.org/mirrors/node-inspector
fsevents_binary_host_mirror=http://npm.taobao.org/mirrors/fsevents/
package-lock=false
28 changes: 1 addition & 27 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,5 @@
"jsxBracketSameLine": true,
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"overrides": [
{
"files": "*.scss",
"options": {
"trailingComma": "none",
"tabWidth": 2,
"parser": "scss"
}
},
{
"files": "*.json",
"options": {
"trailingComma": "none",
"tabWidth": 2,
"parser": "json"
}
},
{
"files": "*.md",
"options": {
"trailingComma": "none",
"tabWidth": 2,
"parser": "json"
}
}
]
"singleQuote": true
}
13 changes: 5 additions & 8 deletions .release-it.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@
"requireCleanWorkingDir": false
},
"hooks": {
"after:init": [
"npm run test",
"t2k"
],
"after:bump": [
"npm run build"
]
"after:init": ["npm run test", "t2k"],
"after:bump": ["npm run build"],
"after:release": ["npm pkg get name | cnpm sync"]
},
"github": {
"release": true
"release": true,
"proxy": "http://127.0.0.1:9090"
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

## installation
```bash
npm install -S @jswork/next-gpid
yarn add @jswork/next-gpid
```

## usage
Expand Down
8 changes: 4 additions & 4 deletions __tests__/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ require('../src');

describe('api.basic test', () => {
test('nx.gpid basic case', function () {
var url = 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png';
var res = nx.gpid(url);
expect(res).toBe('googlelogo_color_272x92dp');
});
var url = 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png';
var res = nx.gpid(url);
expect(res).toBe('googlelogo_color_272x92dp');
});
});
13 changes: 0 additions & 13 deletions build/clean.js

This file was deleted.

22 changes: 0 additions & 22 deletions build/scripts.js

This file was deleted.

16 changes: 6 additions & 10 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
(function() {
'use strict';
const gulp = require('gulp');
const { NxScripts, CleanRegistry } = require('@jswork/gulp-registry');

const gulp = require('gulp');
const fs = require('fs');
const task1 = new CleanRegistry();
const task2 = new NxScripts({ name: 'qs', classify: false });

//import
fs.readdirSync('./build').map(function(file) {
require('./build/' + file);
});
[task1, task2].forEach(gulp.registry);

gulp.task('default', gulp.series(['clean', 'scripts']));
})();
gulp.task('default', gulp.series(['clean', 'nx:scripts']));
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
interface NxStatic {
gpid(inUrl: string): string;
gpid: any;
}
11 changes: 0 additions & 11 deletions jest.config.js

This file was deleted.

1 change: 0 additions & 1 deletion jest.setup.js

This file was deleted.

57 changes: 29 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,55 @@
"version": "1.0.2",
"description": "Get picture uid from url.",
"homepage": "https://js.work",
"files": [
"dist",
"index.d.ts"
],
"author": {
"name": "afei",
"email": "[email protected]"
},
"scripts": {
"build": "gulp",
"test": "jest",
"start": "node ./express.js",
"test": "bun test",
"release": "release-it"
},
"main": "dist/index.js",
"module": "dist/index.esm.js",
"license": "MIT",
"devDependencies": {
"@babel/core": "^7.13.14",
"@babel/preset-env": "^7.13.12",
"@jswork/gulp-pkg-header": "^1.0.4",
"@jswork/next": "^1.0.9",
"@babel/core": "^7.21.3",
"@babel/preset-env": "^7.20.2",
"@jswork/gulp-pkg-header": "^1.0.8",
"@jswork/gulp-registry": "^1.0.45",
"@jswork/next": "^1.2.2",
"@types/jest": "^29.5.12",
"del": "^6.0.0",
"gulp": "^4.0.2",
"gulp-babel": "^8.0.0",
"gulp-debug": "^4.0.0",
"gulp-header": "^2.0.9",
"gulp-ignore": "^3.0.0",
"gulp-load-plugins": "^2.0.6",
"gulp-prettier": "^4.0.0",
"gulp-rename": "^2.0.0",
"gulp-size": "^3.0.0",
"gulp-replace": "^1.1.4",
"gulp-uglify": "^3.0.2",
"jest": "^26.6.3",
"prettier": "^2.2.1",
"release-it": "^14.2.2",
"uglify-js": "3.12.4",
"husky": "^9.0.11",
"lint-staged": "^15.2.2",
"prettier": "^3.2.5",
"uglify-save-license": "^0.4.1"
},
"babel": {
"presets": [
[
"@babel/preset-env"
]
]
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
},
"boilerplate": "boilerplate-next-package",
"repository": {
"type": "git",
"url": "https://github.com/afeiship/boilerplate-next-package.git"
},
"keywords": [
"next",
"id",
"image",
"picture",
"pid",
"uid"
]
"lint-staged": {
"src/**/*.{js,jsx}": [
"npm run pretty"
]
}
}
23 changes: 11 additions & 12 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
(function () {
var global = typeof window !== 'undefined' ? window : this || Function('return this')();
var nx = global.nx || require('@jswork/next');
import nx from '@jswork/next';

nx.gpid = function (inUrl) {
var url = inUrl || location.href || '';
var filename = url.substring(url.lastIndexOf('/') + 1);
return filename.split('.')[0];
};
nx.gpid = function (inUrl) {
var url = inUrl || location.href || '';
var filename = url.substring(url.lastIndexOf('/') + 1);
return filename.split('.')[0];
};

if (typeof module !== 'undefined' && module.exports) {
module.exports = nx.gpid;
}
})();
if (typeof module !== 'undefined' && module.exports && typeof wx === 'undefined') {
module.exports = nx.gpid;
}

export default nx.gpid;

0 comments on commit debbcc7

Please sign in to comment.