Git Product home page Git Product logo

sharec's Introduction

Sharec

Sharec logo by Ivashkina Xenia <xeniaowl112@mail.ru>

.github/workflows/main.yml npm MIT License

With sharec you can share and manage configuration across projects, keep your code up to date and start new projects in one command.

Just transform this:

{
  "name": "my-awesome-project",
  "version": "1.0.0",
  "scripts": {
    "start": "NODE_ENV=development ./dev",
    "build": "rimraf dist && NODE_ENV=production ./build",
-   "eslint": "eslint ./src/**/*.js"
  },
- "husky": {
-   "hooks": {
-     "pre-commit": "lint-staged"
-   }
- },
- "lint-staged": {
-   "src/**/*.js": [
-     "eslint",
-     "prettier --write",
-     "git add"
-   ]
- },
- "browserslist": [
-   "last 2 version",
-   "> 1%"
- ],
- "babel": {
-   "presets": [
-     "@babel/preset-env"
-   ]
- },
- "prettier": {
-   "singleQuote": true,
-   "semi": false
- },
- "jest": {
-   "testURL": "http://localhost/",
-   "moduleNameMapper": {
-     "^src/(.*)$": "<rootDir>/src/$1"
-   }
- },
- "eslintConfig": {
-   "parser": "babel-eslint",
-   "env": {
-     "browser": true,
-     "es6": true,
-     "node": true,
-     "jest": true
-   },
-   "extends": "standard",
-   "rules": {
-     "space-before-function-paren": 0
-   },
-   "parserOptions": {
-     "ecmaVersion": 8,
-     "ecmaFeatures": {
-       "spread": true
-     },
-     "sourceType": "module"
-   }
- },
- "eslintIgnore": [
-   "/node_modules",
-   "/dist"
- ],
  "devDependencies": {
-   "@babel/core": "^7.0.1",
-   "@babel/preset-env": "^7.0.0",
-   "babel-core": "7.0.0-bridge.0",
-   "babel-eslint": "^10.0.0",
-   "babel-jest": "^23.6.0",
-   "eslint": "^5.6.0",
-   "eslint-config-standard": "^12.0.0",
-   "eslint-plugin-import": "^2.9.0",
-   "eslint-plugin-node": "^9.0.0",
-   "eslint-plugin-promise": "^4.0.1",
-   "eslint-plugin-standard": "^4.0.0",
-   "husky": "^2.0.0",
-   "lint-staged": "^8.0.4",
-   "prettier": "^1.11.1"
  }
}

To this:

{
  "name": "my-awesome-project",
  "version": "1.0.0",
  "scripts": {
    "start": "NODE_ENV=development ./dev",
    "build": "rimraf dist && NODE_ENV=production ./build",
  },
  "devDependencies": {
+    "my-awesome-config": "1.0.0"
  }
}

Continue reading on sharec.js.org

sharec's People

Contributors

ai avatar daiyam avatar dependabot[bot] avatar derom avatar epszaw avatar greenkeeper[bot] avatar kitcat-dev avatar meskill avatar tomrule007 avatar usmanyunusov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

sharec's Issues

Save quotes style in yaml files

Double quotes automatically changes to single quotes after strategy applying.

Guess, need to determine quotes style at the beginning and format file after strategy applying.

Relates to #75

Comments in JSON config

In ESLint documentation it's said that comments are allowed.

JSON - use .eslintrc.json to define the configuration structure. ESLint's JSON files also allow JavaScript-style comments.

However sharec fails to apply them

sharec: × Configuration was not fully applyed due unexpected error
SyntaxError: Unexpected token / in JSON at position 868

Publish .npmignore to sharec package

I have share config with:

configs/
  .travis.yml
  .npmignore

configs/.npmignore contains .travis.yml. As a result, I can’t put .travis.yml to sharec config package.

Let’s add alias for .npmignore (for instance npmignore) and sharec will rename config during postinstall.

Docs: Broken links

Looks like your PR #146 broken some of your links that were using relative paths.

<!-- https://sharec.js.org -->
<p>If you want read more detailed manual – look at 
<a href="packages/sharec-demo-config">official demo config</a>
and check <a href="packages/sharec">sharec</a> 
package if you looking for API reference.</p>

Prompt mode

Add prompt mode for allowing partial configuration applying.
Should works with --prompt option.

Codemods

This is a very big and important feature. We should allow users to add codemods for their files in sharec configuration packages.
May be, it should looks like inject in hygen. I don't know at this moment, how to do it better, but I guess - this is a really useful stuff.

Yaml converts with tabs, that cannot be formatted by prettier

