Skip to content

Commit e9854f6

Browse files
authored
Merge pull request #204 from mailjet/version_4
Version 4
2 parents 6339510 + eb4dfdf commit e9854f6

File tree

178 files changed

+16985
-9783
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+16985
-9783
lines changed

.eslintrc.js

Lines changed: 0 additions & 29 deletions
This file was deleted.

.eslintrc.json

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"env": {
3+
"es2021": true,
4+
"node": true,
5+
"browser": true,
6+
"commonjs": true,
7+
"mocha": true
8+
},
9+
"extends": [
10+
"airbnb-base"
11+
],
12+
"parserOptions": {
13+
"ecmaVersion": 12
14+
},
15+
"settings": {
16+
"import/resolver": {
17+
"typescript": {},
18+
"node": {
19+
"extensions": [".js", ".ts"]
20+
}
21+
}
22+
},
23+
"ignorePatterns": ["dist/**", "docs/**", "examples/**"],
24+
"rules": {
25+
"tsdoc/syntax": "warn",
26+
"indent": ["error", 2, { "SwitchCase": 1 }],
27+
"semi": ["error", "always"],
28+
"quotes": ["error", "single"],
29+
"linebreak-style": ["error", "unix"],
30+
"spaced-comment": "off",
31+
"func-names": "off",
32+
"no-shadow": "off",
33+
"class-methods-use-this": "off",
34+
"dot-notation": "off",
35+
"no-param-reassign": ["error", { "props": false }],
36+
"lines-between-class-members": ["error", "always", { "exceptAfterSingleLine": true }]
37+
},
38+
"overrides": [
39+
{
40+
"files": ["*.ts"],
41+
"extends": [
42+
"plugin:@typescript-eslint/eslint-recommended",
43+
"plugin:@typescript-eslint/recommended"
44+
],
45+
"parser": "@typescript-eslint/parser",
46+
"rules": {
47+
"import/extensions": 0,
48+
"@typescript-eslint/no-shadow": ["error"],
49+
"@typescript-eslint/ban-types": [
50+
"error",
51+
{
52+
"extendDefaults": true,
53+
"types": {
54+
"{}": false
55+
}
56+
}
57+
]
58+
},
59+
"plugins": [
60+
"eslint-plugin-tsdoc",
61+
"@typescript-eslint"
62+
]
63+
}
64+
]
65+
}

.husky/commit-msg

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
# $1 - file path to temp file with commit message
5+
npx --no-install commitlint --edit "$1"

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npm run pkg:precommit

.npmignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ node_modules/
55
# Internal lib data
66
examples/
77
test/
8+
webpack/
89

910
# Coverage directory
1011
.coverage
12+
13+
# Docs
14+
docs/

CHANGELOG.md

Whitespace-only changes.

PreparePackage.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
const childProcess = require('child_process');
4+
5+
const DIST_PATH = path.join(__dirname, './dist');
6+
7+
function readJSONFile(filePath) {
8+
const source = fs.readFileSync(filePath).toString('utf-8');
9+
return JSON.parse(source);
10+
}
11+
12+
function changePackageData(packageData) {
13+
delete packageData.scripts;
14+
delete packageData.directories;
15+
delete packageData.devDependencies;
16+
delete packageData['standard-version'];
17+
18+
packageData.private = false;
19+
packageData.files = ['*'];
20+
21+
Object
22+
.entries(packageData)
23+
.forEach(([key, value]) => {
24+
if (key === 'typescript') {
25+
packageData[key].definition = value.definition.replace('./dist/', './');
26+
} else if (typeof value === 'string' && value.startsWith('./dist/')) {
27+
packageData[key] = value.replace('./dist/', './');
28+
}
29+
});
30+
}
31+
32+
function changePackageLockData(packageLockData) {
33+
delete packageLockData.packages;
34+
}
35+
36+
function main() {
37+
// ts declarations
38+
if (fs.existsSync(path.join(DIST_PATH, './declarations'))) {
39+
fs.rmSync(path.join(DIST_PATH, './declarations'), { recursive: true });
40+
}
41+
fs.renameSync(path.join(DIST_PATH, './lib'), path.join(DIST_PATH, './declarations'));
42+
43+
// package.json
44+
const packageData = readJSONFile(path.join(__dirname, './package.json'));
45+
changePackageData(packageData);
46+
47+
// common files
48+
fs.writeFileSync(path.join(DIST_PATH, './package.json'), Buffer.from(JSON.stringify(packageData, null, 2), 'utf-8').toString());
49+
fs.writeFileSync(path.join(DIST_PATH, './VERSION.md'), Buffer.from(packageData.version, 'utf-8').toString());
50+
51+
fs.copyFileSync(path.join(__dirname, 'LICENSE'), path.join(DIST_PATH, './LICENSE'));
52+
fs.copyFileSync(path.join(__dirname, 'README.md'), path.join(DIST_PATH, './README.md'));
53+
fs.copyFileSync(path.join(__dirname, 'CHANGELOG.md'), path.join(DIST_PATH, './CHANGELOG.md'));
54+
55+
// package-lock.json
56+
childProcess.execSync('npm i --prefix ./dist/ --package-lock-only');
57+
58+
const packageLockData = readJSONFile(path.join(DIST_PATH, './package-lock.json'));
59+
changePackageLockData(packageLockData);
60+
61+
fs.writeFileSync(path.join(DIST_PATH, './package-lock.json'), Buffer.from(JSON.stringify(packageLockData, null, 2), 'utf-8').toString());
62+
}
63+
64+
main();

0 commit comments

Comments
 (0)