Skip to content

Commit

Permalink
Merge pull request #204 from mailjet/version_4
Browse files Browse the repository at this point in the history
Version 4
  • Loading branch information
scroll17 authored Jun 10, 2022
2 parents 6339510 + eb4dfdf commit e9854f6
Show file tree
Hide file tree
Showing 178 changed files with 16,985 additions and 9,783 deletions.
29 changes: 0 additions & 29 deletions .eslintrc.js

This file was deleted.

65 changes: 65 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"env": {
"es2021": true,
"node": true,
"browser": true,
"commonjs": true,
"mocha": true
},
"extends": [
"airbnb-base"
],
"parserOptions": {
"ecmaVersion": 12
},
"settings": {
"import/resolver": {
"typescript": {},
"node": {
"extensions": [".js", ".ts"]
}
}
},
"ignorePatterns": ["dist/**", "docs/**", "examples/**"],
"rules": {
"tsdoc/syntax": "warn",
"indent": ["error", 2, { "SwitchCase": 1 }],
"semi": ["error", "always"],
"quotes": ["error", "single"],
"linebreak-style": ["error", "unix"],
"spaced-comment": "off",
"func-names": "off",
"no-shadow": "off",
"class-methods-use-this": "off",
"dot-notation": "off",
"no-param-reassign": ["error", { "props": false }],
"lines-between-class-members": ["error", "always", { "exceptAfterSingleLine": true }]
},
"overrides": [
{
"files": ["*.ts"],
"extends": [
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"rules": {
"import/extensions": 0,
"@typescript-eslint/no-shadow": ["error"],
"@typescript-eslint/ban-types": [
"error",
{
"extendDefaults": true,
"types": {
"{}": false
}
}
]
},
"plugins": [
"eslint-plugin-tsdoc",
"@typescript-eslint"
]
}
]
}
5 changes: 5 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

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

npm run pkg:precommit
4 changes: 4 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ node_modules/
# Internal lib data
examples/
test/
webpack/

# Coverage directory
.coverage

# Docs
docs/
Empty file added CHANGELOG.md
Empty file.
64 changes: 64 additions & 0 deletions PreparePackage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
const fs = require('fs');
const path = require('path');
const childProcess = require('child_process');

const DIST_PATH = path.join(__dirname, './dist');

function readJSONFile(filePath) {
const source = fs.readFileSync(filePath).toString('utf-8');
return JSON.parse(source);
}

function changePackageData(packageData) {
delete packageData.scripts;
delete packageData.directories;
delete packageData.devDependencies;
delete packageData['standard-version'];

packageData.private = false;
packageData.files = ['*'];

Object
.entries(packageData)
.forEach(([key, value]) => {
if (key === 'typescript') {
packageData[key].definition = value.definition.replace('./dist/', './');
} else if (typeof value === 'string' && value.startsWith('./dist/')) {
packageData[key] = value.replace('./dist/', './');
}
});
}

function changePackageLockData(packageLockData) {
delete packageLockData.packages;
}

function main() {
// ts declarations
if (fs.existsSync(path.join(DIST_PATH, './declarations'))) {
fs.rmSync(path.join(DIST_PATH, './declarations'), { recursive: true });
}
fs.renameSync(path.join(DIST_PATH, './lib'), path.join(DIST_PATH, './declarations'));

// package.json
const packageData = readJSONFile(path.join(__dirname, './package.json'));
changePackageData(packageData);

// common files
fs.writeFileSync(path.join(DIST_PATH, './package.json'), Buffer.from(JSON.stringify(packageData, null, 2), 'utf-8').toString());
fs.writeFileSync(path.join(DIST_PATH, './VERSION.md'), Buffer.from(packageData.version, 'utf-8').toString());

fs.copyFileSync(path.join(__dirname, 'LICENSE'), path.join(DIST_PATH, './LICENSE'));
fs.copyFileSync(path.join(__dirname, 'README.md'), path.join(DIST_PATH, './README.md'));
fs.copyFileSync(path.join(__dirname, 'CHANGELOG.md'), path.join(DIST_PATH, './CHANGELOG.md'));

// package-lock.json
childProcess.execSync('npm i --prefix ./dist/ --package-lock-only');

const packageLockData = readJSONFile(path.join(DIST_PATH, './package-lock.json'));
changePackageLockData(packageLockData);

fs.writeFileSync(path.join(DIST_PATH, './package-lock.json'), Buffer.from(JSON.stringify(packageLockData, null, 2), 'utf-8').toString());
}

main();
Loading

0 comments on commit e9854f6

Please sign in to comment.