And do not supported by github

Before
name: Node Library Config (Branch CI)

on:
  pull_request:
  push:
    branches:
      - main
      - master
      - develop

jobs:
  build:
    name: Build Project
    runs-on: ubuntu-20.04
    strategy:
      matrix:
        node-version: [12.x]
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node-version }}

      - run: rm -rf .npmrc
      - run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
      - run: npm install
      - run: npm run test
      - run: npm run build
      - run: npm publish
After
name: Node Library Config (Branch CI)
"on":
	pull_request: null
	push:
		branches:
			- main
			- master
			- develop
jobs:
	build:
		name: Build Project
		runs-on: ubuntu-20.04
		strategy:
			matrix:
				node-version:
					- 12.x
		steps:
			- name: Checkout code
				uses: actions/checkout@v2
			- name: "Use Node.js ${{ matrix.node-version }}"
				uses: actions/setup-node@v1
				with:
					node-version: "${{ matrix.node-version }}"
			- run: rm -rf .npmrc
			- run: >-
					echo "//npm.pkg.github.com/:_authToken=${{ secrets.NPM_TOKEN }}" >
					~/.npmrc
			- run: npm install
			- run: npm run test
			- run: npm run build
			- run: npm publish

Prettier

Keep local changes for package.json → scripts

I have in config

  "scripts": {
    "api": "documentation build *.js -f md -o api.md",
    "spell": "yarn api && yaspeller-ci *.md",
    "clean": "rimraf api.md coverage/",
    "test": "jest --coverage && eslint-ci . && size-limit && yarn spell"
  },

and in project:

  "scripts": {
    "api": "documentation build *.js -f md -o api.md",
    "spell": "yarn api && yaspeller-ci *.md",
    "clean": "rimraf api.md coverage/",
    "test": "jest --coverage && eslint-ci . && size-limit && yarn spell",
    "start": "parcel serve test/demo/index.html -d test/demo/build --open"
  },

When I updated the config, my start script was removed

Sharec change order of the package.json keys

git clone [email protected]:ai/nanoevents.git
yarn upgrade-interactive --latest
# Select @logux/sharec-config
git diff

Sharec will change package.json

   "yaspeller": {
     "lang": "en",
     "ignoreCapitalization": true,
-    "ignoreText": [
-      " \\(by [^)]+\\)."
-    ],
     "dictionary": [
       "EventEmitter",
       "gzipped",
@@ -92,9 +89,12 @@
       "npm",
       "unbindAll",
       "Versioning"
+    ],
+    "ignoreText": [
+      " \\(by [^)]+\\)."
     ]
   },

Composable strategies

I have idea of "composable" strategies.
It should make simple package.json merging or split all strategies for small units.
In the case of package.json:

const packageJsonStrategy = compose({
  scripts: hashStrategy,
  dependencies: hashStrategy,
  eslint: eslintStrategy,
  ...
})

Or for mixed structures, like yaspeller:

const yaspellerStrategy = compose({
  dictionary: listStrategy,
  ...
})

script with two equal subcommand

Describe the bug

Sharec rewrite script, if command have equal subcommand

image

Steps to reproduce the behavior

  1. Add to scripts:

"build:local": "next build && next export",

  1. reinstall sharec in project

Expected behavior

"build:local": "next build && next export",

Code snippets

node_modules/sharec/src/strategies/helpers/params/commandsToMap.js

      parsedCommand.set(subcommand, parsedSubcommand) //subcommand = "next"

System

[email protected]

Split large tests

Some tests very large and difficult for supporting, for example – strategies or commands.
If split them to small units – it would be more convenient in the future.

executable file

When a file is an executable in the config repository, the file isn't executable in the target project.

New Share doesn’t work correctly

  1. git clone https://github.com/ai/nanoevents.git
  2. cd nanoevents
  3. yarn
  4. yarn upgrade-interactive --latest and select @logux/sharec-config
  5. Sharec removed .travis,yml and .gitignore
  6. Sharec doesn’t add dependencies from config like eslint-plugin-unicorn

Typescript migration

At this moment sharec has a huge code base. I think, it is a good moment to use typescript here.
Because there is no any big feature in plans, I will start migration as soon as it possible. If someone wants to participate in migration process – welcome there ✨
New version will be released as v2.x.x, because I want to save all the original functionality.

Overwrites local .eslintrc.js config

I have .eslintrc.js both in the config and in my project. sharec replaces local .eslintrc.js with file from the config. Is this expected behaviour?

Remove `lodash` dependency

lodash is huge npm package. If you need only few functions, it is better to add like lodash.merge to package.json.

