Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@doodle/frontend-config / scripts / postinstall.js
Size: Mime:
const fs = require('fs');
const path = require('path');
const { version } = require('../package.json');

if (process.env.INIT_CWD === path.resolve()) {
  // Don't execute the script when running `npm install` on the library itself
  process.exit();
}

console.log(`
╔╦╗┌─┐┌─┐┌┬┐┬  ┌─┐  ┌─┐┬─┐┌─┐┌┐┌┌┬┐┌─┐┌┐┌┌┬┐  ┌─┐┌─┐┌┐┌┌─┐┬┌─┐  ┬┌┐┌┌─┐┌┬┐┌─┐┬  ┬  ┌─┐┬─┐
 ║║│ ││ │ │││  ├┤   ├┤ ├┬┘│ ││││ │ ├┤ │││ ││  │  │ ││││├┤ ││ ┬  ││││└─┐ │ ├─┤│  │  ├┤ ├┬┘
═╩╝└─┘└─┘─┴┘┴─┘└─┘  └  ┴└─└─┘┘└┘ ┴ └─┘┘└┘─┴┘  └─┘└─┘┘└┘└  ┴└─┘  ┴┘└┘└─┘ ┴ ┴ ┴┴─┘┴─┘└─┘┴└─
version ${version}

`);

const SRC_PATHS = {
  ESLINT: './boilerplate/.eslintrc.js',
  PRETTIER: './boilerplate/.prettierrc.js',
  WEBPACK: './boilerplate/webpack.config.js',
  BABEL: './boilerplate/babel.config.js',
  POSTCSS: './boilerplate/postcss.config.js',
  JEST: './boilerplate/jest.config.js',
  HUSKY: './boilerplate/.huskyrc.js',
  LINT_STAGED: './boilerplate/lint-staged.config.js',
};

const DEST_PATHS = {
  ESLINT: path.resolve(process.env.INIT_CWD, '.eslintrc.js'),
  PRETTIER: path.resolve(process.env.INIT_CWD, '.prettierrc.js'),
  WEBPACK: path.resolve(process.env.INIT_CWD, 'webpack.config.js'),
  BABEL: path.resolve(process.env.INIT_CWD, 'babel.config.js'),
  POSTCSS: path.resolve(process.env.INIT_CWD, 'postcss.config.js'),
  JEST: path.resolve(process.env.INIT_CWD, 'jest.config.js'),
  HUSKY: path.resolve(process.env.INIT_CWD, '.huskyrc.js'),
  LINT_STAGED: path.resolve(process.env.INIT_CWD, 'lint-staged.config.js'),
};

if (!fs.existsSync(DEST_PATHS.ESLINT)) {
  fs.copyFileSync(SRC_PATHS.ESLINT, DEST_PATHS.ESLINT);
  console.log(`✅ Created .eslintrc.js`);
}

if (!fs.existsSync(DEST_PATHS.PRETTIER)) {
  fs.copyFileSync(SRC_PATHS.PRETTIER, DEST_PATHS.PRETTIER);
  console.log(`✅ Created .prettierrc.js`);
}

if (!fs.existsSync(DEST_PATHS.WEBPACK)) {
  fs.copyFileSync(SRC_PATHS.WEBPACK, DEST_PATHS.WEBPACK);
  console.log(
    `✅ Created webpack.config.js - Please check the documentation as some configuration need to be set manually!`
  );
}

if (!fs.existsSync(DEST_PATHS.BABEL)) {
  fs.copyFileSync(SRC_PATHS.BABEL, DEST_PATHS.BABEL);
  console.log(`✅ Created babel.config.js`);
}

if (!fs.existsSync(DEST_PATHS.POSTCSS)) {
  fs.copyFileSync(SRC_PATHS.POSTCSS, DEST_PATHS.POSTCSS);
  console.log(`✅ Created postcss.config.js`);
}

if (!fs.existsSync(DEST_PATHS.JEST)) {
  fs.copyFileSync(SRC_PATHS.JEST, DEST_PATHS.JEST);
  console.log(`✅ Created jest.config.js`);
}

if (!fs.existsSync(DEST_PATHS.HUSKY)) {
  fs.copyFileSync(SRC_PATHS.HUSKY, DEST_PATHS.HUSKY);
  console.log(`✅ Created .huskyrc.js - Please check the documentation as some configuration need to be set manually!`);
}

if (!fs.existsSync(DEST_PATHS.LINT_STAGED)) {
  fs.copyFileSync(SRC_PATHS.LINT_STAGED, DEST_PATHS.LINT_STAGED);
  console.log(
    `✅ Created lint-staged.config.js - Please check the documentation as some configuration need to be set manually!`
  );
}