Can we have overrides?

Hi @lamartire, first of all bravo for this package. I also had the idea to simplify the build/setup process, but I couldn't have done it simpler than this. You had a very good idea, congrats 👏 !

I have a few more questions, before I set this up on my projects:

  • Is there a way to override the configuration files that will be installed?
  • Are all the configuration files supported, is it generic?

Once again, this is really cool. It replaces the need (for me) to setup lerna for my projects, it's minimalistic, waaay simpler and lightweight.

Merge eslintIgnore changes

Nano ID has eslintIgnore keys in package.json:

  "eslintIgnore": [
    "node_modules",
    "test/demo/build"
  ]

My sharec config has:

  "eslintIgnore": [
    "node_modules",
    "test/demo/build"
  ]

Every time when I update the config, sharec remove test/demo/build from package.json.

merge strategy problem in package.json

version: [email protected]

Hi

thanks for your great tool.

I found the merge strategy problem in package.json.

I just give an example for eslintconfig config.

the same problem appear in others,like postcss,babel and so on.

// package.json in share-config package
{
...
"eslintConfig": {
  "root": true
}
...
}

// package.json in business project
{
...
"eslintConfig": {}
}

when update share-config package in business project, the root field dosen't merge into package.json in business project.

but if i use other custom prop like this:

// package.json in share-config package
{
...
"eslintConfig": {
  "customProp": true
}
...
}

// package.json in business project
{
...
"eslintConfig": {}
}

it's ok.

i am not sure it is right or wrong for sharec?

Monorepo support

I have monorepo with sharec in the root. When I call npm install on the root (it triggers npm install in each package) I got unnecessary sharec changes in packages.

problematic command line

Hi,

I'm having an issue with the command npx fixpack || true in package.json/scripts.

I'm getting the error:

✖ Initializing sharec
TypeError: Cannot read property 'split' of undefined
    at /test/node_modules/sharec-schema/lib/helpers/commandsToMap.js:36:58
    at Array.reduce (<anonymous>)
    at commandsToMap (/test/node_modules/sharec-schema/lib/helpers/commandsToMap.js:22:30)
    at commandAtom (/test/node_modules/sharec-schema/lib/atoms/command.js:61:41)
    at /test/node_modules/sharec-schema/lib/actions/compose.js:46:9
    at /test/node_modules/sharec-schema/lib/actions/compose.js:83:65
    at /test/node_modules/sharec-schema/lib/actions/compose.js:46:9
    at Object.<anonymous> (/test/node_modules/sharec-schema/lib/actions/compose.js:82:69)
    at Object.processor (/test/node_modules/lodash/_createFlow.js:71:31)
    at /test/node_modules/sharec/src/steps/mergeConfigs.js:78:39

I've look at commandsToMap, it's splitting the command into subcommands and arguments. But why?

PS: I have to add || true because fixpack in return 1 even when it has successfully fixed the package.json

Problem with gitignore

Hi, I have some problem
When I run npx sharec gitignore does not convert to .gitignore(version sharec 3.2.1)
Could you please help me?

Working aliases

In new flow previous aliases were broken. Need to restore this functionality.
npmignore should be applied to .npmignore or just be written by this name.

Find solution to test fixtures on windows

At this moment, the most of fixture tests uses toWraplessEqual which unifies all line-wraps symbols to current OS EOL.
In this case, we can't correctly check EOF in formatting specs and other ones.
Need to remove toWraplessEqual matcher and find better solution for matching tests.

Disappear mode

It should install configuration without footprints – without cache and sharec meta-data in target project package.json.

Invalid updating flow

I have a config with these scripts in package.json.

  "scripts": {
    "api": "documentation build *.js -f md -o api.md",
    "spell": "yarn api && yaspeller-ci *.md",
    "clean": "rimraf api.md coverage/",
    "test": "jest --coverage && eslint-ci . && size-limit && yarn spell"
  },

I added this config to my project and changed api script:

  "scripts": {
-   "api": "documentation build *.js -f md -o api.md",
+   "api": "documentation build *.js async/*.js -f md -o api.md",
    "spell": "yarn api && yaspeller-ci *.md",
    "clean": "rimraf api.md coverage/",
    "test": "jest --coverage && eslint-ci . && size-limit && yarn spell"
  },

When I updated the script, sharec clean my api script changes

Special logic for scripts

It is very popular pattern to have && list of commands in package.json scripts:

  "test": "jest --coverage && eslint . && size-limit && yarn spell"

We can tread these scripts as lists: if locally one element changed we can ignore this element, but update others.

Of course, we should not hurry with this issue and do #47 first

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.