├── .editorconfig ├── .github └── workflows │ └── main.yml ├── .gitignore ├── .prettierignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── lerna.json ├── package-lock.json ├── package.json ├── packages ├── sharec-core │ ├── .npmignore │ ├── README.md │ ├── jest.setup.js │ ├── lib │ │ ├── index.js │ │ ├── pipes │ │ │ ├── babel │ │ │ │ ├── pipe.js │ │ │ │ ├── schema.js │ │ │ │ └── test │ │ │ │ │ ├── __snapshots__ │ │ │ │ │ ├── base.test.js.snap │ │ │ │ │ ├── listed.test.js.snap │ │ │ │ │ ├── pipe.test.js.snap │ │ │ │ │ ├── uniqueEnv.test.js.snap │ │ │ │ │ └── withEmpty.test.js.snap │ │ │ │ │ ├── base.test.js │ │ │ │ │ ├── listed.test.js │ │ │ │ │ ├── pipe.test.js │ │ │ │ │ ├── uniqueEnv.test.js │ │ │ │ │ └── withEmpty.test.js │ │ │ ├── browserslist │ │ │ │ ├── pipe.js │ │ │ │ ├── schema.js │ │ │ │ └── test │ │ │ │ │ ├── __snapshots__ │ │ │ │ │ ├── pipe.test.js.snap │ │ │ │ │ └── schema.test.js.snap │ │ │ │ │ ├── pipe.test.js │ │ │ │ │ └── schema.test.js │ │ │ ├── commitlint │ │ │ │ ├── pipe.js │ │ │ │ ├── schema.js │ │ │ │ └── test │ │ │ │ │ ├── __snapshots__ │ │ │ │ │ ├── pipe.test.js.snap │ │ │ │ │ └── schema.test.js.snap │ │ │ │ │ ├── pipe.test.js │ │ │ │ │ └── schema.test.js │ │ │ ├── default │ │ │ │ ├── pipe.js │ │ │ │ ├── schema.js │ │ │ │ └── test │ │ │ │ │ ├── __snapshots__ │ │ │ │ │ ├── pipe.test.js.snap │ │ │ │ │ └── schema.test.js.snap │ │ │ │ │ ├── pipe.test.js │ │ │ │ │ └── schema.test.js │ │ │ ├── eslint │ │ │ │ ├── pipe.js │ │ │ │ ├── schema.js │ │ │ │ └── test │ │ │ │ │ ├── __snapshots__ │ │ │ │ │ ├── pipe.test.js.snap │ │ │ │ │ └── schema.test.js.snap │ │ │ │ │ ├── pipe.test.js │ │ │ │ │ └── schema.test.js │ │ │ ├── eslintignore │ │ │ │ ├── pipe.js │ │ │ │ └── test │ │ │ │ │ ├── __snapshots__ │ │ │ │ │ └── pipe.test.js.snap │ │ │ │ │ └── pipe.test.js │ │ │ ├── gitignore │ │ │ │ ├── pipe.js │ │ │ │ └── test │ │ │ │ │ ├── __snapshots__ │ │ │ │ │ └── pipe.test.js.snap │ │ │ │ │ └── pipe.test.js │ │ │ ├── husky │ │ │ │ ├── schema.js │ │ │ │ └── test │ │ │ │ │ ├── __snapshots__ │ │ │ │ │ └── schema.test.js.snap │ │ │ │ │ └── schema.test.js │ │ │ ├── index.js │ │ │ ├── jest │ │ │ │ ├── schema.js │ │ │ │ └── test │ │ │ │ │ ├── __snapshots__ │ │ │ │ │ └── schema.test.js.snap │ │ │ │ │ └── schema.test.js │ │ │ ├── lintStaged │ │ │ │ ├── pipe.js │ │ │ │ ├── schema.js │ │ │ │ └── test │ │ │ │ │ ├── __snapshots__ │ │ │ │ │ ├── pipe.test.js.snap │ │ │ │ │ └── schema.test.js.snap │ │ │ │ │ ├── pipe.test.js │ │ │ │ │ └── schema.test.js │ │ │ ├── npmignore │ │ │ │ ├── pipe.js │ │ │ │ └── test │ │ │ │ │ ├── __snapshots__ │ │ │ │ │ └── pipe.test.js.snap │ │ │ │ │ └── pipe.test.js │ │ │ ├── package │ │ │ │ ├── pipe.js │ │ │ │ ├── schema.js │ │ │ │ └── test │ │ │ │ │ ├── __snapshots__ │ │ │ │ │ ├── pipe.test.js.snap │ │ │ │ │ └── schema.test.js.snap │ │ │ │ │ ├── pipe.test.js │ │ │ │ │ └── schema.test.js │ │ │ ├── pipes.test.js │ │ │ ├── postcss │ │ │ │ ├── schema.js │ │ │ │ └── test │ │ │ │ │ ├── __snapshots__ │ │ │ │ │ └── schema.test.js.snap │ │ │ │ │ └── schema.test.js │ │ │ ├── prettier │ │ │ │ ├── pipe.js │ │ │ │ ├── schema.js │ │ │ │ └── test │ │ │ │ │ ├── __snapshots__ │ │ │ │ │ ├── pipe.test.js.snap │ │ │ │ │ └── schema.test.js.snap │ │ │ │ │ ├── pipe.test.js │ │ │ │ │ └── schema.test.js │ │ │ ├── stylelint │ │ │ │ ├── pipe.js │ │ │ │ ├── schema.js │ │ │ │ └── test │ │ │ │ │ ├── __snapshots__ │ │ │ │ │ ├── pipe.test.js.snap │ │ │ │ │ └── schema.test.js.snap │ │ │ │ │ ├── pipe.test.js │ │ │ │ │ └── schema.test.js │ │ │ └── yaspeller │ │ │ │ ├── pipe.js │ │ │ │ ├── schema.js │ │ │ │ └── test │ │ │ │ ├── __snapshots__ │ │ │ │ ├── pipe.test.js.snap │ │ │ │ └── schema.test.js.snap │ │ │ │ ├── pipe.test.js │ │ │ │ └── schema.test.js │ │ ├── steps │ │ │ ├── applyRuntimeHook.js │ │ │ ├── index.js │ │ │ ├── mergeConfigsPackages.js │ │ │ ├── readCache.js │ │ │ ├── readConfigsPackages.js │ │ │ ├── readRuntimeConfig.js │ │ │ ├── readTargetPackage.js │ │ │ ├── test │ │ │ │ ├── __snapshots__ │ │ │ │ │ ├── readConfigsPackages.test.js.snap │ │ │ │ │ └── writeConfigs.test.js.snap │ │ │ │ ├── applyRuntimeHook.test.js │ │ │ │ ├── mergeConfigsPackages │ │ │ │ │ ├── __snapshots__ │ │ │ │ │ │ ├── configs.test.js.snap │ │ │ │ │ │ ├── mixed.test.js.snap │ │ │ │ │ │ ├── multiple.test.js.snap │ │ │ │ │ │ └── package.test.js.snap │ │ │ │ │ ├── base.test.js │ │ │ │ │ ├── configs.test.js │ │ │ │ │ ├── mixed.test.js │ │ │ │ │ ├── multiple.test.js │ │ │ │ │ └── package.test.js │ │ │ │ ├── readCache.test.js │ │ │ │ ├── readConfigsPackages.test.js │ │ │ │ ├── readTargetPackage.test.js │ │ │ │ ├── writeCache.test.js │ │ │ │ ├── writeConfigs.test.js │ │ │ │ └── writeLockdata.test.js │ │ │ ├── writeCache.js │ │ │ ├── writeConfigs.js │ │ │ └── writeLockdata.js │ │ └── test │ │ │ ├── __snapshots__ │ │ │ └── update.test.js.snap │ │ │ ├── install │ │ │ ├── __snapshots__ │ │ │ │ ├── base.test.js.snap │ │ │ │ ├── mishandled.test.js.snap │ │ │ │ ├── missingName.test.js.snap │ │ │ │ └── nested.test.js.snap │ │ │ ├── base.test.js │ │ │ ├── mishandled.test.js │ │ │ ├── missingName.test.js │ │ │ └── nested.test.js │ │ │ └── update.test.js │ ├── package-lock.json │ ├── package.json │ ├── tsconfig.json │ └── types │ │ ├── errors │ │ ├── InternalError.d.ts │ │ ├── causes.d.ts │ │ └── index.d.ts │ │ ├── index.d.ts │ │ ├── pipes │ │ ├── babel │ │ │ ├── pipe.d.ts │ │ │ └── schema.d.ts │ │ ├── browserslist │ │ │ └── pipe.d.ts │ │ ├── default │ │ │ ├── pipe.d.ts │ │ │ └── schema.d.ts │ │ ├── eslint │ │ │ ├── pipe.d.ts │ │ │ └── schema.d.ts │ │ ├── gitignore │ │ │ └── pipe.d.ts │ │ ├── husky │ │ │ └── schema.d.ts │ │ ├── index.d.ts │ │ ├── jest │ │ │ └── schema.d.ts │ │ ├── lintStaged │ │ │ ├── pipe.d.ts │ │ │ └── schema.d.ts │ │ ├── npmignore │ │ │ └── pipe.d.ts │ │ ├── package │ │ │ ├── pipe.d.ts │ │ │ └── schema.d.ts │ │ ├── postcss │ │ │ └── schema.d.ts │ │ ├── prettier │ │ │ ├── pipe.d.ts │ │ │ └── schema.d.ts │ │ ├── stylelint │ │ │ ├── pipe.d.ts │ │ │ └── schema.d.ts │ │ └── yaspeller │ │ │ ├── pipe.d.ts │ │ │ └── schema.d.ts │ │ └── steps │ │ ├── applyRuntimeHook.d.ts │ │ ├── index.d.ts │ │ ├── mergeConfigsPackages.d.ts │ │ ├── readCache.d.ts │ │ ├── readConfigsPackages.d.ts │ │ ├── readRuntimeConfig.d.ts │ │ ├── readTargetPackage.d.ts │ │ ├── writeCache.d.ts │ │ ├── writeConfigs.d.ts │ │ └── writeLockdata.d.ts ├── sharec-docs │ ├── .eleventy.js │ ├── .gitignore │ ├── CNAME │ ├── LICENSE │ ├── gulpfile.js │ ├── package-lock.json │ ├── package.json │ ├── scripts │ │ └── deploy.js │ ├── src │ │ ├── _data │ │ │ └── docs │ │ │ │ ├── 1_introduction.md │ │ │ │ ├── 2_quick_start.md │ │ │ │ ├── 3_how_it_works.md │ │ │ │ ├── 4_hooks.md │ │ │ │ ├── 5_multiple_configurations.md │ │ │ │ ├── 6_cli.md │ │ │ │ └── 7_ready_examples.md │ │ ├── _includes │ │ │ ├── icon.liquid │ │ │ ├── logo.liquid │ │ │ ├── main.liquid │ │ │ └── menu.liquid │ │ ├── assets │ │ │ ├── fonts │ │ │ │ └── .gitkeep │ │ │ ├── images │ │ │ │ ├── logo-alt.svg │ │ │ │ └── logo.svg │ │ │ └── svg │ │ │ │ └── .gitkeep │ │ ├── css │ │ │ ├── base.css │ │ │ └── main.css │ │ └── page.liquid │ ├── tailwind.config.js │ └── task │ │ ├── css.js │ │ ├── serve.js │ │ ├── static.js │ │ └── svg.js ├── sharec-schema │ ├── .npmignore │ ├── jest.setup.js │ ├── lib │ │ ├── actions │ │ │ ├── compose.js │ │ │ ├── fork.js │ │ │ ├── index.js │ │ │ ├── map.js │ │ │ └── test │ │ │ │ ├── compose │ │ │ │ ├── array.test.js │ │ │ │ ├── hash.test.js │ │ │ │ ├── mixed.test.js │ │ │ │ └── operators.test.js │ │ │ │ ├── fork.test.js │ │ │ │ └── map.test.js │ │ ├── atoms │ │ │ ├── command.js │ │ │ ├── hash.js │ │ │ ├── index.js │ │ │ ├── linesConcat.js │ │ │ ├── linesMerge.js │ │ │ ├── listConcat.js │ │ │ ├── listMerge.js │ │ │ ├── pair.js │ │ │ ├── primitive.js │ │ │ ├── rule.js │ │ │ └── test │ │ │ │ ├── __snapshots__ │ │ │ │ ├── linesConcat.test.js.snap │ │ │ │ └── linesMerge.test.js.snap │ │ │ │ ├── command.test.js │ │ │ │ ├── hash.test.js │ │ │ │ ├── linesConcat.test.js │ │ │ │ ├── linesMerge.test.js │ │ │ │ ├── listConcat.test.js │ │ │ │ ├── listMerge.test.js │ │ │ │ ├── pair.test.js │ │ │ │ ├── primitive.test.js │ │ │ │ └── rule.test.js │ │ ├── helpers │ │ │ ├── commandsToMap.js │ │ │ ├── index.js │ │ │ ├── linesToLists.js │ │ │ ├── test │ │ │ │ ├── commandsToMap.test.js │ │ │ │ ├── linesToLists.test.js │ │ │ │ └── trimEOF.test.js │ │ │ └── trimEOF.js │ │ ├── index.js │ │ ├── parsers │ │ │ ├── index.js │ │ │ ├── json.js │ │ │ ├── test │ │ │ │ ├── __snapshots__ │ │ │ │ │ ├── json.test.js.snap │ │ │ │ │ └── yaml.test.js.snap │ │ │ │ ├── json.test.js │ │ │ │ └── yaml.test.js │ │ │ └── yaml.js │ │ └── pipes │ │ │ ├── createJsonPipe.js │ │ │ ├── createYamlPipe.js │ │ │ ├── fromJson.js │ │ │ ├── fromYaml.js │ │ │ ├── index.js │ │ │ ├── toJson.js │ │ │ └── toYaml.js │ ├── package-lock.json │ ├── package.json │ ├── tsconfig.json │ └── types │ │ ├── actions │ │ ├── compose.d.ts │ │ ├── fork.d.ts │ │ ├── index.d.ts │ │ └── map.d.ts │ │ ├── atoms │ │ ├── command.d.ts │ │ ├── hash.d.ts │ │ ├── index.d.ts │ │ ├── linesConcat.d.ts │ │ ├── linesMerge.d.ts │ │ ├── listConcat.d.ts │ │ ├── listMerge.d.ts │ │ ├── pair.d.ts │ │ ├── primitive.d.ts │ │ └── rule.d.ts │ │ ├── helpers │ │ ├── commandsToMap.d.ts │ │ ├── index.d.ts │ │ ├── linesToLists.d.ts │ │ └── trimEOF.d.ts │ │ ├── index.d.ts │ │ ├── parsers │ │ ├── index.d.ts │ │ ├── json.d.ts │ │ └── yaml.d.ts │ │ └── pipes │ │ ├── createJsonPipe.d.ts │ │ ├── createYamlPipe.d.ts │ │ ├── fromJson.d.ts │ │ ├── fromYaml.d.ts │ │ ├── index.d.ts │ │ ├── toJson.d.ts │ │ └── toYaml.d.ts ├── sharec-utils │ ├── .npmignore │ ├── jest.setup.js │ ├── lib │ │ ├── format.js │ │ ├── fs.js │ │ ├── index.js │ │ ├── map.js │ │ ├── path.js │ │ ├── std.js │ │ └── test │ │ │ ├── __snapshots__ │ │ │ └── format.test.js.snap │ │ │ ├── format.test.js │ │ │ ├── fs.test.js │ │ │ └── map.test.js │ ├── package-lock.json │ ├── package.json │ ├── tsconfig.json │ └── types │ │ ├── format.d.ts │ │ ├── fs.d.ts │ │ ├── index.d.ts │ │ ├── map.d.ts │ │ ├── path.d.ts │ │ └── std.d.ts └── sharec │ ├── .npmignore │ ├── README.md │ ├── bin │ └── sharec │ ├── lib │ └── index.js │ ├── package-lock.json │ ├── package.json │ └── tsconfig.json └── test ├── fixtures ├── babel │ └── json │ │ ├── 00-base │ │ ├── current.json │ │ ├── result.json │ │ └── upcoming.json │ │ ├── 01-with-empty │ │ ├── current.json │ │ ├── result.json │ │ └── upcoming.json │ │ ├── 02-with-empty │ │ ├── current.json │ │ ├── result.json │ │ └── upcoming.json │ │ ├── 03-unique-env │ │ ├── current.json │ │ ├── result.json │ │ └── upcoming.json │ │ ├── 04-listed-values │ │ ├── current.json │ │ ├── result.json │ │ └── upcoming.json │ │ ├── 05-update │ │ ├── cached.json │ │ ├── current.json │ │ ├── result.json │ │ └── upcoming.json │ │ ├── 06-disappear │ │ ├── current.json │ │ ├── result.json │ │ └── upcoming.json │ │ └── 07-format │ │ ├── current.json │ │ ├── result.json │ │ └── upcoming.json ├── browserslist │ ├── json │ │ └── 00-array-like │ │ │ ├── current.json │ │ │ ├── result.json │ │ │ └── upcoming.json │ └── lines │ │ └── 00-base │ │ ├── current.txt │ │ ├── result.txt │ │ └── upcoming.txt ├── commitlint │ ├── json │ │ └── 00-base │ │ │ ├── current.json │ │ │ ├── result.json │ │ │ └── upcoming.json │ └── yaml │ │ └── 00-base │ │ ├── current.yaml │ │ ├── result.yaml │ │ └── upcoming.yaml ├── default │ ├── json │ │ ├── 00-base │ │ │ ├── cached.json │ │ │ ├── current.json │ │ │ ├── result.json │ │ │ └── upcoming.json │ │ ├── 01-handle-removed │ │ │ ├── cached.json │ │ │ ├── current.json │ │ │ ├── result.json │ │ │ └── upcoming.json │ │ ├── 02-formatting │ │ │ ├── current.json │ │ │ └── result.json │ │ └── 03-comments │ │ │ └── current.json │ └── yaml │ │ ├── 00-base │ │ ├── cached.yml │ │ ├── current.yml │ │ ├── result.yml │ │ └── upcoming.yml │ │ └── 01-formatting │ │ ├── current.yml │ │ └── result.yml ├── editorconfig │ └── lines │ │ ├── 00-base │ │ └── current.txt │ │ └── 01-tabs │ │ └── current.txt ├── eslint │ ├── json │ │ ├── 01-base │ │ │ ├── current.json │ │ │ ├── result.json │ │ │ └── upcoming.json │ │ ├── 02-update │ │ │ ├── cached.json │ │ │ ├── current.json │ │ │ ├── result.json │ │ │ └── upcoming.json │ │ ├── 03-disappear │ │ │ ├── current.json │ │ │ ├── result.json │ │ │ └── upcoming.json │ │ └── 04-format │ │ │ ├── current.json │ │ │ ├── result.json │ │ │ └── upcoming.json │ └── yaml │ │ └── 01-base │ │ ├── current.yaml │ │ ├── result.yaml │ │ └── upcoming.yaml ├── eslintignore │ ├── json │ │ └── 01-array-like │ │ │ ├── current.json │ │ │ ├── result.json │ │ │ └── upcoming.json │ └── lines │ │ ├── 00-base │ │ ├── current.txt │ │ ├── result.txt │ │ └── upcoming.txt │ │ └── 01-base │ │ ├── current.txt │ │ ├── result.txt │ │ └── upcoming.txt ├── gitignore │ └── lines │ │ ├── 00-base │ │ ├── current.txt │ │ ├── result.txt │ │ └── upcoming.txt │ │ ├── 01-base │ │ ├── current.txt │ │ ├── result.txt │ │ └── upcoming.txt │ │ └── 02-update │ │ ├── cached.txt │ │ ├── current.txt │ │ ├── result.txt │ │ └── upcoming.txt ├── husky │ └── json │ │ └── 00-base │ │ ├── cached.json │ │ ├── current.json │ │ ├── result.json │ │ └── upcoming.json ├── jest │ └── json │ │ └── 00-base │ │ ├── cached.json │ │ ├── current.json │ │ ├── result.json │ │ └── upcoming.json ├── lines │ └── lines │ │ ├── 00-merge │ │ ├── cached.txt │ │ ├── current.txt │ │ ├── result.txt │ │ └── upcoming.txt │ │ └── 01-concat │ │ ├── current.txt │ │ ├── result.txt │ │ └── upcoming.txt ├── lintStaged │ └── json │ │ └── 00-base │ │ ├── cached.json │ │ ├── current.json │ │ ├── result.json │ │ └── upcoming.json ├── list │ └── json │ │ ├── 00-concat-primitives │ │ ├── current.json │ │ ├── result.json │ │ └── upcoming.json │ │ ├── 01-merge-primitives │ │ ├── current.json │ │ ├── result.json │ │ └── upcoming.json │ │ ├── 02-merge-hashes │ │ ├── current.json │ │ ├── result.json │ │ └── upcoming.json │ │ └── 03-concat-hashes │ │ ├── current.json │ │ ├── result.json │ │ └── upcoming.json ├── npmignore │ └── lines │ │ ├── 00-base │ │ ├── current.txt │ │ ├── result.txt │ │ └── upcoming.txt │ │ ├── 01-base │ │ ├── current.txt │ │ ├── result.txt │ │ └── upcoming.txt │ │ └── 02-update │ │ ├── current.txt │ │ ├── result.txt │ │ └── upcoming.txt ├── package │ └── json │ │ ├── 00-base │ │ ├── cached.json │ │ ├── current.json │ │ ├── result.json │ │ └── upcoming.json │ │ ├── 01-install │ │ ├── current.json │ │ ├── result.json │ │ └── upcoming.json │ │ ├── 02-update │ │ ├── cached.json │ │ ├── current.json │ │ ├── result.json │ │ └── upcoming.json │ │ ├── 03-disappear │ │ ├── current.json │ │ ├── result.json │ │ └── upcoming.json │ │ ├── 04-overwrite │ │ ├── cached.json │ │ ├── current.json │ │ ├── result.json │ │ └── upcoming.json │ │ ├── 05-removed │ │ ├── cached.json │ │ ├── current.json │ │ ├── result.json │ │ └── upcoming.json │ │ ├── 06-format │ │ ├── current.json │ │ ├── result.json │ │ └── upcoming.json │ │ ├── 07-sharec-config │ │ └── current.json │ │ ├── 08-install-missing-name │ │ ├── current.json │ │ ├── result.json │ │ └── upcoming.json │ │ └── 09-install-mishandled │ │ ├── current.json │ │ ├── result.json │ │ └── upcoming.json ├── pair │ └── json │ │ ├── 00-base │ │ ├── cached.json │ │ ├── current.json │ │ ├── result.json │ │ └── upcoming.json │ │ └── 01-different-keys │ │ ├── current.json │ │ ├── result.json │ │ └── upcoming.json ├── postcss │ └── json │ │ └── 00-base │ │ ├── current.json │ │ ├── result.json │ │ └── upcoming.json ├── prettier │ ├── json │ │ ├── 00-base │ │ │ ├── cached.json │ │ │ ├── current.json │ │ │ ├── result.json │ │ │ └── upcoming.json │ │ └── 01-tabs │ │ │ └── current.json │ └── yaml │ │ └── 00-base │ │ ├── cached.yml │ │ ├── current.yml │ │ ├── result.yml │ │ └── upcoming.yml ├── rule │ └── json │ │ ├── 00-eslint │ │ ├── cached.json │ │ ├── current.json │ │ ├── result.json │ │ └── upcoming.json │ │ └── 01-hash │ │ ├── cached.json │ │ ├── current.json │ │ ├── result.json │ │ └── upcoming.json ├── sharec │ └── json │ │ └── 00-base │ │ └── current.json ├── stylelint │ └── json │ │ └── 00-base │ │ ├── current.json │ │ ├── result.json │ │ └── upcoming.json ├── travis │ └── yaml │ │ └── 00-base │ │ ├── cached.yml │ │ ├── current.yml │ │ ├── result.yml │ │ └── upcoming.yml └── yaspeller │ └── json │ ├── 00-base │ ├── current.json │ ├── result.json │ └── upcoming.json │ ├── 01-update │ ├── cached.json │ ├── current.json │ ├── result.json │ └── upcoming.json │ └── 02-disappear │ ├── current.json │ ├── result.json │ └── upcoming.json └── testUtils └── index.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | max_line_length = 80 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | **/node_modules 3 | .idea 4 | **/.idea 5 | .vscode 6 | **/.vscode 7 | .eslintcache 8 | **/.eslintcache 9 | *.log 10 | **/*.log 11 | .DS_Store 12 | **/dist 13 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | packages/sharec/test/fixtures 2 | packages/sharec-docs/**/*.html 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright 2019 Konstantin Epishev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "lerna": "2.11.0", 3 | "packages": [ 4 | "packages/sharec", 5 | "packages/sharec-utils", 6 | "packages/sharec-schema", 7 | "packages/sharec-core" 8 | ], 9 | "version": "3.2.1" 10 | } 11 | -------------------------------------------------------------------------------- /packages/sharec-core/.npmignore: -------------------------------------------------------------------------------- 1 | src/**/*.test.js 2 | docs 3 | -------------------------------------------------------------------------------- /packages/sharec-core/README.md: -------------------------------------------------------------------------------- 1 | # Sharec 2 | 3 | [![.github/workflows/main.yml](https://github.com/lamartire/sharec/workflows/.github/workflows/main.yml/badge.svg)](https://github.com/lamartire/sharec/actions) 4 | [![npm](https://img.shields.io/npm/v/sharec)](https://npmjs.com/sharec) 5 | ![MIT License](https://camo.githubusercontent.com/4481c7672053be9c676fbc983c040ca59fddfa19/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f6c2f6c6f6775782d70726f636573736f722e737667) 6 | 7 | Read more on [sharec.js.org](https://sharec.js.org/overview.html) 8 | -------------------------------------------------------------------------------- /packages/sharec-core/jest.setup.js: -------------------------------------------------------------------------------- 1 | jest.mock('sharec-utils/lib/std', () => { 2 | const fs = require('memfs').promises 3 | 4 | return { 5 | readdir: fs.readdir, 6 | makedir: fs.mkdir, 7 | readFile: fs.readFile, 8 | copyFile: fs.copyFile, 9 | writeFile: fs.writeFile, 10 | lstat: fs.lstat, 11 | stat: fs.stat, 12 | removeFile: fs.unlink, 13 | } 14 | }) 15 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/babel/pipe.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { map } = require('sharec-schema').actions 3 | const { createJsonPipe } = require('sharec-schema').pipes 4 | const { babelJson } = require('./schema') 5 | 6 | const babelJsonPipe = createJsonPipe([babelJson]) 7 | 8 | const babelPipe = map(['.babelrc', babelJsonPipe], ['.babelrc.json', babelJsonPipe], ['babelrc.json', babelJsonPipe]) 9 | 10 | module.exports = { 11 | pipe: babelPipe, 12 | } 13 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/babel/schema.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { compose } = require('sharec-schema').actions 3 | const { listConcatAtom, listMergeAtom, pairAtom } = require('sharec-schema').atoms 4 | 5 | const babelEnvJson = compose({ 6 | plugins: listMergeAtom(pairAtom), 7 | presets: listMergeAtom(pairAtom), 8 | }) 9 | 10 | const babelJson = compose({ 11 | env: compose({ 12 | $$default: babelEnvJson, 13 | }), 14 | plugins: listMergeAtom(pairAtom), 15 | presets: listMergeAtom(pairAtom), 16 | ignore: listConcatAtom, 17 | }) 18 | 19 | module.exports = { 20 | babelJson, 21 | } 22 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/babel/test/__snapshots__/base.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`strategies > pipes > babel > schema should merge babel json configs 1`] = ` 4 | Map { 5 | "presets" => Array [ 6 | Array [ 7 | "env", 8 | Map { 9 | "modules" => false, 10 | "targets" => Map { 11 | "browsers" => Array [ 12 | "> 1%", 13 | "last 2 versions", 14 | "not ie > 0", 15 | ], 16 | }, 17 | }, 18 | ], 19 | "stage-2", 20 | ], 21 | "plugins" => Array [ 22 | Array [ 23 | "syntax-dynamic-import", 24 | Map { 25 | "foo" => "bar", 26 | }, 27 | ], 28 | "lodash", 29 | ], 30 | "env" => Map { 31 | "test" => Map { 32 | "presets" => Array [ 33 | "env", 34 | "stage-2", 35 | ], 36 | "plugins" => Array [ 37 | "dynamic-import-node", 38 | ], 39 | }, 40 | }, 41 | "ignore" => Array [ 42 | "*.babelrc", 43 | ], 44 | } 45 | `; 46 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/babel/test/__snapshots__/listed.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`strategies > pipes > babel > schema should handle empty envs 1`] = ` 4 | Map { 5 | "presets" => Array [ 6 | Array [ 7 | "env", 8 | Map { 9 | "modules" => false, 10 | "targets" => Map { 11 | "browsers" => Array [ 12 | "> 1%", 13 | "last 2 versions", 14 | "not ie > 10", 15 | "not ie > 0", 16 | ], 17 | }, 18 | }, 19 | ], 20 | "stage-2", 21 | ], 22 | "plugins" => Array [ 23 | Array [ 24 | "syntax-dynamic-import", 25 | Map { 26 | "foo" => "bar", 27 | }, 28 | ], 29 | "lodash", 30 | ], 31 | "env" => Map { 32 | "test" => Map { 33 | "presets" => Array [ 34 | "env", 35 | "stage-2", 36 | ], 37 | "plugins" => Array [ 38 | "dynamic-import-node", 39 | ], 40 | }, 41 | }, 42 | "ignore" => Array [ 43 | "*.babelrc", 44 | "*.vue", 45 | ], 46 | } 47 | `; 48 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/babel/test/__snapshots__/pipe.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`strategies > pipes > babel > pipe should merge babel json configs 1`] = ` 4 | "{ 5 | \\"presets\\": [ 6 | [ 7 | \\"env\\", 8 | { 9 | \\"modules\\": false, 10 | \\"targets\\": { 11 | \\"browsers\\": [ 12 | \\"> 1%\\", 13 | \\"last 2 versions\\", 14 | \\"not ie > 0\\" 15 | ] 16 | } 17 | } 18 | ], 19 | \\"stage-2\\" 20 | ], 21 | \\"plugins\\": [ 22 | [ 23 | \\"syntax-dynamic-import\\", 24 | { 25 | \\"foo\\": \\"bar\\" 26 | } 27 | ], 28 | \\"lodash\\" 29 | ], 30 | \\"env\\": { 31 | \\"test\\": { 32 | \\"presets\\": [ 33 | \\"env\\", 34 | \\"stage-2\\" 35 | ], 36 | \\"plugins\\": [ 37 | \\"dynamic-import-node\\" 38 | ] 39 | } 40 | }, 41 | \\"ignore\\": [ 42 | \\"*.babelrc\\" 43 | ] 44 | }" 45 | `; 46 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/babel/test/__snapshots__/uniqueEnv.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`strategies > pipes > babel > schema should handle unique envs 1`] = ` 4 | Map { 5 | "env" => Map { 6 | "test" => Map { 7 | "presets" => Array [ 8 | "env", 9 | ], 10 | }, 11 | "development" => Map { 12 | "presets" => Array [ 13 | "stage-2", 14 | ], 15 | }, 16 | }, 17 | } 18 | `; 19 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/babel/test/__snapshots__/withEmpty.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`strategies > pipes > babel > schema should handle empty envs 1`] = ` 4 | Map { 5 | "env" => Map { 6 | "test" => Map { 7 | "presets" => Array [ 8 | "env", 9 | ], 10 | }, 11 | }, 12 | } 13 | `; 14 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/babel/test/base.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const { babelJson } = require('../schema') 3 | 4 | describe('strategies > pipes > babel > schema', () => { 5 | const babelBaseFxt = fixtures('babel/json/00-base', 'map') 6 | 7 | it('should merge babel json configs', () => { 8 | expect(babelJson(babelBaseFxt)).toMatchSnapshot() 9 | }) 10 | }) 11 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/babel/test/listed.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const { babelJson } = require('../schema') 3 | 4 | describe('strategies > pipes > babel > schema', () => { 5 | const babelListedValuesFxt = fixtures('babel/json/04-listed-values', 'map') 6 | 7 | it('should handle empty envs', () => { 8 | expect(babelJson(babelListedValuesFxt)).toMatchSnapshot() 9 | }) 10 | }) 11 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/babel/test/pipe.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const { pipe } = require('../pipe') 3 | 4 | describe('strategies > pipes > babel > pipe', () => { 5 | const babelBaseFxt = fixtures('babel/json/00-base') 6 | 7 | it('should merge babel json configs', () => { 8 | expect(pipe('.babelrc')(babelBaseFxt)).toMatchSnapshot() 9 | }) 10 | }) 11 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/babel/test/uniqueEnv.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const { babelJson } = require('../schema') 3 | 4 | describe('strategies > pipes > babel > schema', () => { 5 | const babelUniqueEnvFxt = fixtures('babel/json/03-unique-env', 'map') 6 | 7 | it('should handle unique envs', () => { 8 | expect(babelJson(babelUniqueEnvFxt)).toMatchSnapshot() 9 | }) 10 | }) 11 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/babel/test/withEmpty.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const { babelJson } = require('../schema') 3 | 4 | describe('strategies > pipes > babel > schema', () => { 5 | const babelWithEmptyFxt = fixtures('babel/json/01-with-empty', 'map') 6 | 7 | it('should handle empty envs', () => { 8 | expect(babelJson(babelWithEmptyFxt)).toMatchSnapshot() 9 | }) 10 | }) 11 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/browserslist/pipe.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { map } = require('sharec-schema').actions 3 | const { linesConcatAtom } = require('sharec-schema').atoms 4 | 5 | const browserslistPipe = map(['.browserslistrc', linesConcatAtom]) 6 | 7 | module.exports = { 8 | pipe: browserslistPipe, 9 | } 10 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/browserslist/schema.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { compose } = require('sharec-schema').actions 3 | const { listConcatAtom } = require('sharec-schema').atoms 4 | 5 | const browserslistJson = compose([listConcatAtom]) 6 | 7 | module.exports = { 8 | browserslistJson, 9 | } 10 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/browserslist/test/__snapshots__/pipe.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`strategies > pipes > browserslist should process browserslist configs 1`] = ` 4 | "last 1 version 5 | > 1% 6 | maintained node versions 7 | not dead" 8 | `; 9 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/browserslist/test/__snapshots__/schema.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`pipes > browserslist > schema JSON should merge configs 1`] = ` 4 | Array [ 5 | "last 1 version", 6 | "> 1%", 7 | "maintained node versions", 8 | "not dead", 9 | ] 10 | `; 11 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/browserslist/test/pipe.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const { pipe } = require('../pipe') 3 | 4 | describe('strategies > pipes > browserslist', () => { 5 | const browserslistBaseFxt = fixtures('browserslist/lines/00-base') 6 | 7 | it('should process browserslist configs', () => { 8 | expect(pipe('.browserslistrc')(browserslistBaseFxt)).toMatchSnapshot() 9 | }) 10 | }) 11 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/browserslist/test/schema.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const { browserslistJson } = require('../schema') 3 | 4 | describe('pipes > browserslist > schema', () => { 5 | describe('JSON', () => { 6 | const browserslistArrayLikeFxt = fixtures('browserslist/json/00-array-like', 'map') 7 | 8 | it('should merge configs', () => { 9 | expect(browserslistJson(browserslistArrayLikeFxt)).toMatchSnapshot() 10 | }) 11 | }) 12 | }) 13 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/commitlint/pipe.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { map } = require('sharec-schema').actions 3 | const { createJsonPipe, createYamlPipe } = require('sharec-schema').pipes 4 | const { commitlintJson } = require('./schema') 5 | 6 | const commitlintJsonPipe = createJsonPipe([commitlintJson]) 7 | const commitlintYamlPipe = createYamlPipe([commitlintJson]) 8 | 9 | const commitlintPipe = map( 10 | ['.commitlintrc.json', commitlintJsonPipe], 11 | ['.commitlintrc.yaml', commitlintYamlPipe], 12 | ['.commitlintrc.yml', commitlintYamlPipe], 13 | ) 14 | 15 | module.exports = { 16 | pipe: commitlintPipe, 17 | } 18 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/commitlint/schema.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { compose } = require('sharec-schema').actions 3 | const { ruleAtom, primitiveAtom } = require('sharec-schema').atoms 4 | 5 | const commitlintJson = compose({ 6 | parserPreset: primitiveAtom, 7 | rules: compose({ 8 | $$default: ruleAtom, 9 | }), 10 | $$default: primitiveAtom, 11 | }) 12 | 13 | module.exports = { 14 | commitlintJson, 15 | } 16 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/commitlint/test/__snapshots__/schema.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`pipes > commitlint > schema JSON should merge configs 1`] = ` 4 | Map { 5 | "parserPreset" => "other-parser", 6 | "rules" => Map { 7 | "body-leading-blank" => Array [ 8 | 2, 9 | "never", 10 | ], 11 | "body-max-line-length" => Array [ 12 | 2, 13 | "always", 14 | 100, 15 | ], 16 | "footer-leading-blank" => Array [ 17 | 1, 18 | "always", 19 | ], 20 | "type-enum" => Array [ 21 | 2, 22 | "always", 23 | Array [ 24 | "feat", 25 | "fix", 26 | "perf", 27 | "refactor", 28 | "revert", 29 | "style", 30 | "test", 31 | ], 32 | ], 33 | "footer-max-line-length" => Array [ 34 | 2, 35 | "always", 36 | 100, 37 | ], 38 | "header-max-length" => Array [ 39 | 2, 40 | "always", 41 | 100, 42 | ], 43 | }, 44 | } 45 | `; 46 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/commitlint/test/pipe.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const { pipe } = require('../pipe') 3 | 4 | describe('strategies > pipes > commitlint > pipe', () => { 5 | describe('JSON', () => { 6 | const commitlintFxt = fixtures('commitlint/json/00-base') 7 | 8 | it('should merge configs', () => { 9 | expect(pipe('.commitlintrc.json')(commitlintFxt)).toMatchSnapshot() 10 | }) 11 | }) 12 | 13 | describe('YAML', () => { 14 | const commitlintFxt = fixtures('commitlint/yaml/00-base') 15 | 16 | it('should merge configs', () => { 17 | expect(pipe('.commitlintrc.yaml')(commitlintFxt)).toMatchSnapshot() 18 | }) 19 | }) 20 | }) 21 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/commitlint/test/schema.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const { commitlintJson } = require('../schema') 3 | 4 | describe('pipes > commitlint > schema', () => { 5 | describe('JSON', () => { 6 | const commitlintFxt = fixtures('commitlint/json/00-base', 'map') 7 | 8 | it('should merge configs', () => { 9 | expect( 10 | commitlintJson({ 11 | current: commitlintFxt.current, 12 | upcoming: commitlintFxt.upcoming, 13 | }), 14 | ).toMatchSnapshot() 15 | }) 16 | }) 17 | }) 18 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/default/pipe.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { map } = require('sharec-schema').actions 3 | const { defaultJson } = require('./schema') 4 | const { createJsonPipe, createYamlPipe } = require('sharec-schema').pipes 5 | 6 | const defaultJsonPipe = createJsonPipe([defaultJson]) 7 | const defaultYamlPipe = createYamlPipe([defaultJson]) 8 | 9 | const defaultPipe = map([/\.json$/, defaultJsonPipe], [/\.ya?ml$/, defaultYamlPipe]) 10 | 11 | module.exports = { 12 | pipe: defaultPipe, 13 | } 14 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/default/schema.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { isMap } = require('sharec-utils').map 3 | const { compose, fork } = require('sharec-schema').actions 4 | const { hashAtom, listConcatAtom, primitiveAtom } = require('sharec-schema').atoms 5 | 6 | const defaultJson = compose({ 7 | $$default: fork([[Array.isArray, listConcatAtom], [isMap, hashAtom], primitiveAtom]), 8 | }) 9 | 10 | module.exports = { 11 | defaultJson, 12 | } 13 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/default/test/__snapshots__/pipe.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`strategies > pipes > eslint > pipe JSON should merge configs 1`] = ` 4 | "{ 5 | \\"foo\\": \\"baz\\", 6 | \\"bar\\": { 7 | \\"foo\\": \\"foo\\" 8 | }, 9 | \\"baz\\": { 10 | \\"foo\\": \\"bar\\", 11 | \\"bar\\": \\"baz\\" 12 | } 13 | }" 14 | `; 15 | 16 | exports[`strategies > pipes > eslint > pipe YAML should merge configs 1`] = ` 17 | "foo: baz 18 | bar: 19 | foo: foo 20 | baz: 21 | foo: bar 22 | bar: baz" 23 | `; 24 | 25 | exports[`strategies > pipes > eslint > pipe YAML should merge configs 2`] = ` 26 | "foo: baz 27 | bar: 28 | foo: foo 29 | baz: 30 | foo: bar 31 | bar: baz" 32 | `; 33 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/default/test/__snapshots__/schema.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`pipes > default > schema JSON should merge configs 1`] = ` 4 | Map { 5 | "foo" => "baz", 6 | "bar" => Map { 7 | "foo" => "foo", 8 | }, 9 | "baz" => Map { 10 | "foo" => "bar", 11 | "bar" => "baz", 12 | }, 13 | } 14 | `; 15 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/default/test/pipe.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const { pipe } = require('../pipe') 3 | 4 | describe('strategies > pipes > eslint > pipe', () => { 5 | describe('JSON', () => { 6 | const defaultFxt = fixtures('default/json/00-base') 7 | 8 | it('should merge configs', () => { 9 | expect(pipe('foo.json')(defaultFxt)).toMatchSnapshot() 10 | }) 11 | }) 12 | 13 | describe('YAML', () => { 14 | const defaultFxt = fixtures('default/yaml/00-base') 15 | 16 | it('should merge configs', () => { 17 | expect(pipe('foo.yaml')(defaultFxt)).toMatchSnapshot() 18 | expect(pipe('foo.yml')(defaultFxt)).toMatchSnapshot() 19 | }) 20 | }) 21 | }) 22 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/default/test/schema.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const { defaultJson } = require('../schema') 3 | 4 | describe('pipes > default > schema', () => { 5 | describe('JSON', () => { 6 | const defaultFxt = fixtures('default/json/00-base', 'map') 7 | 8 | it('should merge configs', () => { 9 | expect( 10 | defaultJson({ 11 | current: defaultFxt.current, 12 | upcoming: defaultFxt.upcoming, 13 | }), 14 | ).toMatchSnapshot() 15 | }) 16 | }) 17 | }) 18 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/eslint/pipe.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { map } = require('sharec-schema').actions 3 | const { eslintJson } = require('./schema') 4 | const { createJsonPipe, createYamlPipe } = require('sharec-schema').pipes 5 | 6 | const eslintJsonPipe = createJsonPipe([eslintJson]) 7 | const eslintYamlPipe = createYamlPipe([eslintJson]) 8 | 9 | const eslintPipe = map( 10 | ['.eslintrc', eslintJsonPipe], 11 | ['.eslintrc.json', eslintJsonPipe], 12 | ['eslintrc.json', eslintJsonPipe], 13 | ['.eslintrc.yaml', eslintYamlPipe], 14 | ['.eslintrc.yml', eslintYamlPipe], 15 | ) 16 | 17 | module.exports = { 18 | pipe: eslintPipe, 19 | } 20 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/eslint/schema.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { isMap } = require('sharec-utils').map 3 | const { compose, fork } = require('sharec-schema').actions 4 | const { ruleAtom, hashAtom, listConcatAtom, primitiveAtom } = require('sharec-schema').atoms 5 | 6 | const eslintJson = compose({ 7 | env: hashAtom, 8 | parserOptions: compose({ 9 | ecmaFeatures: fork([[isMap, hashAtom], primitiveAtom]), 10 | $$default: primitiveAtom, 11 | }), 12 | globals: hashAtom, 13 | extends: fork([[Array.isArray, listConcatAtom], primitiveAtom]), 14 | plugins: listConcatAtom, 15 | rules: compose({ 16 | $$default: ruleAtom, 17 | }), 18 | overrides: listConcatAtom, 19 | $$default: primitiveAtom, 20 | }) 21 | 22 | module.exports = { 23 | eslintJson, 24 | } 25 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/eslint/test/__snapshots__/schema.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`pipes > eslint > schema JSON should merge configs 1`] = ` 4 | Map { 5 | "env" => Map { 6 | "browser" => true, 7 | "es6" => true, 8 | "node" => true, 9 | "jest" => true, 10 | }, 11 | "globals" => Map { 12 | "foo" => true, 13 | "bar" => true, 14 | }, 15 | "extends" => "airbnb", 16 | "rules" => Map { 17 | "max-len" => Array [ 18 | "warn", 19 | 120, 20 | 4, 21 | Map { 22 | "ignoreUrls" => false, 23 | "ignoreComments" => true, 24 | "ignoreStrings" => false, 25 | }, 26 | ], 27 | "space-before-function-paren" => 1, 28 | "no-console" => 0, 29 | }, 30 | "parserOptions" => Map { 31 | "parser" => "babel-eslint", 32 | "ecmaVersion" => 7, 33 | "ecmaFeatures" => Map { 34 | "spread" => true, 35 | }, 36 | "sourceType" => "module", 37 | }, 38 | } 39 | `; 40 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/eslint/test/pipe.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const { pipe } = require('../pipe') 3 | 4 | describe('strategies > pipes > eslint > pipe', () => { 5 | describe('JSON', () => { 6 | const eslintFxt = fixtures('eslint/json/01-base') 7 | 8 | it('should merge configs', () => { 9 | expect(pipe('.eslintrc')(eslintFxt)).toMatchSnapshot() 10 | }) 11 | }) 12 | 13 | describe('YAML', () => { 14 | const eslintFxt = fixtures('eslint/yaml/01-base') 15 | 16 | it('should merge configs', () => { 17 | expect(pipe('.eslintrc.yaml')(eslintFxt)).toMatchSnapshot() 18 | }) 19 | }) 20 | }) 21 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/eslint/test/schema.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const { eslintJson } = require('../schema') 3 | 4 | describe('pipes > eslint > schema', () => { 5 | describe('JSON', () => { 6 | const eslintBaseFxt = fixtures('eslint/json/01-base', 'map') 7 | 8 | it('should merge configs', () => { 9 | expect( 10 | eslintJson({ 11 | current: eslintBaseFxt.current, 12 | upcoming: eslintBaseFxt.upcoming, 13 | }), 14 | ).toMatchSnapshot() 15 | }) 16 | }) 17 | }) 18 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/eslintignore/pipe.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { map } = require('sharec-schema').actions 3 | const { linesConcatAtom } = require('sharec-schema').atoms 4 | 5 | const eslintignorePipe = map(['.eslintignore', linesConcatAtom]) 6 | 7 | module.exports = { 8 | pipe: eslintignorePipe, 9 | } 10 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/eslintignore/test/__snapshots__/pipe.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`strategies > pipes > eslintignore should process eslintignore configs 1`] = ` 4 | "node_modules 5 | foo 6 | bar 7 | baz" 8 | `; 9 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/eslintignore/test/pipe.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const { pipe } = require('../pipe') 3 | 4 | describe('strategies > pipes > eslintignore', () => { 5 | const eslintignoreBaseFxt = fixtures('eslintignore/lines/00-base') 6 | 7 | it('should process eslintignore configs', () => { 8 | expect(pipe('.eslintignore')(eslintignoreBaseFxt)).toMatchSnapshot() 9 | }) 10 | }) 11 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/gitignore/pipe.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { map } = require('sharec-schema').actions 3 | const { linesConcatAtom } = require('sharec-schema').atoms 4 | 5 | const gitignorePipe = map([/^\.?gitignore$/, linesConcatAtom]) 6 | 7 | module.exports = { 8 | pipe: gitignorePipe, 9 | alias: '.gitignore', 10 | } 11 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/gitignore/test/__snapshots__/pipe.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`strategies > pipes > gitignore handles .gitignore files 1`] = ` 4 | "node_modules 5 | foo 6 | bar 7 | baz" 8 | `; 9 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/gitignore/test/pipe.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const { pipe } = require('../pipe') 3 | 4 | describe('strategies > pipes > gitignore', () => { 5 | const gitignoreBaseFxt = fixtures('gitignore/lines/00-base') 6 | 7 | it('handles .gitignore files', () => { 8 | expect(pipe('.gitignore')(gitignoreBaseFxt)).toMatchSnapshot() 9 | }) 10 | }) 11 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/husky/schema.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { compose } = require('sharec-schema').actions 3 | const { primitiveAtom } = require('sharec-schema').atoms 4 | 5 | const huskyJson = compose({ 6 | hooks: compose({ 7 | $$default: primitiveAtom, 8 | }), 9 | }) 10 | 11 | module.exports = { 12 | huskyJson, 13 | } 14 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/husky/test/__snapshots__/schema.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`pipes > husky > schema JSON should merge configs 1`] = ` 4 | Map { 5 | "hooks" => Map { 6 | "pre-commit" => "different-linter", 7 | "post-commit" => "echo 'yay'", 8 | }, 9 | } 10 | `; 11 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/husky/test/schema.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const { huskyJson } = require('../schema') 3 | 4 | describe('pipes > husky > schema', () => { 5 | describe('JSON', () => { 6 | const huskyBaseFxt = fixtures('husky/json/00-base', 'map') 7 | 8 | it('should merge configs', () => { 9 | expect(huskyJson(huskyBaseFxt)).toMatchSnapshot() 10 | }) 11 | }) 12 | }) 13 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/jest/test/__snapshots__/schema.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`pipes > jest > schema JSON should merge configs 1`] = ` 4 | Map { 5 | "testEnvironment" => "node", 6 | "clearMocks" => true, 7 | "cacheDirectory" => "./.cache", 8 | "extraGlobals" => Array [ 9 | "foo", 10 | "bar", 11 | "baz", 12 | ], 13 | "coverageThreshold" => Map { 14 | "global" => Map { 15 | "statements" => 100, 16 | }, 17 | }, 18 | } 19 | `; 20 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/jest/test/schema.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const { jestJson } = require('../schema') 3 | 4 | describe('pipes > jest > schema', () => { 5 | describe('JSON', () => { 6 | const jestBaseFxt = fixtures('jest/json/00-base', 'map') 7 | 8 | it('should merge configs', () => { 9 | expect(jestJson(jestBaseFxt)).toMatchSnapshot() 10 | }) 11 | }) 12 | }) 13 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/lintStaged/pipe.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { map } = require('sharec-schema').actions 3 | const { lintStagedJson } = require('./schema') 4 | const { createJsonPipe } = require('sharec-schema').pipes 5 | 6 | const lintStagedJsonPipe = createJsonPipe([lintStagedJson]) 7 | 8 | const lintStagedPipe = map(['.lintstagedrc', lintStagedJsonPipe]) 9 | 10 | module.exports = { 11 | pipe: lintStagedPipe, 12 | } 13 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/lintStaged/schema.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { compose, fork } = require('sharec-schema').actions 3 | const { listMergeAtom, primitiveAtom } = require('sharec-schema').atoms 4 | 5 | const lintStagedJson = compose({ 6 | $$default: fork([[Array.isArray, listMergeAtom(primitiveAtom)], primitiveAtom]), 7 | }) 8 | 9 | module.exports = { 10 | lintStagedJson, 11 | } 12 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/lintStaged/test/__snapshots__/pipe.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`pipes > lintStaged > pipe JSON should merge configs 1`] = ` 4 | "{ 5 | \\"src/**/*.{js,jsx,json}\\": [ 6 | \\"eslint --fix\\", 7 | \\"prettier --write\\", 8 | \\"git add\\" 9 | ], 10 | \\"src/**/*.css\\": [ 11 | \\"stylelint --fix\\", 12 | \\"prettier --write\\", 13 | \\"git add\\" 14 | ] 15 | }" 16 | `; 17 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/lintStaged/test/__snapshots__/schema.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`pipes > lintStaged > schema JSON should merge configs 1`] = ` 4 | Map { 5 | "src/**/*.{js,jsx,json}" => Array [ 6 | "eslint --fix", 7 | "prettier --write", 8 | "git add", 9 | ], 10 | "src/**/*.css" => Array [ 11 | "stylelint --fix", 12 | "prettier --write", 13 | "git add", 14 | ], 15 | } 16 | `; 17 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/lintStaged/test/pipe.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const { pipe } = require('../pipe') 3 | 4 | describe('pipes > lintStaged > pipe', () => { 5 | describe('JSON', () => { 6 | const lintStagedBaseFxt = fixtures('lintStaged/json/00-base') 7 | 8 | it('should merge configs', () => { 9 | expect(pipe('.lintstagedrc')(lintStagedBaseFxt)).toMatchSnapshot() 10 | }) 11 | }) 12 | }) 13 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/lintStaged/test/schema.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const { lintStagedJson } = require('../schema') 3 | 4 | describe('pipes > lintStaged > schema', () => { 5 | describe('JSON', () => { 6 | const lintStagedBaseFxt = fixtures('lintStaged/json/00-base', 'map') 7 | 8 | it('should merge configs', () => { 9 | expect(lintStagedJson(lintStagedBaseFxt)).toMatchSnapshot() 10 | }) 11 | }) 12 | }) 13 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/npmignore/pipe.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { map } = require('sharec-schema').actions 3 | const { linesConcatAtom } = require('sharec-schema').atoms 4 | 5 | const npmignorePipe = map([/^\.?npmignore$/, linesConcatAtom]) 6 | 7 | module.exports = { 8 | pipe: npmignorePipe, 9 | alias: '.npmignore', 10 | } 11 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/npmignore/test/__snapshots__/pipe.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`strategies > pipes > npmignore should process npmignore configs 1`] = ` 4 | "node_modules 5 | foo 6 | bar 7 | baz" 8 | `; 9 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/npmignore/test/pipe.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const { pipe } = require('../pipe') 3 | 4 | describe('strategies > pipes > npmignore', () => { 5 | const npmignoreBaseFxt = fixtures('npmignore/lines/00-base') 6 | 7 | it('should process npmignore configs', () => { 8 | expect(pipe('npmignore')(npmignoreBaseFxt)).toMatchSnapshot() 9 | }) 10 | }) 11 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/package/pipe.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { map } = require('sharec-schema').actions 3 | const { packageJson } = require('./schema') 4 | const { createJsonPipe } = require('sharec-schema').pipes 5 | 6 | const packageJsonPipe = createJsonPipe([packageJson]) 7 | 8 | const packagePipe = map(['package.json', packageJsonPipe]) 9 | 10 | module.exports = { 11 | pipe: packagePipe, 12 | } 13 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/package/test/pipe.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const { pipe } = require('../pipe') 3 | 4 | describe('pipes > package > pipe', () => { 5 | describe('JSON', () => { 6 | const packageBaseFxt = fixtures('package/json/00-base') 7 | 8 | it('should merge configs', () => { 9 | expect(pipe('package.json')(packageBaseFxt)).toMatchSnapshot() 10 | }) 11 | }) 12 | }) 13 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/package/test/schema.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const { packageJson } = require('../schema') 3 | 4 | describe('pipes > package > schema', () => { 5 | describe('JSON', () => { 6 | const packageBaseFxt = fixtures('package/json/00-base', 'map') 7 | 8 | it('should merge configs', () => { 9 | expect(packageJson(packageBaseFxt)).toMatchSnapshot() 10 | }) 11 | }) 12 | }) 13 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/postcss/schema.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { compose } = require('sharec-schema').actions 3 | const { hashAtom, primitiveAtom } = require('sharec-schema').atoms 4 | 5 | const postcssJson = compose({ 6 | plugins: hashAtom, 7 | $$default: primitiveAtom, 8 | }) 9 | 10 | module.exports = { 11 | postcssJson, 12 | } 13 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/postcss/test/__snapshots__/schema.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`pipes > postcss > schema merge should merge objects by one deep level 1`] = ` 4 | Map { 5 | "plugins" => Map { 6 | "postcss-partial-import" => Map {}, 7 | "postcss-custom-properties" => Map { 8 | "preserve" => true, 9 | }, 10 | "postcss-nested" => Map {}, 11 | "autoprefixer" => Map {}, 12 | }, 13 | } 14 | `; 15 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/postcss/test/schema.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const { postcssJson } = require('../schema') 3 | 4 | describe('pipes > postcss > schema', () => { 5 | const postcssBaseFxt = fixtures('postcss/json/00-base', 'map') 6 | 7 | describe('merge', () => { 8 | it('should merge objects by one deep level', () => { 9 | expect( 10 | postcssJson({ 11 | current: postcssBaseFxt.current, 12 | upcoming: postcssBaseFxt.upcoming, 13 | }), 14 | ).toMatchSnapshot() 15 | }) 16 | }) 17 | }) 18 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/prettier/pipe.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { map } = require('sharec-schema').actions 3 | const { prettierJson } = require('./schema') 4 | const { createJsonPipe, createYamlPipe } = require('sharec-schema').pipes 5 | 6 | const prettierJsonPipe = createJsonPipe([prettierJson]) 7 | const prettierYamlPipe = createYamlPipe([prettierJson]) 8 | 9 | const stylelintPipe = map( 10 | ['.prettierrc', prettierJsonPipe], 11 | ['.prettierrc.json', prettierJsonPipe], 12 | ['.prettierrc.yml', prettierYamlPipe], 13 | ['.prettierrc.yaml', prettierYamlPipe], 14 | ) 15 | 16 | module.exports = { 17 | pipe: stylelintPipe, 18 | } 19 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/prettier/schema.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { compose } = require('sharec-schema').actions 3 | const { primitiveAtom } = require('sharec-schema').atoms 4 | 5 | const prettierJson = compose({ 6 | $$default: primitiveAtom, 7 | }) 8 | 9 | module.exports = { 10 | prettierJson, 11 | } 12 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/prettier/test/__snapshots__/pipe.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`strategies > pipes > prettier > pipe JSON should merge configs 1`] = ` 4 | "{ 5 | \\"tab\\": true, 6 | \\"tabWidth\\": 2, 7 | \\"semi\\": true 8 | }" 9 | `; 10 | 11 | exports[`strategies > pipes > prettier > pipe YAML should merge configs 1`] = ` 12 | "tab: true 13 | tabWidth: 2 14 | semi: true" 15 | `; 16 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/prettier/test/__snapshots__/schema.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`pipes > prettier > schema JSON should merge configs 1`] = ` 4 | Map { 5 | "tab" => true, 6 | "tabWidth" => 2, 7 | "semi" => true, 8 | } 9 | `; 10 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/prettier/test/pipe.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const { pipe } = require('../pipe') 3 | 4 | describe('strategies > pipes > prettier > pipe', () => { 5 | describe('JSON', () => { 6 | const perttierFxt = fixtures('prettier/json/00-base') 7 | 8 | it('should merge configs', () => { 9 | expect(pipe('.prettierrc')(perttierFxt)).toMatchSnapshot() 10 | }) 11 | }) 12 | 13 | describe('YAML', () => { 14 | const perttierFxt = fixtures('prettier/yaml/00-base') 15 | 16 | it('should merge configs', () => { 17 | expect(pipe('.prettierrc.yaml')(perttierFxt)).toMatchSnapshot() 18 | }) 19 | }) 20 | }) 21 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/prettier/test/schema.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const { prettierJson } = require('../schema') 3 | 4 | describe('pipes > prettier > schema', () => { 5 | describe('JSON', () => { 6 | const prettierBaseFxt = fixtures('prettier/json/00-base', 'map') 7 | 8 | it('should merge configs', () => { 9 | expect(prettierJson(prettierBaseFxt)).toMatchSnapshot() 10 | }) 11 | }) 12 | }) 13 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/stylelint/pipe.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { map } = require('sharec-schema').actions 3 | const { stylelintJson } = require('./schema') 4 | const { createJsonPipe } = require('sharec-schema').pipes 5 | 6 | const stylelintJsonPipe = createJsonPipe([stylelintJson]) 7 | 8 | const stylelintPipe = map(['.stylelint', stylelintJsonPipe], ['.stylelint.json', stylelintJsonPipe]) 9 | 10 | module.exports = { 11 | pipe: stylelintPipe, 12 | } 13 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/stylelint/schema.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { compose, fork } = require('sharec-schema').actions 3 | const { ruleAtom, listConcatAtom, listMergeAtom, primitiveAtom, pairAtom } = require('sharec-schema').atoms 4 | 5 | const stylelintJson = compose({ 6 | extends: fork([[Array.isArray, listConcatAtom], primitiveAtom]), 7 | plugins: listConcatAtom, 8 | rules: compose({ 9 | $$default: ruleAtom, 10 | }), 11 | ignoreFiles: listConcatAtom, 12 | defaultSeverity: primitiveAtom, 13 | processors: listMergeAtom(pairAtom), 14 | }) 15 | 16 | module.exports = { 17 | stylelintJson, 18 | } 19 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/stylelint/test/__snapshots__/pipe.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`pipes > stylelint > pipe JSON should merge configs 1`] = ` 4 | "{ 5 | \\"extends\\": [ 6 | \\"stylelint-config-standard\\", 7 | \\"stylelint-config-recess-order\\" 8 | ], 9 | \\"rules\\": { 10 | \\"declaration-block-trailing-semicolon\\": null, 11 | \\"block-closing-brace-newline-before\\": null, 12 | \\"block-opening-brace-space-before\\": null, 13 | \\"at-rule-no-unknown\\": [ 14 | false, 15 | { 16 | \\"ignoreAtRules\\": [ 17 | \\"define-mixin\\", 18 | \\"mixin\\" 19 | ] 20 | } 21 | ], 22 | \\"color-named\\": \\"never\\" 23 | }, 24 | \\"processors\\": [ 25 | [ 26 | \\"stylelint-my-processor\\", 27 | { 28 | \\"optionOne\\": false 29 | } 30 | ], 31 | [ 32 | \\"some-other-processor\\", 33 | { 34 | \\"optionOne\\": false, 35 | \\"optionTwo\\": true 36 | } 37 | ], 38 | \\"another-processor\\" 39 | ] 40 | }" 41 | `; 42 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/stylelint/test/__snapshots__/schema.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`pipes > stylelint > schema JSON should merge configs 1`] = ` 4 | Map { 5 | "extends" => Array [ 6 | "stylelint-config-standard", 7 | "stylelint-config-recess-order", 8 | ], 9 | "rules" => Map { 10 | "declaration-block-trailing-semicolon" => null, 11 | "block-closing-brace-newline-before" => null, 12 | "block-opening-brace-space-before" => null, 13 | "at-rule-no-unknown" => Array [ 14 | false, 15 | Map { 16 | "ignoreAtRules" => Array [ 17 | "define-mixin", 18 | "mixin", 19 | ], 20 | }, 21 | ], 22 | "color-named" => "never", 23 | }, 24 | "processors" => Array [ 25 | Array [ 26 | "stylelint-my-processor", 27 | Map { 28 | "optionOne" => false, 29 | }, 30 | ], 31 | Array [ 32 | "some-other-processor", 33 | Map { 34 | "optionOne" => false, 35 | "optionTwo" => true, 36 | }, 37 | ], 38 | "another-processor", 39 | ], 40 | } 41 | `; 42 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/stylelint/test/pipe.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const { pipe } = require('../pipe') 3 | 4 | describe('pipes > stylelint > pipe', () => { 5 | describe('JSON', () => { 6 | const stylelintBaseFxt = fixtures('stylelint/json/00-base') 7 | 8 | it('should merge configs', () => { 9 | expect(pipe('.stylelint')(stylelintBaseFxt)).toMatchSnapshot() 10 | }) 11 | }) 12 | }) 13 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/stylelint/test/schema.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const { stylelintJson } = require('../schema') 3 | 4 | describe('pipes > stylelint > schema', () => { 5 | describe('JSON', () => { 6 | const stylelintFxt = fixtures('stylelint/json/00-base', 'map') 7 | 8 | it('should merge configs', () => { 9 | expect(stylelintJson(stylelintFxt)).toMatchSnapshot() 10 | }) 11 | }) 12 | }) 13 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/yaspeller/pipe.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { map } = require('sharec-schema').actions 3 | const { yaspellerJson } = require('./schema') 4 | const { createJsonPipe } = require('sharec-schema').pipes 5 | 6 | const yaspellerJsonPipe = createJsonPipe([yaspellerJson]) 7 | 8 | const yaspellerPipe = map(['.yaspellerrc', yaspellerJsonPipe], ['.yaspeller.json', yaspellerJsonPipe]) 9 | 10 | module.exports = { 11 | pipe: yaspellerPipe, 12 | } 13 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/yaspeller/schema.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { compose } = require('sharec-schema').actions 3 | const { primitiveAtom, listConcatAtom } = require('sharec-schema').atoms 4 | 5 | const yaspellerJson = compose({ 6 | excludeFiles: listConcatAtom, 7 | ignoreText: listConcatAtom, 8 | ignoreTags: listConcatAtom, 9 | dictionary: listConcatAtom, 10 | fileExtensions: listConcatAtom, 11 | $$default: primitiveAtom, 12 | }) 13 | 14 | module.exports = { 15 | yaspellerJson, 16 | } 17 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/yaspeller/test/__snapshots__/pipe.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`pipes > yaspeller > pipe JSON should merge configs 1`] = ` 4 | "{ 5 | \\"lang\\": \\"en\\", 6 | \\"ignoreCapitalization\\": false, 7 | \\"excludeFiles\\": [ 8 | \\"README-*.md\\", 9 | \\"CHANGELOG.md\\" 10 | ], 11 | \\"ignoreText\\": [ 12 | \\" \\\\\\\\(by [^)]+\\\\\\\\).\\" 13 | ], 14 | \\"ignoreTags\\": [ 15 | \\"foo\\" 16 | ], 17 | \\"dictionary\\": [ 18 | \\"cryptographically\\", 19 | \\"formatAsync\\", 20 | \\"generateAsync\\", 21 | \\"gzip\\", 22 | \\"gzipped\\", 23 | \\"Haskell\\", 24 | \\"js\\", 25 | \\"JSDoc\\", 26 | \\"nanoid\\", 27 | \\"Nim\\", 28 | \\"nonSecure\\", 29 | \\"npm\\", 30 | \\"UUID\\", 31 | \\"v4\\", 32 | \\"Versioning\\", 33 | \\"JS\\", 34 | \\"PouchDB\\", 35 | \\"CouchDB\\", 36 | \\"Async\\", 37 | \\"asyncGenerator\\", 38 | \\"CLI\\", 39 | \\"Clojure\\", 40 | \\"ClojureScript\\", 41 | \\"Crypto\\" 42 | ], 43 | \\"fileExtensions\\": [ 44 | \\"bar\\" 45 | ] 46 | }" 47 | `; 48 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/yaspeller/test/__snapshots__/schema.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`pipes > yaspeller > schema should merge yaspeller json configs 1`] = ` 4 | Map { 5 | "lang" => "en", 6 | "ignoreCapitalization" => false, 7 | "excludeFiles" => Array [ 8 | "README-*.md", 9 | "CHANGELOG.md", 10 | ], 11 | "ignoreText" => Array [ 12 | " \\\\(by [^)]+\\\\).", 13 | ], 14 | "ignoreTags" => Array [ 15 | "foo", 16 | ], 17 | "dictionary" => Array [ 18 | "cryptographically", 19 | "formatAsync", 20 | "generateAsync", 21 | "gzip", 22 | "gzipped", 23 | "Haskell", 24 | "js", 25 | "JSDoc", 26 | "nanoid", 27 | "Nim", 28 | "nonSecure", 29 | "npm", 30 | "UUID", 31 | "v4", 32 | "Versioning", 33 | "JS", 34 | "PouchDB", 35 | "CouchDB", 36 | "Async", 37 | "asyncGenerator", 38 | "CLI", 39 | "Clojure", 40 | "ClojureScript", 41 | "Crypto", 42 | ], 43 | "fileExtensions" => Array [ 44 | "bar", 45 | ], 46 | } 47 | `; 48 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/yaspeller/test/pipe.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const { pipe } = require('../pipe') 3 | 4 | describe('pipes > yaspeller > pipe', () => { 5 | describe('JSON', () => { 6 | const yaspellerBaseFxt = fixtures('yaspeller/json/00-base') 7 | 8 | it('should merge configs', () => { 9 | expect(pipe('.yaspellerrc')(yaspellerBaseFxt)).toMatchSnapshot() 10 | }) 11 | }) 12 | }) 13 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/pipes/yaspeller/test/schema.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const { yaspellerJson } = require('../schema') 3 | 4 | describe('pipes > yaspeller > schema', () => { 5 | const yaspellerBaseFxt = fixtures('yaspeller/json/00-base', 'map') 6 | 7 | it('should merge yaspeller json configs', () => { 8 | expect(yaspellerJson(yaspellerBaseFxt)).toMatchSnapshot() 9 | }) 10 | }) 11 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/steps/applyRuntimeHook.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | 3 | /** 4 | * @typedef {import('../').FlowContext} FlowContext 5 | * @typedef {import('../').FlowStep} FlowStep 6 | * @typedef {import('../').Semaphore} Semaphore 7 | */ 8 | 9 | /** 10 | * @param {'beforeMerge'|'afterMerge'} hook 11 | * @returns {FlowStep} 12 | */ 13 | const readRuntimeConfig = (hook) => async (context, semaphore) => { 14 | const { runtimeConfig = {} } = context 15 | 16 | if (!runtimeConfig[hook]) return context 17 | 18 | return runtimeConfig[hook](context, semaphore) 19 | } 20 | 21 | module.exports = readRuntimeConfig 22 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/steps/readRuntimeConfig.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { stat } = require('sharec-utils').std 3 | const { join } = require('sharec-utils').path 4 | 5 | /** 6 | * @typedef {import('../').FlowContext} FlowContext 7 | * @typedef {import('../').Semaphore} Semaphore 8 | */ 9 | 10 | /** 11 | * TODO: don't know how to cover the function with unit-tests 12 | * `require` can't work inside `memfs` 13 | * @param {FlowContext} context 14 | * @param {Semaphore} semaphore 15 | * @returns {Promise} 16 | */ 17 | const readRuntimeConfig = async (context, semaphore) => { 18 | const { targetPath } = context 19 | const runtimeConfigPath = join(targetPath, '.sharecrc.js') 20 | 21 | try { 22 | semaphore.start('Loading runtime configuration') 23 | 24 | await stat(runtimeConfigPath) 25 | } catch (err) { 26 | semaphore.warn('No runtime configuration found') 27 | 28 | return context 29 | } 30 | 31 | context.runtimeConfig = require(runtimeConfigPath) 32 | 33 | semaphore.success('Runtime configuration has been loaded') 34 | 35 | return context 36 | } 37 | 38 | module.exports = readRuntimeConfig 39 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/steps/readTargetPackage.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { readFile } = require('sharec-utils').std 3 | const { resolve } = require('sharec-utils').path 4 | 5 | /** 6 | * @typedef {import('../').FlowContext} FlowContext 7 | * @typedef {import('../').Semaphore} Semaphore 8 | */ 9 | 10 | /** 11 | * @param {FlowContext} context 12 | * @param {Semaphore} semaphore 13 | * @returns {Promise} 14 | */ 15 | const readTargetPackage = async (context, semaphore) => { 16 | semaphore.start('Loading package.json') 17 | 18 | try { 19 | const targetPackageJsonPath = resolve(context.targetPath, './package.json') 20 | const rawTargetPackageJson = await readFile(targetPackageJsonPath, 'utf8') 21 | 22 | context.targetPackage = JSON.parse(rawTargetPackageJson) 23 | 24 | return context 25 | } catch (err) { 26 | semaphore.fail("Can't continue without package.json") 27 | 28 | return context 29 | } 30 | } 31 | 32 | module.exports = readTargetPackage 33 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/steps/test/__snapshots__/readConfigsPackages.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`steps > readConfigsPackages has configs adds listed configs to the context 1`] = ` 4 | Array [ 5 | Object { 6 | "configs": Object { 7 | ".eslintrc": "bar", 8 | "package.json": "foo", 9 | }, 10 | "name": "awesome-config", 11 | "path": "/node_modules/awesome-config", 12 | "version": "1.0.0", 13 | }, 14 | Object { 15 | "configs": Object { 16 | ".eslintrc": "bar", 17 | "package.json": "foo", 18 | }, 19 | "name": "second-config", 20 | "path": "/node_modules/second-config", 21 | "version": "2.0.0", 22 | }, 23 | ] 24 | `; 25 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/steps/test/__snapshots__/writeConfigs.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`steps > writeConfigs with configs writes merged configs 1`] = ` 4 | "foo 5 | " 6 | `; 7 | 8 | exports[`steps > writeConfigs with configs writes merged configs 2`] = ` 9 | "bar 10 | " 11 | `; 12 | 13 | exports[`steps > writeConfigs with configs writes merged configs 3`] = ` 14 | "baz 15 | " 16 | `; 17 | -------------------------------------------------------------------------------- /packages/sharec-core/lib/steps/test/mergeConfigsPackages/__snapshots__/multiple.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`steps > mergeConfigsPackages > multiple without sharec config merges configs sequently 1`] = ` 4 | "{ 5 | \\"env\\": { 6 | \\"browser\\": true, 7 | \\"es6\\": true, 8 | \\"node\\": true, 9 | \\"jest\\": true 10 | } 11 | }" 12 | `; 13 | -------------------------------------------------------------------------------- /packages/sharec-core/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./types", 4 | "moduleResolution": "node", 5 | "allowJs": true, 6 | "checkJs": true, 7 | "declaration": true, 8 | "types": ["node", "jest"] 9 | }, 10 | "include": ["./lib/*.js"], 11 | "exclude": ["./lib/*.test.js"] 12 | } 13 | -------------------------------------------------------------------------------- /packages/sharec-core/types/errors/InternalError.d.ts: -------------------------------------------------------------------------------- 1 | export = InternalError 2 | declare class InternalError extends Error { 3 | /** 4 | * @param {string} message 5 | * @param {symbol} cause 6 | */ 7 | constructor(message: string, cause: symbol) 8 | cause: symbol 9 | } 10 | -------------------------------------------------------------------------------- /packages/sharec-core/types/errors/causes.d.ts: -------------------------------------------------------------------------------- 1 | export namespace ALREADY_INSTALLED { 2 | function message(): string 3 | const symbol: symbol 4 | } 5 | export namespace IS_DEPENDANT_OF_SHAREC { 6 | export function message_1(): string 7 | export { message_1 as message } 8 | const symbol_1: symbol 9 | export { symbol_1 as symbol } 10 | } 11 | export namespace IS_IGNORES_SHAREC { 12 | export function message_2(): string 13 | export { message_2 as message } 14 | const symbol_2: symbol 15 | export { symbol_2 as symbol } 16 | } 17 | export namespace CONFIGS_NOT_FOUND { 18 | export function message_3(path: any): string 19 | export { message_3 as message } 20 | const symbol_3: symbol 21 | export { symbol_3 as symbol } 22 | } 23 | export namespace DOES_NOT_HAVE_ANY_CONFIG { 24 | export function message_4(path: any): string 25 | export { message_4 as message } 26 | const symbol_4: symbol 27 | export { symbol_4 as symbol } 28 | } 29 | -------------------------------------------------------------------------------- /packages/sharec-core/types/errors/index.d.ts: -------------------------------------------------------------------------------- 1 | import errorCauses = require('./causes') 2 | import InternalError = require('./InternalError') 3 | export { errorCauses, InternalError } 4 | -------------------------------------------------------------------------------- /packages/sharec-core/types/pipes/babel/pipe.d.ts: -------------------------------------------------------------------------------- 1 | declare const babelPipe: Function 2 | export { babelPipe as pipe } 3 | -------------------------------------------------------------------------------- /packages/sharec-core/types/pipes/babel/schema.d.ts: -------------------------------------------------------------------------------- 1 | export const babelJson: Function 2 | -------------------------------------------------------------------------------- /packages/sharec-core/types/pipes/browserslist/pipe.d.ts: -------------------------------------------------------------------------------- 1 | declare const browserslistPipe: Function 2 | export { browserslistPipe as pipe } 3 | -------------------------------------------------------------------------------- /packages/sharec-core/types/pipes/default/pipe.d.ts: -------------------------------------------------------------------------------- 1 | declare const defaultPipe: Function 2 | export { defaultPipe as pipe } 3 | -------------------------------------------------------------------------------- /packages/sharec-core/types/pipes/default/schema.d.ts: -------------------------------------------------------------------------------- 1 | export const defaultJson: Function 2 | -------------------------------------------------------------------------------- /packages/sharec-core/types/pipes/eslint/pipe.d.ts: -------------------------------------------------------------------------------- 1 | declare const eslintPipe: Function 2 | export { eslintPipe as pipe } 3 | -------------------------------------------------------------------------------- /packages/sharec-core/types/pipes/eslint/schema.d.ts: -------------------------------------------------------------------------------- 1 | export const eslintJson: Function 2 | -------------------------------------------------------------------------------- /packages/sharec-core/types/pipes/gitignore/pipe.d.ts: -------------------------------------------------------------------------------- 1 | declare const gitignorePipe: Function 2 | export { gitignorePipe as pipe } 3 | export declare const alias: string 4 | -------------------------------------------------------------------------------- /packages/sharec-core/types/pipes/husky/schema.d.ts: -------------------------------------------------------------------------------- 1 | export const huskyJson: Function 2 | -------------------------------------------------------------------------------- /packages/sharec-core/types/pipes/jest/schema.d.ts: -------------------------------------------------------------------------------- 1 | export const jestJson: Function 2 | -------------------------------------------------------------------------------- /packages/sharec-core/types/pipes/lintStaged/pipe.d.ts: -------------------------------------------------------------------------------- 1 | declare const lintStagedPipe: Function 2 | export { lintStagedPipe as pipe } 3 | -------------------------------------------------------------------------------- /packages/sharec-core/types/pipes/lintStaged/schema.d.ts: -------------------------------------------------------------------------------- 1 | export const lintStagedJson: Function 2 | -------------------------------------------------------------------------------- /packages/sharec-core/types/pipes/npmignore/pipe.d.ts: -------------------------------------------------------------------------------- 1 | declare const npmignorePipe: Function 2 | export { npmignorePipe as pipe } 3 | export declare const alias: string 4 | -------------------------------------------------------------------------------- /packages/sharec-core/types/pipes/package/pipe.d.ts: -------------------------------------------------------------------------------- 1 | declare const packagePipe: Function 2 | export { packagePipe as pipe } 3 | -------------------------------------------------------------------------------- /packages/sharec-core/types/pipes/package/schema.d.ts: -------------------------------------------------------------------------------- 1 | export const packageJson: Function 2 | -------------------------------------------------------------------------------- /packages/sharec-core/types/pipes/postcss/schema.d.ts: -------------------------------------------------------------------------------- 1 | export const postcssJson: Function 2 | -------------------------------------------------------------------------------- /packages/sharec-core/types/pipes/prettier/pipe.d.ts: -------------------------------------------------------------------------------- 1 | declare const stylelintPipe: Function 2 | export { stylelintPipe as pipe } 3 | -------------------------------------------------------------------------------- /packages/sharec-core/types/pipes/prettier/schema.d.ts: -------------------------------------------------------------------------------- 1 | export const prettierJson: Function 2 | -------------------------------------------------------------------------------- /packages/sharec-core/types/pipes/stylelint/pipe.d.ts: -------------------------------------------------------------------------------- 1 | declare const stylelintPipe: Function 2 | export { stylelintPipe as pipe } 3 | -------------------------------------------------------------------------------- /packages/sharec-core/types/pipes/stylelint/schema.d.ts: -------------------------------------------------------------------------------- 1 | export const stylelintJson: Function 2 | -------------------------------------------------------------------------------- /packages/sharec-core/types/pipes/yaspeller/pipe.d.ts: -------------------------------------------------------------------------------- 1 | declare const yaspellerPipe: Function 2 | export { yaspellerPipe as pipe } 3 | -------------------------------------------------------------------------------- /packages/sharec-core/types/pipes/yaspeller/schema.d.ts: -------------------------------------------------------------------------------- 1 | export const yaspellerJson: Function 2 | -------------------------------------------------------------------------------- /packages/sharec-docs/.eleventy.js: -------------------------------------------------------------------------------- 1 | const Markdown = require('markdown-it') 2 | const { loadFront } = require('yaml-front-matter') 3 | 4 | const md = new Markdown() 5 | 6 | module.exports = (config) => { 7 | config.addDataExtension('md', contents => { 8 | const { __content, ...frontMatter } = loadFront(contents) 9 | 10 | return { 11 | ...frontMatter, 12 | body: md.render(__content), 13 | } 14 | }) 15 | } 16 | -------------------------------------------------------------------------------- /packages/sharec-docs/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | book 3 | -------------------------------------------------------------------------------- /packages/sharec-docs/CNAME: -------------------------------------------------------------------------------- 1 | sharec.js.org 2 | -------------------------------------------------------------------------------- /packages/sharec-docs/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Konstantin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/sharec-docs/scripts/deploy.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | const ghPages = require('gh-pages') 3 | 4 | console.info('Deploying...') 5 | 6 | ghPages.publish(path.resolve(__dirname, '../dist'), err => { 7 | if (err) { 8 | console.error('Deploy failed!') 9 | console.error(err) 10 | process.exit(1) 11 | } 12 | 13 | console.info('Deployed!') 14 | }) 15 | -------------------------------------------------------------------------------- /packages/sharec-docs/src/_data/docs/1_introduction.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Introduction 3 | permalink: '/' 4 | --- 5 | 6 | # Introduction 7 | 8 | With **sharec** you can share and manage configuration across projects, 9 | keep your code up to date and prepare new ones in one command. 10 | 11 | ## Potential use-cases 12 | 13 | - Versionable configuration packages 14 | - Boilerplates and project starters (like `create-react-app`) 15 | 16 | ## Supported configs 17 | 18 | At this moment, sharec supports: 19 | 20 | - `npmignore` 21 | - `eslint` 22 | - `eslintignore` 23 | - `babel` 24 | - `yaspeller` 25 | - `browserslist` 26 | - `postcss` 27 | - `gitignore` 28 | - `husky` 29 | - `jest` (only as `package.json` member) 30 | - `lint-staged` 31 | - `stylelint` 32 | - `commitlint` 33 | - `prettier` 34 | 35 | Other `.json` or `.yaml` files will be merged by keys. 36 | 37 | Files with different extension will be just copied. 38 | 39 | ## `.gitignore` and `.npmignore` 40 | 41 | If you want to include these files, you should name them without dot - 42 | `gitignore`, `npmignore`. It's necessary because originally named 43 | files won't be readed during installation. 44 | -------------------------------------------------------------------------------- /packages/sharec-docs/src/_data/docs/5_multiple_configurations.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Multiple configurations 3 | permalink: '/docs/multi_configs/' 4 | --- 5 | 6 | # Multiple configurations 7 | 8 | `sharec` supports multiple configuration package. 9 | 10 | You just need to install packages you need and pass them to `sharec.configs` 11 | field in your `package.json` file: 12 | 13 | ```json 14 | { 15 | "name": "my-awesome-project", 16 | "devDependencies": { 17 | "config-a": "0.0.1", 18 | "config-b": "0.1.0", 19 | "config-c": "1.0.0", 20 | "sharec": "3.0.0" 21 | }, 22 | "sharec": { 23 | "configs": ["config-a", "config-b", "config-c"] 24 | } 25 | } 26 | ``` 27 | 28 | ## How configs will be applyed 29 | 30 | Your configs will be merged in order you described in `sharec.configs`. 31 | 32 | Keep in mind, that next config can overwrite previous one. 33 | 34 | ## Use cases 35 | 36 | You can divide your configs by purporse: `javascript`, `css`, `git`, 37 | `utilities`, etc. And then combine them between each other to make them 38 | lighter and much more maintainable. 39 | -------------------------------------------------------------------------------- /packages/sharec-docs/src/_data/docs/6_cli.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: CLI API 3 | permalink: '/docs/cli_api/' 4 | --- 5 | 6 | # CLI API 7 | 8 | `sharec` ships only one command. Use it to apply all your configuration packages: 9 | 10 | ```shell 11 | npx sharec 12 | ``` 13 | 14 | ## Options 15 | 16 | **`--cache, -c`** - disables or enables cache for configuration versioning. Also in can place all the `cahce` to `.sharec` 17 | directory if you don't have `node_modules`. By default cache is enabled. 18 | 19 | - `true` – cache will be saved inside `/node_modules/.cache/sharec` 20 | - `false` – cache won't be saved 21 | - `include` – cache would be saved in `/.sharec/cache`, instead `node_modules` 22 | 23 | Examples: 24 | 25 | ```shell 26 | npx sharec --cache 27 | npx sharec --cache false 28 | npx sharec --cache include 29 | ``` 30 | -------------------------------------------------------------------------------- /packages/sharec-docs/src/_data/docs/7_ready_examples.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Ready examples 3 | permalink: '/docs/ready_examples/' 4 | --- 5 | 6 | # Ready examples 7 | 8 | - [sharec-essential-config](https://github.com/sharecjs/sharec-react-app) – just set of configs ready to apply 9 | - [sharec-react-app](https://github.com/sharecjs/sharec-react-app/blob/master/README.md) – attempt to reproduce `create-react-app` 10 | functionality just as pack of static files 11 | -------------------------------------------------------------------------------- /packages/sharec-docs/src/_includes/icon.liquid: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /packages/sharec-docs/src/_includes/logo.liquid: -------------------------------------------------------------------------------- 1 |
2 | Sharec logo 3 | Sharec 4 |
5 | -------------------------------------------------------------------------------- /packages/sharec-docs/src/_includes/menu.liquid: -------------------------------------------------------------------------------- 1 | 15 | -------------------------------------------------------------------------------- /packages/sharec-docs/src/assets/fonts/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharecjs/sharec/e4c1b8fa15173f695c7160c0a9437f3521cec584/packages/sharec-docs/src/assets/fonts/.gitkeep -------------------------------------------------------------------------------- /packages/sharec-docs/src/assets/svg/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharecjs/sharec/e4c1b8fa15173f695c7160c0a9437f3521cec584/packages/sharec-docs/src/assets/svg/.gitkeep -------------------------------------------------------------------------------- /packages/sharec-docs/src/css/base.css: -------------------------------------------------------------------------------- 1 | *, 2 | body { 3 | @apply leading-6; 4 | box-sizing: border-box; 5 | font-family: system-ui; 6 | } 7 | 8 | .menu-link { 9 | @apply block px-2 rounded hover:font-bold transition-colors duration-150; 10 | } 11 | 12 | .article { 13 | @apply max-w-4xl pt-4 pb-16 mx-auto text-base; 14 | 15 | h1 { 16 | @apply text-3xl my-4; 17 | } 18 | 19 | h2 { 20 | @apply text-2xl my-4; 21 | } 22 | 23 | h3 { 24 | @apply text-3xl my-4; 25 | } 26 | 27 | p { 28 | @apply my-1; 29 | } 30 | 31 | code, 32 | pre { 33 | @apply font-mono; 34 | } 35 | 36 | code { 37 | @apply inline-block py-0.5 px-1.5 rounded shadow bg-white; 38 | } 39 | 40 | pre { 41 | @apply my-4 overflow-x-auto; 42 | } 43 | 44 | pre > code { 45 | @apply w-full; 46 | } 47 | 48 | ul, 49 | ol { 50 | @apply pl-4; 51 | } 52 | 53 | ul { 54 | @apply list-disc; 55 | } 56 | 57 | ul > li { 58 | &:not(:last-child) { 59 | @apply mb-1; 60 | } 61 | } 62 | 63 | a { 64 | @apply font-medium underline; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /packages/sharec-docs/src/css/main.css: -------------------------------------------------------------------------------- 1 | @import 'reset.css'; 2 | @import './base.css'; 3 | @tailwind base; 4 | @tailwind utilities; 5 | -------------------------------------------------------------------------------- /packages/sharec-docs/src/page.liquid: -------------------------------------------------------------------------------- 1 | --- 2 | pagination: 3 | data: docs 4 | size: 1 5 | alias: doc 6 | permalink: '{{ docs[doc].permalink }}index.html' 7 | --- 8 | 9 | {% layout 'main.liquid' %} 10 | {% block title %} 11 | {{ docs[doc].title }} | Sharec 12 | {% endblock %} 13 | {% block content %} 14 |
15 | {{ docs[doc].body }} 16 |
17 | {% endblock %} 18 | -------------------------------------------------------------------------------- /packages/sharec-docs/tailwind.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | content: ['./src/**/*.liquid'], 3 | theme: { 4 | extend: {}, 5 | }, 6 | plugins: [], 7 | } 8 | -------------------------------------------------------------------------------- /packages/sharec-docs/task/css.js: -------------------------------------------------------------------------------- 1 | const gulp = require('gulp') 2 | const browserSync = require('browser-sync') 3 | const plumber = require('gulp-plumber') 4 | const sourcemaps = require('gulp-sourcemaps') 5 | const plumberErrorHandler = require('gulp-plumber-error-handler') 6 | const postCss = require('gulp-postcss') 7 | const cssnano = require('gulp-cssnano') 8 | const cond = require('gulp-if') 9 | 10 | const ENV = process.env.NODE_ENV || 'development' 11 | 12 | function css(cb) { 13 | gulp 14 | .src('src/css/main.css') 15 | .pipe( 16 | plumber({ 17 | errorHandler: plumberErrorHandler( 18 | 'Error was occurred during CSS compile', 19 | ), 20 | }), 21 | ) 22 | .pipe(postCss()) 23 | .pipe( 24 | cond( 25 | ENV === 'dev', 26 | sourcemaps.init({ 27 | loadMaps: true, 28 | }), 29 | ), 30 | ) 31 | .pipe(cond(ENV === 'development', sourcemaps.write())) 32 | .pipe(cond(ENV === 'production', cssnano())) 33 | .pipe( 34 | gulp.dest('dist/assets/css'), 35 | { 36 | overwrite: true, 37 | }, 38 | ) 39 | .pipe(browserSync.stream()) 40 | cb() 41 | } 42 | 43 | module.exports = { 44 | css, 45 | } 46 | -------------------------------------------------------------------------------- /packages/sharec-docs/task/serve.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | const browserSync = require('browser-sync').create() 3 | 4 | function serve(cb) { 5 | browserSync.init({ 6 | server: { 7 | baseDir: path.resolve(__dirname, '../dist/'), 8 | }, 9 | port: 3000, 10 | open: false, 11 | }) 12 | cb() 13 | } 14 | 15 | function reload(cb) { 16 | browserSync.reload() 17 | cb() 18 | } 19 | 20 | module.exports = { 21 | serve, 22 | reload, 23 | } 24 | -------------------------------------------------------------------------------- /packages/sharec-docs/task/static.js: -------------------------------------------------------------------------------- 1 | const gulp = require('gulp') 2 | 3 | function fonts(cb) { 4 | gulp.src('src/assets/fonts/**/*').pipe(gulp.dest('dist/assets/fonts')) 5 | cb() 6 | } 7 | 8 | function images(cb) { 9 | gulp.src('src/assets/images/**/*').pipe(gulp.dest('dist/assets/images')) 10 | cb() 11 | } 12 | 13 | function cname(cb) { 14 | gulp.src('CNAME').pipe(gulp.dest('dist')) 15 | cb() 16 | } 17 | 18 | module.exports = { 19 | fonts, 20 | images, 21 | cname, 22 | } 23 | -------------------------------------------------------------------------------- /packages/sharec-docs/task/svg.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | const browserSync = require('browser-sync') 3 | const gulp = require('gulp') 4 | const svgStore = require('gulp-svgstore') 5 | const svgMin = require('gulp-svgmin') 6 | const plumber = require('gulp-plumber') 7 | const plumberErrorHandler = require('gulp-plumber-error-handler') 8 | 9 | function svg(cb) { 10 | gulp 11 | .src('src/assets/svg/*.svg') 12 | .pipe( 13 | plumber({ 14 | errorHandler: plumberErrorHandler( 15 | 'Error was occurred during SVG compile', 16 | ), 17 | }), 18 | ) 19 | .pipe( 20 | svgMin(file => { 21 | return { 22 | plugins: [ 23 | { 24 | cleanupIDs: { 25 | prefix: `${path.basename( 26 | file.relative, 27 | path.extname(file.relative), 28 | )}-`, 29 | minify: true, 30 | }, 31 | }, 32 | ], 33 | } 34 | }), 35 | ) 36 | .pipe(svgStore({ inlineSvg: true })) 37 | .pipe(gulp.dest('dist/assets/svg')) 38 | .pipe(browserSync.stream()) 39 | cb() 40 | } 41 | 42 | module.exports = { 43 | svg, 44 | } 45 | -------------------------------------------------------------------------------- /packages/sharec-schema/.npmignore: -------------------------------------------------------------------------------- 1 | src/**/*.test.js 2 | -------------------------------------------------------------------------------- /packages/sharec-schema/jest.setup.js: -------------------------------------------------------------------------------- 1 | jest.mock('sharec-utils/lib/std', () => { 2 | const fs = require('memfs').promises 3 | 4 | return { 5 | readdir: fs.readdir, 6 | makedir: fs.mkdir, 7 | readFile: fs.readFile, 8 | copyFile: fs.copyFile, 9 | writeFile: fs.writeFile, 10 | lstat: fs.lstat, 11 | removeFile: fs.unlink, 12 | } 13 | }) 14 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/actions/fork.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | 3 | /** 4 | * Creates conditional sequence of functions with predicates 5 | * The last argument is default function 6 | * Each condition branch should be an array, where first element is predicate function 7 | * Second element is the target function and it will be applyed only if predicate return true 8 | * 9 | * ``` 10 | * const handler = arr => arr.map(item => item * item) 11 | * const identity = val => val 12 | * const forkTest = fork([[Array.isArray, handler], identity]) 13 | * 14 | * forkTest([1, 2, 3]) // [1, 4, 9] 15 | * forkTest(1) // 1 16 | * ``` 17 | * 18 | * @param {Array} cases 19 | * @returns {Function} 20 | */ 21 | const fork = (cases) => 22 | /** 23 | * @param {Object} params 24 | * @returns {*} 25 | */ 26 | (params) => { 27 | const targetCase = cases.find((c) => { 28 | if (!Array.isArray(c)) return c 29 | if (params.current) return c[0](params.current) 30 | 31 | return c[0](params.upcoming) 32 | }) 33 | const targetAtom = Array.isArray(targetCase) ? targetCase[1] : targetCase 34 | 35 | return targetAtom(params) 36 | } 37 | 38 | module.exports = fork 39 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/actions/index.js: -------------------------------------------------------------------------------- 1 | const compose = require('./compose') 2 | const fork = require('./fork') 3 | const map = require('./map') 4 | 5 | module.exports = { 6 | compose, 7 | fork, 8 | map, 9 | } 10 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/actions/map.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | 3 | /** 4 | * Maps functions by strings and RegExps 5 | * Mapped functions will be returned by given matchers 6 | * 7 | * ``` 8 | * const mapper = map(['foo', () => 1, 'bar', () => 2]) 9 | * 10 | * mapper('foo')() // 1 11 | * mapper('bar')() // 2 12 | * mapper('baz')() // null 13 | * ``` 14 | * 15 | * @param {...[string | RegExp, Function]} mappers 16 | * @returns {Function} 17 | */ 18 | const map = (...mappers) => 19 | /** 20 | * @param {string} filename 21 | * @returns {Function} 22 | */ 23 | (filename) => { 24 | const mapper = mappers.find((mapper) => { 25 | if (mapper[0] instanceof RegExp) { 26 | return mapper[0].test(filename) 27 | } 28 | 29 | return mapper[0] === filename 30 | }) 31 | 32 | if (!mapper) return null 33 | 34 | return mapper[1] 35 | } 36 | 37 | module.exports = map 38 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/actions/test/compose/array.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const compose = require('../../compose') 3 | const { listConcatAtom } = require('../../../atoms') 4 | 5 | describe('actions > compose > array', () => { 6 | const listConcatBaseFxt = fixtures('list/json/00-concat-primitives', 'map') 7 | 8 | it('should create composition for hashes', () => { 9 | const composition = compose([listConcatAtom]) 10 | const result = composition(listConcatBaseFxt) 11 | 12 | expect(result).toEqual(listConcatBaseFxt.result) 13 | }) 14 | }) 15 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/actions/test/compose/hash.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const compose = require('../../compose') 3 | const { primitiveAtom } = require('../../../atoms') 4 | 5 | describe('actions > compose > hash', () => { 6 | const hashFxt = fixtures('rule/json/01-hash', 'map') 7 | 8 | it('should create composition for hashes', () => { 9 | const composition = compose({ 10 | foo: primitiveAtom, 11 | bar: primitiveAtom, 12 | baz: primitiveAtom, 13 | }) 14 | const result = composition(hashFxt) 15 | 16 | expect(result).toEqual(hashFxt.result) 17 | }) 18 | }) 19 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/actions/test/compose/mixed.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const compose = require('../../compose') 3 | const { listConcatAtom } = require('../../../atoms') 4 | 5 | describe('actions > compose > mixed', () => { 6 | const listFxt = fixtures('list/json/00-concat-primitives', 'map') 7 | 8 | it('should allow to compose nested schemas', () => { 9 | const composition = compose({ 10 | foo: compose({ 11 | bar: listConcatAtom, 12 | }), 13 | }) 14 | const result = composition({ 15 | current: new Map().set('foo', new Map().set('bar', listFxt.current)), 16 | upcoming: new Map().set('foo', new Map().set('bar', listFxt.upcoming)), 17 | cached: new Map().set('foo', new Map().set('bar', listFxt.cached)), 18 | }) 19 | 20 | expect(result).toEqual(new Map().set('foo', new Map().set('bar', listFxt.result))) 21 | }) 22 | }) 23 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/actions/test/fork.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const fork = require('../fork') 3 | const compose = require('../compose') 4 | const { primitiveAtom, listConcatAtom } = require('../../atoms') 5 | 6 | describe('actions > fork', () => { 7 | const listFxt = fixtures('list/json/00-concat-primitives', 'map') 8 | 9 | it('should apply strategies for mixed parameters types', () => { 10 | const composition = compose({ 11 | foo: fork([[Array.isArray, listConcatAtom], primitiveAtom]), 12 | }) 13 | 14 | expect( 15 | composition({ 16 | current: new Map().set('foo', listFxt.current), 17 | upcoming: new Map().set('foo', listFxt.upcoming), 18 | }), 19 | ).toEqual(new Map().set('foo', listFxt.result)) 20 | expect( 21 | composition({ 22 | current: new Map().set('foo', 'foo'), 23 | upcoming: new Map().set('foo', 'bar'), 24 | }), 25 | ).toEqual(new Map().set('foo', 'bar')) 26 | }) 27 | }) 28 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/actions/test/map.test.js: -------------------------------------------------------------------------------- 1 | const map = require('../map') 2 | 3 | describe('actions > map', () => { 4 | const mapper = map(['filename', () => 'foo'], [/\.json$/, () => 'bar'], [/\.ya?ml$/, () => 'baz']) 5 | 6 | it('should map functions by filename regexp and strings', () => { 7 | expect(mapper('filename')()).toEqual('foo') 8 | expect(mapper('filename.json')()).toEqual('bar') 9 | expect(mapper('filename.yaml')()).toEqual('baz') 10 | expect(mapper('filename.yml')()).toEqual('baz') 11 | }) 12 | 13 | it('should returns null if any mapper is not matched', () => { 14 | expect(mapper('filename.toml')).toEqual(null) 15 | }) 16 | }) 17 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/atoms/index.js: -------------------------------------------------------------------------------- 1 | const hashAtom = require('./hash') 2 | const primitiveAtom = require('./primitive') 3 | const ruleAtom = require('./rule') 4 | const listMergeAtom = require('./listMerge') 5 | const listConcatAtom = require('./listConcat') 6 | const pairAtom = require('./pair') 7 | const linesMergeAtom = require('./linesMerge') 8 | const linesConcatAtom = require('./linesConcat') 9 | const commandAtom = require('./command') 10 | 11 | module.exports = { 12 | hashAtom, 13 | primitiveAtom, 14 | ruleAtom, 15 | listMergeAtom, 16 | listConcatAtom, 17 | pairAtom, 18 | linesMergeAtom, 19 | linesConcatAtom, 20 | commandAtom, 21 | } 22 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/atoms/linesConcat.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const flow = require('lodash.flow') 3 | const { trimEOF, linesToLists } = require('../helpers') 4 | const listConcatAtom = require('./listConcat') 5 | 6 | /** 7 | * @typedef {import('../').SchemaParams} SchemaLinesParams 8 | */ 9 | 10 | /** 11 | * Merges lines (string separated by EOLs) 12 | * Doesn't remove duplicates, just concat lines or remove deleted ones 13 | * @param {SchemaLinesParams} params 14 | * @returns {string} 15 | */ 16 | function linesConcatAtom(params) { 17 | const { current, upcoming } = params 18 | 19 | if (current === undefined && upcoming) return upcoming 20 | if (current && upcoming === undefined) return current 21 | 22 | const result = listConcatAtom(flow(trimEOF, linesToLists)(params)) 23 | 24 | return result.join('\n') 25 | } 26 | 27 | module.exports = linesConcatAtom 28 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/atoms/linesMerge.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const flow = require('lodash.flow') 3 | const { trimEOF, linesToLists } = require('../helpers') 4 | const listMergeAtom = require('./listMerge') 5 | const primitiveAtom = require('./primitive') 6 | 7 | /** 8 | * @typedef {import('../').SchemaParams} SchemaLinesParams 9 | */ 10 | 11 | /** 12 | * Creates list of unique values from lists-params 13 | * @param {SchemaLinesParams} params 14 | * @returns {string} 15 | */ 16 | function linesMergeAtom(params) { 17 | const { current, upcoming } = params 18 | 19 | if (current === undefined && upcoming) return upcoming 20 | if (current && upcoming === undefined) return current 21 | 22 | const result = listMergeAtom(primitiveAtom)(flow(trimEOF, linesToLists)(params)) 23 | 24 | return result.join('\n') 25 | } 26 | 27 | module.exports = linesMergeAtom 28 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/atoms/listConcat.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | 3 | const isEqual = require('lodash.isequal') 4 | const uniqWith = require('lodash.uniqwith') 5 | 6 | /** 7 | * @typedef {import('../').SchemaParams} SchemaListParams 8 | */ 9 | 10 | /** 11 | * Creates list of unique values from lists-params 12 | * @param {SchemaListParams} params 13 | * @returns {string[]} 14 | */ 15 | function listConcatAtom({ current, upcoming }) { 16 | if (current && upcoming === undefined) return current 17 | if (current === undefined && upcoming) return upcoming 18 | 19 | return uniqWith([...current, ...upcoming], isEqual) 20 | } 21 | 22 | module.exports = listConcatAtom 23 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/atoms/primitive.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | 3 | /** 4 | * @typedef {import('../').Primitive} Primitive 5 | * @typedef {import('../').SchemaParams} SchemaPrimitiveParams 6 | */ 7 | 8 | /** 9 | * Merges primitive data types 10 | * @param {SchemaPrimitiveParams} params 11 | * @returns {Primitive} 12 | */ 13 | function primitiveAtom({ current, upcoming, cached }) { 14 | if (current && upcoming === undefined) return current 15 | if (current === undefined && upcoming) return upcoming 16 | 17 | const withCache = cached !== undefined 18 | 19 | if (withCache && current !== cached) return current 20 | if (current !== upcoming) return upcoming 21 | 22 | return current 23 | } 24 | 25 | module.exports = primitiveAtom 26 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/atoms/rule.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | 3 | const isEqual = require('lodash.isequal') 4 | 5 | /** 6 | * @typedef {import('../').Rule} Rule 7 | * @typedef {import('../').SchemaParams} SchemaRulesParams 8 | */ 9 | 10 | /** 11 | * Merges rules-like data-strutures (eslint, stylelint etc. rules) 12 | * Doesn't merge anything, only returns required one, because rule can't be correctly 13 | * merged 14 | * Mostly, rule changes mean that rule is not correct anymore 15 | * @param {SchemaRulesParams} params 16 | * @returns {Rule} 17 | */ 18 | function ruleAtom({ current, upcoming, cached }) { 19 | if (current && upcoming === undefined) return current 20 | if (current === undefined && upcoming) return upcoming 21 | if (cached !== undefined && !isEqual(current, cached)) return current 22 | if (!isEqual(current, upcoming)) return upcoming 23 | 24 | return current 25 | } 26 | 27 | module.exports = ruleAtom 28 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/atoms/test/__snapshots__/linesConcat.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`atoms > linesConcat should merge lines as lists 1`] = ` 4 | "foo 5 | bar 6 | baz 7 | new foo 8 | new bar" 9 | `; 10 | 11 | exports[`atoms > linesConcat should return current if upcoming is not passed 1`] = ` 12 | "foo 13 | bar 14 | baz" 15 | `; 16 | 17 | exports[`atoms > linesConcat should return upcoming if current is not passed 1`] = ` 18 | "new foo 19 | new bar" 20 | `; 21 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/atoms/test/__snapshots__/linesMerge.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`atoms > linesMerge should merge lines as lists 1`] = ` 4 | "foo 5 | new bar 6 | baz" 7 | `; 8 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/atoms/test/hash.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const hashAtom = require('../hash') 3 | 4 | describe('atoms > hash', () => { 5 | const hashFxt = fixtures('rule/json/01-hash', 'map') 6 | const hashRemovedFxt = fixtures('default/json/01-handle-removed', 'map') 7 | 8 | it('should return current if upcoming is not passed', () => { 9 | const result = hashAtom({ current: hashFxt.current }) 10 | 11 | expect(result).toEqual(hashFxt.current) 12 | }) 13 | 14 | it('should return upcoming if current is not passed', () => { 15 | const result = hashAtom({ upcoming: hashFxt.upcoming }) 16 | 17 | expect(result).toEqual(hashFxt.upcoming) 18 | }) 19 | 20 | it('should merge rules with cache', () => { 21 | const result = hashAtom(hashFxt) 22 | 23 | expect(result).toEqual(hashFxt.result) 24 | }) 25 | 26 | it('should handle removed fields', () => { 27 | const result = hashAtom(hashRemovedFxt) 28 | 29 | expect(result).toEqual(hashRemovedFxt.result) 30 | }) 31 | }) 32 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/atoms/test/linesConcat.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const linesConcatAtom = require('../linesConcat') 3 | 4 | describe('atoms > linesConcat', () => { 5 | const concatLinesFxt = fixtures('lines/lines/01-concat') 6 | 7 | it('should return current if upcoming is not passed', () => { 8 | const result = linesConcatAtom({ current: concatLinesFxt.current }) 9 | 10 | expect(result).toMatchSnapshot() 11 | }) 12 | 13 | it('should return upcoming if current is not passed', () => { 14 | const result = linesConcatAtom({ upcoming: concatLinesFxt.upcoming }) 15 | 16 | expect(result).toMatchSnapshot() 17 | }) 18 | 19 | it('should merge lines as lists', () => { 20 | expect(linesConcatAtom(concatLinesFxt)).toMatchSnapshot() 21 | }) 22 | }) 23 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/atoms/test/linesMerge.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const linesMergeAtom = require('../linesMerge') 3 | 4 | describe('atoms > linesMerge', () => { 5 | const mergeLinesFxt = fixtures('lines/lines/00-merge') 6 | 7 | it('should return current if upcoming is not passed', () => { 8 | const result = linesMergeAtom({ current: mergeLinesFxt.current }) 9 | 10 | expect(result).toEqual(mergeLinesFxt.current) 11 | }) 12 | 13 | it('should return upcoming if current is not passed', () => { 14 | const result = linesMergeAtom({ upcoming: mergeLinesFxt.upcoming }) 15 | 16 | expect(result).toEqual(mergeLinesFxt.upcoming) 17 | }) 18 | 19 | it('should merge lines as lists', () => { 20 | expect(linesMergeAtom(mergeLinesFxt)).toMatchSnapshot() 21 | }) 22 | }) 23 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/atoms/test/listConcat.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const listConcatAtom = require('../listConcat') 3 | 4 | describe('atoms > listConcat', () => { 5 | const primitivesListFxt = fixtures('list/json/00-concat-primitives', 'map') 6 | const hashesListFxt = fixtures('list/json/03-concat-hashes', 'map') 7 | 8 | it('should return current if upcoming is not passed', () => { 9 | expect(listConcatAtom({ current: primitivesListFxt.current })).toEqual(primitivesListFxt.current) 10 | expect(listConcatAtom({ current: hashesListFxt.current })).toEqual(hashesListFxt.current) 11 | }) 12 | 13 | it('should return upcoming if current is not passed', () => { 14 | expect(listConcatAtom({ upcoming: primitivesListFxt.upcoming })).toEqual(primitivesListFxt.upcoming) 15 | expect(listConcatAtom({ upcoming: hashesListFxt.upcoming })).toEqual(hashesListFxt.upcoming) 16 | }) 17 | 18 | it('should concat primitives lists', () => { 19 | expect(listConcatAtom(primitivesListFxt)).toEqual(primitivesListFxt.result) 20 | }) 21 | 22 | it('should concat hashes lists', () => { 23 | expect(listConcatAtom(hashesListFxt)).toEqual(hashesListFxt.result) 24 | }) 25 | }) 26 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/atoms/test/primitive.test.js: -------------------------------------------------------------------------------- 1 | const primitiveAtom = require('../primitive') 2 | 3 | describe('atoms > primitive', () => { 4 | it('should return current if upcoming is not passed', () => { 5 | const result = primitiveAtom({ current: 'foo' }) 6 | 7 | expect(result).toEqual('foo') 8 | }) 9 | 10 | it('should return upcoming if current is not passed', () => { 11 | const result = primitiveAtom({ upcoming: 'bar' }) 12 | 13 | expect(result).toEqual('bar') 14 | }) 15 | 16 | it('should return upcoming if values are not equal', () => { 17 | const result = primitiveAtom({ current: 'foo', upcoming: 'bar' }) 18 | 19 | expect(result).toEqual('bar') 20 | }) 21 | 22 | it('should not change if it was changed by user', () => { 23 | const result = primitiveAtom({ 24 | current: 'foo', 25 | upcoming: 'bar', 26 | cached: 'cached foo', 27 | }) 28 | 29 | expect(result).toEqual('foo') 30 | }) 31 | }) 32 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/helpers/index.js: -------------------------------------------------------------------------------- 1 | const trimEOF = require('./trimEOF') 2 | const linesToLists = require('./linesToLists') 3 | 4 | module.exports = { 5 | trimEOF, 6 | linesToLists, 7 | } 8 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/helpers/linesToLists.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | // TODO: move to parsers 3 | /** 4 | * @typedef {import('../').SchemaParams} SchemaStringParams 5 | * @typedef {import('../').SchemaParams} SchemaListParams 6 | */ 7 | 8 | /** 9 | * Splits given lines to mapped strings lists 10 | * @param {SchemaStringParams} params 11 | * @returns {SchemaListParams} 12 | */ 13 | function linesToLists(params) { 14 | return Object.keys(params).reduce( 15 | (acc, key) => 16 | Object.assign(acc, { 17 | [key]: typeof params[key] === 'string' ? params[key].split(/\n/gm) : params[key], 18 | }), 19 | {}, 20 | ) 21 | } 22 | 23 | module.exports = linesToLists 24 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/helpers/test/linesToLists.test.js: -------------------------------------------------------------------------------- 1 | const linesToLists = require('../linesToLists') 2 | 3 | describe('strategies > helpers > params > linesToLists', () => { 4 | it('should trim EOF each params entry', () => { 5 | expect( 6 | linesToLists({ 7 | current: 'foo\nbar\nbaz', 8 | upcoming: 'foo\nbar\nbaz', 9 | }), 10 | ).toEqual({ 11 | current: ['foo', 'bar', 'baz'], 12 | upcoming: ['foo', 'bar', 'baz'], 13 | }) 14 | }) 15 | }) 16 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/helpers/test/trimEOF.test.js: -------------------------------------------------------------------------------- 1 | const { EOL } = require('os') 2 | const trimEOF = require('../trimEOF') 3 | 4 | describe('strategies > helpers > params > trimEOF', () => { 5 | it('should trim EOF each params entry', () => { 6 | expect( 7 | trimEOF({ 8 | current: `foo${EOL}bar${EOL}baz${EOL}`, 9 | upcoming: `foo${EOL}bar${EOL}baz${EOL}`, 10 | }), 11 | ).toEqual({ 12 | current: `foo${EOL}bar${EOL}baz`, 13 | upcoming: `foo${EOL}bar${EOL}baz`, 14 | }) 15 | }) 16 | }) 17 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/helpers/trimEOF.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { cutEOF } = require('sharec-utils/lib/format') 3 | 4 | /** @typedef {import('../').SchemaParams} SchemaParams */ 5 | 6 | /** 7 | * Trims EOL from all given strings mapped by any keys 8 | * @param {SchemaParams} params 9 | * @returns {SchemaParams} 10 | */ 11 | function trimEOF(params) { 12 | return Object.keys(params).reduce( 13 | (acc, key) => 14 | Object.assign(acc, { 15 | [key]: params[key] ? cutEOF(params[key]) : params[key], 16 | }), 17 | {}, 18 | ) 19 | } 20 | 21 | module.exports = trimEOF 22 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/index.js: -------------------------------------------------------------------------------- 1 | const actions = require('./actions') 2 | const atoms = require('./atoms') 3 | const helpers = require('./helpers') 4 | const parsers = require('./parsers') 5 | const pipes = require('./pipes') 6 | 7 | /** 8 | * @typedef {Map} ParsedCommand 9 | * @property {string[]} env 10 | * @property {string[]} args 11 | * @property {string} [separator] 12 | */ 13 | 14 | /** 15 | * @template T 16 | * @typedef {Map} SchemaParam 17 | */ 18 | 19 | /** 20 | * @template T 21 | * @typedef {object} SchemaParams 22 | * @property {T} [current] 23 | * @property {T} [upcoming] 24 | * @property {T} [cached] 25 | * @property {T} [result] 26 | */ 27 | 28 | /** 29 | * @typedef {{ [x: string]: any }} Schema 30 | * @property {string[]} [$$ignore] 31 | * @property {Function} [$$default] 32 | */ 33 | 34 | /** 35 | * @typedef {(string|number|boolean)} Primitive 36 | */ 37 | 38 | /** 39 | * @template T 40 | * @typedef {[string, T]} Pair 41 | */ 42 | 43 | /** 44 | * @typedef {(Primitive|{ [x: string]: any } | any[])} Rule 45 | */ 46 | 47 | module.exports = { 48 | actions, 49 | atoms, 50 | helpers, 51 | parsers, 52 | pipes, 53 | } 54 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/parsers/index.js: -------------------------------------------------------------------------------- 1 | const json = require('./json') 2 | const yaml = require('./yaml') 3 | 4 | module.exports = { 5 | json, 6 | yaml, 7 | } 8 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/parsers/json.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const json8 = require('json8') 3 | 4 | const COMMENTS_REG = /\s+?(\/{2}|\/\*)\s?.+/gm 5 | 6 | /** 7 | * Creates map from JSON string with order saving 8 | * @param {string} str Raw JSON string 9 | * @returns {Map} 10 | */ 11 | const fromJSON = (str) => { 12 | let rawJSON = str 13 | 14 | if (COMMENTS_REG.test(str)) { 15 | rawJSON = rawJSON.replace(COMMENTS_REG, '') 16 | } 17 | 18 | return json8.parse(rawJSON, { map: true }) 19 | } 20 | 21 | /** 22 | * Transforms given map to JSON string with order saving 23 | * @param {Map} map Any map 24 | * @param {number} [space] Indent spaces count 25 | * @returns {string} 26 | */ 27 | const toJSON = (map, space = 2) => json8.serialize(map, { space }) 28 | 29 | module.exports = { 30 | fromJSON, 31 | toJSON, 32 | } 33 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/parsers/test/__snapshots__/json.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`parsers > json toJSON should create JSON string from Map 1`] = ` 4 | "{ 5 | \\"foo\\": \\"bar\\", 6 | \\"bar\\": \\"baz\\", 7 | \\"baz\\": { 8 | \\"foo\\": \\"bar\\", 9 | \\"bar\\": \\"baz\\" 10 | } 11 | }" 12 | `; 13 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/parsers/test/__snapshots__/yaml.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`parsers > yaml fromYAML should create Map from given YAML 1`] = ` 4 | "{ 5 | \\"foo\\": \\"bar\\", 6 | \\"bar\\": \\"baz\\", 7 | \\"baz\\": { 8 | \\"foo\\": \\"bar\\", 9 | \\"bar\\": \\"baz\\" 10 | } 11 | }" 12 | `; 13 | 14 | exports[`parsers > yaml toYAML should create YAML string from Map 1`] = ` 15 | "foo: bar 16 | bar: baz 17 | baz: 18 | foo: bar 19 | bar: baz 20 | " 21 | `; 22 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/parsers/test/json.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const { fromJSON, toJSON } = require('../json') 3 | 4 | describe('parsers > json', () => { 5 | const defaultFxt = fixtures('default/json/00-base') 6 | const defaultCommentsFxt = fixtures('default/json/03-comments') 7 | 8 | const currentMap = new Map().set('foo', 'bar').set('bar', 'baz') 9 | const defaultFxtMap = new Map(currentMap).set('baz', currentMap) 10 | 11 | describe('fromJSON', () => { 12 | it('should create Map from given JSON', () => { 13 | expect(fromJSON(defaultFxt.current)).toEqual(defaultFxtMap) 14 | }) 15 | 16 | it('should create Map from JSON which includes comments', () => { 17 | expect(fromJSON(defaultCommentsFxt.current)).toEqual(defaultFxtMap) 18 | }) 19 | }) 20 | 21 | describe('toJSON', () => { 22 | it('should create JSON string from Map', () => { 23 | expect(toJSON(defaultFxtMap)).toMatchSnapshot() 24 | }) 25 | }) 26 | }) 27 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/parsers/test/yaml.test.js: -------------------------------------------------------------------------------- 1 | const { fixtures } = require('testUtils') 2 | const { fromYAML, toYAML } = require('../yaml') 3 | 4 | describe('parsers > yaml', () => { 5 | const defaultFxt = fixtures('default/json/00-base') 6 | const defaultFxtYAML = fixtures('default/yaml/00-base') 7 | 8 | describe('fromYAML', () => { 9 | it('should create Map from given YAML', () => { 10 | expect(fromYAML(defaultFxtYAML.current)).toMatchSnapshot() 11 | }) 12 | }) 13 | 14 | describe('toYAML', () => { 15 | it('should create YAML string from Map', () => { 16 | expect(toYAML(defaultFxt.current)).toMatchSnapshot() 17 | }) 18 | }) 19 | }) 20 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/parsers/yaml.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { load, dump } = require('js-yaml') 3 | 4 | /** 5 | * Creates JSON string from YAML string with order saving 6 | * @param {string} str Raw YAML string 7 | * @returns {string} 8 | */ 9 | const fromYAML = (str) => JSON.stringify(load(str), null, 2) 10 | 11 | /** 12 | * Transforms given JSON string to YAML string with order saving 13 | * @param {string} str JSON string 14 | * @returns {string} 15 | */ 16 | const toYAML = (str) => dump(JSON.parse(str)) 17 | 18 | module.exports = { 19 | fromYAML, 20 | toYAML, 21 | } 22 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/pipes/createJsonPipe.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const flow = require('lodash.flow') 3 | const toJson = require('./toJson') 4 | const fromJson = require('./fromJson') 5 | 6 | /** 7 | * Creates function with given handlers which accepts params in JSON format 8 | * and returns data in the same format 9 | * @param {...Function[]} handlers 10 | * @returns {Function} 11 | */ 12 | // @ts-ignore 13 | const createJsonPipe = (...handlers) => flow(fromJson, ...handlers, toJson) 14 | 15 | module.exports = createJsonPipe 16 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/pipes/createYamlPipe.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const flow = require('lodash.flow') 3 | const toJson = require('./toJson') 4 | const fromJson = require('./fromJson') 5 | const toYaml = require('./toYaml') 6 | const fromYaml = require('./fromYaml') 7 | 8 | /** 9 | * @typedef {import('../').SchemaParams} SchemaYamlParams 10 | */ 11 | 12 | /** 13 | * Creates function with given handlers which accepts params in YAML format 14 | * and returns data in the same format 15 | * @param {...Function[]} handlers 16 | * @returns {Function} 17 | */ 18 | const createYamlPipe = (...handlers) => 19 | /** 20 | * @param {SchemaYamlParams} params 21 | * @returns {SchemaYamlParams} 22 | */ 23 | (params) => { 24 | const isSingleQuote = params.current && /'/gm.test(params.current) 25 | // @ts-ignore 26 | const pipe = flow(fromYaml, fromJson, ...handlers, toJson, toYaml) 27 | const result = pipe(params) 28 | 29 | if (isSingleQuote) return result.replace(/"/gm, "'") 30 | 31 | return result.replace(/'/gm, '"') 32 | } 33 | 34 | module.exports = createYamlPipe 35 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/pipes/fromJson.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const omitBy = require('lodash.omitby') 3 | const isUndefined = require('lodash.isundefined') 4 | const mapValues = require('lodash.mapvalues') 5 | const { fromJSON } = require('../parsers/json') 6 | 7 | /** 8 | * @typedef {import('../').SchemaParams} SchemaJsonParams 9 | * @typedef {import('../').SchemaParams>} SchemaHashParams 10 | */ 11 | 12 | /** 13 | * Transforms JSON params to Hash params 14 | * @param {SchemaJsonParams} params 15 | * @returns {SchemaHashParams} 16 | */ 17 | const fromJsonPipe = (params) => { 18 | const sanitizedParams = omitBy(params, isUndefined) 19 | 20 | return mapValues(sanitizedParams, fromJSON) 21 | } 22 | 23 | module.exports = fromJsonPipe 24 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/pipes/fromYaml.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const omitBy = require('lodash.omitby') 3 | const isUndefined = require('lodash.isundefined') 4 | const mapValues = require('lodash.mapvalues') 5 | const { fromYAML } = require('../parsers/yaml') 6 | 7 | /** 8 | * @typedef {import('../').SchemaParams} SchemaYamlParams 9 | * @typedef {import('../').SchemaParams>} SchemaHashParams 10 | */ 11 | 12 | /** 13 | * Transforms JSON params to Hash params 14 | * @param {SchemaYamlParams} params 15 | * @returns {SchemaHashParams} 16 | */ 17 | const fromYaml = (params) => { 18 | const sanitizedParams = omitBy(params, isUndefined) 19 | 20 | return mapValues(sanitizedParams, fromYAML) 21 | } 22 | 23 | module.exports = fromYaml 24 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/pipes/index.js: -------------------------------------------------------------------------------- 1 | const fromJson = require('./fromJson') 2 | const toJson = require('./toJson') 3 | const fromYaml = require('./fromYaml') 4 | const toYaml = require('./toYaml') 5 | const createJsonPipe = require('./createJsonPipe') 6 | const createYamlPipe = require('./createYamlPipe') 7 | 8 | module.exports = { 9 | fromJson, 10 | toJson, 11 | fromYaml, 12 | toYaml, 13 | createJsonPipe, 14 | createYamlPipe, 15 | } 16 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/pipes/toJson.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { toJSON } = require('../parsers/json') 3 | 4 | /** 5 | * Transforms Map to JSON-string 6 | * @param {Map} input 7 | * @returns {string} 8 | */ 9 | const toJsonPipe = (input) => toJSON(input) 10 | 11 | module.exports = toJsonPipe 12 | -------------------------------------------------------------------------------- /packages/sharec-schema/lib/pipes/toYaml.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const last = require('lodash.last') 3 | const { toYAML } = require('../parsers/yaml') 4 | 5 | /** 6 | * Transforms JSON-string to YAML-string 7 | * @param {string} input 8 | * @returns {string} 9 | */ 10 | const toYaml = (input) => { 11 | const yamlInput = toYAML(input) 12 | const yamlLines = yamlInput.split(/\n|\r\n/) 13 | const eof = last(yamlLines) === '' 14 | 15 | if (eof) { 16 | return yamlLines.slice(0, yamlLines.length - 1).join('\n') 17 | } 18 | 19 | return yamlInput 20 | } 21 | 22 | module.exports = toYaml 23 | -------------------------------------------------------------------------------- /packages/sharec-schema/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./types", 4 | "moduleResolution": "node", 5 | "allowJs": true, 6 | "checkJs": true, 7 | "declaration": true, 8 | "types": ["node", "jest"] 9 | }, 10 | "include": ["./lib/*.js"], 11 | "exclude": ["./lib/*.test.js"] 12 | } 13 | -------------------------------------------------------------------------------- /packages/sharec-schema/types/actions/compose.d.ts: -------------------------------------------------------------------------------- 1 | export = compose 2 | /** 3 | * Main utility which allows to create callable schemas-representation 4 | * Returns function which applies incoming params by given schema 5 | * @param {Schema} schema 6 | * @returns {Function} 7 | */ 8 | declare function compose(schema: Schema): Function 9 | declare namespace compose { 10 | export { Schema, SchemaParams } 11 | } 12 | type Schema = { 13 | [x: string]: any 14 | } 15 | type SchemaParams = { 16 | current?: any 17 | upcoming?: any 18 | cached?: any 19 | result?: any 20 | } 21 | -------------------------------------------------------------------------------- /packages/sharec-schema/types/actions/fork.d.ts: -------------------------------------------------------------------------------- 1 | export = fork 2 | /** 3 | * Creates conditional sequence of functions with predicates 4 | * The last argument is default function 5 | * Each condition branch should be an array, where first element is predicate function 6 | * Second element is the target function and it will be applyed only if predicate return true 7 | * 8 | * ``` 9 | * const handler = arr => arr.map(item => item * item) 10 | * const identity = val => val 11 | * const forkTest = fork([[Array.isArray, handler], identity]) 12 | * 13 | * forkTest([1, 2, 3]) // [1, 4, 9] 14 | * forkTest(1) // 1 15 | * ``` 16 | * 17 | * @param {Array} cases 18 | * @returns {Function} 19 | */ 20 | declare function fork(cases: Array): Function 21 | -------------------------------------------------------------------------------- /packages/sharec-schema/types/actions/index.d.ts: -------------------------------------------------------------------------------- 1 | import compose = require('./compose') 2 | import fork = require('./fork') 3 | import map = require('./map') 4 | export { compose, fork, map } 5 | -------------------------------------------------------------------------------- /packages/sharec-schema/types/actions/map.d.ts: -------------------------------------------------------------------------------- 1 | export = map 2 | /** 3 | * Maps functions by strings and RegExps 4 | * Mapped functions will be returned by given matchers 5 | * 6 | * ``` 7 | * const mapper = map(['foo', () => 1, 'bar', () => 2]) 8 | * 9 | * mapper('foo')() // 1 10 | * mapper('bar')() // 2 11 | * mapper('baz')() // null 12 | * ``` 13 | * 14 | * @param {...[string | RegExp, Function]} mappers 15 | * @returns {Function} 16 | */ 17 | declare function map(...mappers: [string | RegExp, Function][]): Function 18 | -------------------------------------------------------------------------------- /packages/sharec-schema/types/atoms/command.d.ts: -------------------------------------------------------------------------------- 1 | export = commandAtom 2 | /** 3 | * Merges parsed cli-commands and returns cli-command string 4 | * @param {SchemaRawCommandParams} params 5 | * @returns {string} 6 | */ 7 | declare function commandAtom(params: SchemaRawCommandParams): string 8 | declare namespace commandAtom { 9 | export { ParsedCommand, SchemaCommandParam, SchemaRawCommandParams } 10 | } 11 | type SchemaRawCommandParams = { 12 | current?: string 13 | upcoming?: string 14 | cached?: string 15 | result?: string 16 | } 17 | type ParsedCommand = Map 18 | type SchemaCommandParam = Map 19 | -------------------------------------------------------------------------------- /packages/sharec-schema/types/atoms/hash.d.ts: -------------------------------------------------------------------------------- 1 | export = hashAtom 2 | /** 3 | * @typedef {import('../').SchemaParam>} SchemaHashParam 4 | * @typedef {import('../').SchemaParams>} SchemaHashParams 5 | */ 6 | /** 7 | * Merges objects preseted as maps 8 | * @param {SchemaHashParams} params 9 | * @returns {SchemaHashParam} 10 | */ 11 | declare function hashAtom({ current, upcoming, cached }: SchemaHashParams): import('..').SchemaParam> 12 | declare namespace hashAtom { 13 | export { SchemaHashParam, SchemaHashParams } 14 | } 15 | type SchemaHashParams = { 16 | current?: Map 17 | upcoming?: Map 18 | cached?: Map 19 | result?: Map 20 | } 21 | type SchemaHashParam = Map> 22 | -------------------------------------------------------------------------------- /packages/sharec-schema/types/atoms/index.d.ts: -------------------------------------------------------------------------------- 1 | import hashAtom = require('./hash') 2 | import primitiveAtom = require('./primitive') 3 | import ruleAtom = require('./rule') 4 | import listMergeAtom = require('./listMerge') 5 | import listConcatAtom = require('./listConcat') 6 | import pairAtom = require('./pair') 7 | import linesMergeAtom = require('./linesMerge') 8 | import linesConcatAtom = require('./linesConcat') 9 | import commandAtom = require('./command') 10 | export { 11 | hashAtom, 12 | primitiveAtom, 13 | ruleAtom, 14 | listMergeAtom, 15 | listConcatAtom, 16 | pairAtom, 17 | linesMergeAtom, 18 | linesConcatAtom, 19 | commandAtom, 20 | } 21 | -------------------------------------------------------------------------------- /packages/sharec-schema/types/atoms/linesConcat.d.ts: -------------------------------------------------------------------------------- 1 | export = linesConcatAtom 2 | /** 3 | * @typedef {import('../').SchemaParams} SchemaLinesParams 4 | */ 5 | /** 6 | * Merges lines (string separated by EOLs) 7 | * Doesn't remove duplicates, just concat lines or remove deleted ones 8 | * @param {SchemaLinesParams} params 9 | * @returns {string} 10 | */ 11 | declare function linesConcatAtom(params: SchemaLinesParams): string 12 | declare namespace linesConcatAtom { 13 | export { SchemaLinesParams } 14 | } 15 | type SchemaLinesParams = { 16 | current?: string 17 | upcoming?: string 18 | cached?: string 19 | result?: string 20 | } 21 | -------------------------------------------------------------------------------- /packages/sharec-schema/types/atoms/linesMerge.d.ts: -------------------------------------------------------------------------------- 1 | export = linesMergeAtom 2 | /** 3 | * @typedef {import('../').SchemaParams} SchemaLinesParams 4 | */ 5 | /** 6 | * Creates list of unique values from lists-params 7 | * @param {SchemaLinesParams} params 8 | * @returns {string} 9 | */ 10 | declare function linesMergeAtom(params: SchemaLinesParams): string 11 | declare namespace linesMergeAtom { 12 | export { SchemaLinesParams } 13 | } 14 | type SchemaLinesParams = { 15 | current?: string 16 | upcoming?: string 17 | cached?: string 18 | result?: string 19 | } 20 | -------------------------------------------------------------------------------- /packages/sharec-schema/types/atoms/listConcat.d.ts: -------------------------------------------------------------------------------- 1 | export = listConcatAtom 2 | /** 3 | * @typedef {import('../').SchemaParams} SchemaListParams 4 | */ 5 | /** 6 | * Creates list of unique values from lists-params 7 | * @param {SchemaListParams} params 8 | * @returns {string[]} 9 | */ 10 | declare function listConcatAtom({ current, upcoming }: SchemaListParams): string[] 11 | declare namespace listConcatAtom { 12 | export { SchemaListParams } 13 | } 14 | type SchemaListParams = { 15 | current?: string[] 16 | upcoming?: string[] 17 | cached?: string[] 18 | result?: string[] 19 | } 20 | -------------------------------------------------------------------------------- /packages/sharec-schema/types/atoms/listMerge.d.ts: -------------------------------------------------------------------------------- 1 | export = listMergeAtom 2 | /** 3 | * @typedef {import('../').SchemaParams} SchemaAnyListParams 4 | */ 5 | /** 6 | * Merges each value in lists by index with given atom 7 | * @param {Function} atom 8 | * @returns {Function} 9 | */ 10 | declare function listMergeAtom(atom: Function): Function 11 | declare namespace listMergeAtom { 12 | export { SchemaAnyListParams } 13 | } 14 | type SchemaAnyListParams = { 15 | current?: any[] 16 | upcoming?: any[] 17 | cached?: any[] 18 | result?: any[] 19 | } 20 | -------------------------------------------------------------------------------- /packages/sharec-schema/types/atoms/primitive.d.ts: -------------------------------------------------------------------------------- 1 | export = primitiveAtom 2 | /** 3 | * @typedef {import('../').Primitive} Primitive 4 | * @typedef {import('../').SchemaParams} SchemaPrimitiveParams 5 | */ 6 | /** 7 | * Merges primitive data types 8 | * @param {SchemaPrimitiveParams} params 9 | * @returns {Primitive} 10 | */ 11 | declare function primitiveAtom({ current, upcoming, cached }: SchemaPrimitiveParams): Primitive 12 | declare namespace primitiveAtom { 13 | export { Primitive, SchemaPrimitiveParams } 14 | } 15 | type SchemaPrimitiveParams = { 16 | current?: string | number | boolean 17 | upcoming?: string | number | boolean 18 | cached?: string | number | boolean 19 | result?: string | number | boolean 20 | } 21 | type Primitive = string | number | boolean 22 | -------------------------------------------------------------------------------- /packages/sharec-schema/types/atoms/rule.d.ts: -------------------------------------------------------------------------------- 1 | export = ruleAtom 2 | /** 3 | * @typedef {import('../').Rule} Rule 4 | * @typedef {import('../').SchemaParams} SchemaRulesParams 5 | */ 6 | /** 7 | * Merges rules-like data-strutures (eslint, stylelint etc. rules) 8 | * Doesn't merge anything, only returns required one, because rule can't be correctly 9 | * merged 10 | * Mostly, rule changes mean that rule is not correct anymore 11 | * @param {SchemaRulesParams} params 12 | * @returns {Rule} 13 | */ 14 | declare function ruleAtom({ current, upcoming, cached }: SchemaRulesParams): Rule 15 | declare namespace ruleAtom { 16 | export { Rule, SchemaRulesParams } 17 | } 18 | type SchemaRulesParams = { 19 | current?: import('..').Rule 20 | upcoming?: import('..').Rule 21 | cached?: import('..').Rule 22 | result?: import('..').Rule 23 | } 24 | type Rule = 25 | | string 26 | | number 27 | | boolean 28 | | any[] 29 | | { 30 | [x: string]: any 31 | } 32 | -------------------------------------------------------------------------------- /packages/sharec-schema/types/helpers/commandsToMap.d.ts: -------------------------------------------------------------------------------- 1 | export = commandsToMap 2 | /** 3 | * @typedef {import('../').ParsedCommand} ParsedCommand 4 | * @typedef {import('../').SchemaParams} SchemaStringParams 5 | * @typedef {import('../').SchemaParams} SchemaCommandsParams 6 | */ 7 | /** 8 | * Parse given object with raw cli-commands and returns parsed ones 9 | * for next merge 10 | * schema params 11 | * @param {SchemaStringParams} params 12 | * @returns {SchemaCommandsParams} 13 | */ 14 | declare function commandsToMap(params: SchemaStringParams): SchemaCommandsParams 15 | declare namespace commandsToMap { 16 | export { ParsedCommand, SchemaStringParams, SchemaCommandsParams } 17 | } 18 | type SchemaStringParams = { 19 | current?: string 20 | upcoming?: string 21 | cached?: string 22 | result?: string 23 | } 24 | type SchemaCommandsParams = { 25 | current?: import('..').ParsedCommand 26 | upcoming?: import('..').ParsedCommand 27 | cached?: import('..').ParsedCommand 28 | result?: import('..').ParsedCommand 29 | } 30 | type ParsedCommand = Map 31 | -------------------------------------------------------------------------------- /packages/sharec-schema/types/helpers/index.d.ts: -------------------------------------------------------------------------------- 1 | import trimEOF = require('./trimEOF') 2 | import linesToLists = require('./linesToLists') 3 | export { trimEOF, linesToLists } 4 | -------------------------------------------------------------------------------- /packages/sharec-schema/types/helpers/linesToLists.d.ts: -------------------------------------------------------------------------------- 1 | export = linesToLists 2 | /** 3 | * @typedef {import('../').SchemaParams} SchemaStringParams 4 | * @typedef {import('../').SchemaParams} SchemaListParams 5 | */ 6 | /** 7 | * Splits given lines to mapped strings lists 8 | * @param {SchemaStringParams} params 9 | * @returns {SchemaListParams} 10 | */ 11 | declare function linesToLists(params: SchemaStringParams): SchemaListParams 12 | declare namespace linesToLists { 13 | export { SchemaStringParams, SchemaListParams } 14 | } 15 | type SchemaStringParams = { 16 | current?: string 17 | upcoming?: string 18 | cached?: string 19 | result?: string 20 | } 21 | type SchemaListParams = { 22 | current?: string[] 23 | upcoming?: string[] 24 | cached?: string[] 25 | result?: string[] 26 | } 27 | -------------------------------------------------------------------------------- /packages/sharec-schema/types/helpers/trimEOF.d.ts: -------------------------------------------------------------------------------- 1 | export = trimEOF 2 | /** @typedef {import('../').SchemaParams} SchemaParams */ 3 | /** 4 | * Trims EOL from all given strings mapped by any keys 5 | * @param {SchemaParams} params 6 | * @returns {SchemaParams} 7 | */ 8 | declare function trimEOF(params: SchemaParams): SchemaParams 9 | declare namespace trimEOF { 10 | export { SchemaParams } 11 | } 12 | type SchemaParams = { 13 | current?: string 14 | upcoming?: string 15 | cached?: string 16 | result?: string 17 | } 18 | -------------------------------------------------------------------------------- /packages/sharec-schema/types/index.d.ts: -------------------------------------------------------------------------------- 1 | export type ParsedCommand = Map 2 | export type SchemaParam = Map 3 | export type SchemaParams = { 4 | current?: T 5 | upcoming?: T 6 | cached?: T 7 | result?: T 8 | } 9 | export type Schema = { 10 | [x: string]: any 11 | } 12 | export type Primitive = string | number | boolean 13 | export type Pair = [string, T] 14 | export type Rule = 15 | | string 16 | | number 17 | | boolean 18 | | any[] 19 | | { 20 | [x: string]: any 21 | } 22 | import actions = require('./actions') 23 | import atoms = require('./atoms') 24 | import helpers = require('./helpers') 25 | import parsers = require('./parsers') 26 | import pipes = require('./pipes') 27 | export { actions, atoms, helpers, parsers, pipes } 28 | -------------------------------------------------------------------------------- /packages/sharec-schema/types/parsers/index.d.ts: -------------------------------------------------------------------------------- 1 | import json = require('./json') 2 | import yaml = require('./yaml') 3 | export { json, yaml } 4 | -------------------------------------------------------------------------------- /packages/sharec-schema/types/parsers/json.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates map from JSON string with order saving 3 | * @param {string} str Raw JSON string 4 | * @returns {Map} 5 | */ 6 | export function fromJSON(str: string): Map 7 | /** 8 | * Transforms given map to JSON string with order saving 9 | * @param {Map} map Any map 10 | * @param {number} [space] Indent spaces count 11 | * @returns {string} 12 | */ 13 | export function toJSON(map: Map, space?: number): string 14 | -------------------------------------------------------------------------------- /packages/sharec-schema/types/parsers/yaml.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates JSON string from YAML string with order saving 3 | * @param {string} str Raw YAML string 4 | * @returns {string} 5 | */ 6 | export function fromYAML(str: string): string 7 | /** 8 | * Transforms given JSON string to YAML string with order saving 9 | * @param {string} str JSON string 10 | * @returns {string} 11 | */ 12 | export function toYAML(str: string): string 13 | -------------------------------------------------------------------------------- /packages/sharec-schema/types/pipes/createJsonPipe.d.ts: -------------------------------------------------------------------------------- 1 | export = createJsonPipe 2 | /** 3 | * Creates function with given handlers which accepts params in JSON format 4 | * and returns data in the same format 5 | * @param {...Function[]} handlers 6 | * @returns {Function} 7 | */ 8 | declare function createJsonPipe(...handlers: Function[][]): Function 9 | -------------------------------------------------------------------------------- /packages/sharec-schema/types/pipes/createYamlPipe.d.ts: -------------------------------------------------------------------------------- 1 | export = createYamlPipe 2 | /** 3 | * @typedef {import('../').SchemaParams} SchemaYamlParams 4 | */ 5 | /** 6 | * Creates function with given handlers which accepts params in YAML format 7 | * and returns data in the same format 8 | * @param {...Function[]} handlers 9 | * @returns {Function} 10 | */ 11 | declare function createYamlPipe(...handlers: Function[][]): Function 12 | declare namespace createYamlPipe { 13 | export { SchemaYamlParams } 14 | } 15 | type SchemaYamlParams = { 16 | current?: string 17 | upcoming?: string 18 | cached?: string 19 | result?: string 20 | } 21 | -------------------------------------------------------------------------------- /packages/sharec-schema/types/pipes/fromJson.d.ts: -------------------------------------------------------------------------------- 1 | export = fromJsonPipe 2 | /** 3 | * @typedef {import('../').SchemaParams} SchemaJsonParams 4 | * @typedef {import('../').SchemaParams>} SchemaHashParams 5 | */ 6 | /** 7 | * Transforms JSON params to Hash params 8 | * @param {SchemaJsonParams} params 9 | * @returns {SchemaHashParams} 10 | */ 11 | declare function fromJsonPipe(params: SchemaJsonParams): SchemaHashParams 12 | declare namespace fromJsonPipe { 13 | export { SchemaJsonParams, SchemaHashParams } 14 | } 15 | type SchemaJsonParams = { 16 | current?: string 17 | upcoming?: string 18 | cached?: string 19 | result?: string 20 | } 21 | type SchemaHashParams = { 22 | current?: Map 23 | upcoming?: Map 24 | cached?: Map 25 | result?: Map 26 | } 27 | -------------------------------------------------------------------------------- /packages/sharec-schema/types/pipes/fromYaml.d.ts: -------------------------------------------------------------------------------- 1 | export = fromYaml 2 | /** 3 | * @typedef {import('../').SchemaParams} SchemaYamlParams 4 | * @typedef {import('../').SchemaParams>} SchemaHashParams 5 | */ 6 | /** 7 | * Transforms JSON params to Hash params 8 | * @param {SchemaYamlParams} params 9 | * @returns {SchemaHashParams} 10 | */ 11 | declare function fromYaml(params: SchemaYamlParams): SchemaHashParams 12 | declare namespace fromYaml { 13 | export { SchemaYamlParams, SchemaHashParams } 14 | } 15 | type SchemaYamlParams = { 16 | current?: string 17 | upcoming?: string 18 | cached?: string 19 | result?: string 20 | } 21 | type SchemaHashParams = { 22 | current?: Map 23 | upcoming?: Map 24 | cached?: Map 25 | result?: Map 26 | } 27 | -------------------------------------------------------------------------------- /packages/sharec-schema/types/pipes/index.d.ts: -------------------------------------------------------------------------------- 1 | import fromJson = require('./fromJson') 2 | import toJson = require('./toJson') 3 | import fromYaml = require('./fromYaml') 4 | import toYaml = require('./toYaml') 5 | import createJsonPipe = require('./createJsonPipe') 6 | import createYamlPipe = require('./createYamlPipe') 7 | export { fromJson, toJson, fromYaml, toYaml, createJsonPipe, createYamlPipe } 8 | -------------------------------------------------------------------------------- /packages/sharec-schema/types/pipes/toJson.d.ts: -------------------------------------------------------------------------------- 1 | export = toJsonPipe 2 | /** 3 | * Transforms Map to JSON-string 4 | * @param {Map} input 5 | * @returns {string} 6 | */ 7 | declare function toJsonPipe(input: Map): string 8 | -------------------------------------------------------------------------------- /packages/sharec-schema/types/pipes/toYaml.d.ts: -------------------------------------------------------------------------------- 1 | export = toYaml 2 | /** 3 | * Transforms JSON-string to YAML-string 4 | * @param {string} input 5 | * @returns {string} 6 | */ 7 | declare function toYaml(input: string): string 8 | -------------------------------------------------------------------------------- /packages/sharec-utils/.npmignore: -------------------------------------------------------------------------------- 1 | src/**/*.test.js 2 | .gitignore 3 | tsconfig.json 4 | lib/test 5 | jest.setup.js 6 | -------------------------------------------------------------------------------- /packages/sharec-utils/jest.setup.js: -------------------------------------------------------------------------------- 1 | jest.mock('./lib/std', () => { 2 | const fs = require('memfs').promises 3 | 4 | return { 5 | readdir: fs.readdir, 6 | makedir: fs.mkdir, 7 | readFile: fs.readFile, 8 | copyFile: fs.copyFile, 9 | writeFile: fs.writeFile, 10 | lstat: fs.lstat, 11 | removeFile: fs.unlink, 12 | } 13 | }) 14 | -------------------------------------------------------------------------------- /packages/sharec-utils/lib/index.js: -------------------------------------------------------------------------------- 1 | const format = require('./format') 2 | const fs = require('./fs') 3 | const map = require('./map') 4 | const std = require('./std') 5 | const path = require('./path') 6 | 7 | /** 8 | * @typedef {object} FormattingRules 9 | * @property {'space' | 'tab'} [indentType] 10 | * @property {number} [indentSize] 11 | * @property {boolean} [eof] 12 | */ 13 | 14 | /** 15 | * @typedef {{ [x: string]: FormattingRules }} MappedFormattingRules 16 | */ 17 | 18 | module.exports = { 19 | format, 20 | fs, 21 | map, 22 | std, 23 | path, 24 | } 25 | -------------------------------------------------------------------------------- /packages/sharec-utils/lib/path.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const nativePath = require('path') 3 | const slash = require('slash') 4 | 5 | /** 6 | * Original node `path.join`, but with normalized slashes 7 | * @param {String} p 8 | * @param {...String} parts 9 | * @returns {String} 10 | */ 11 | const join = (p, ...parts) => slash(nativePath.join(p, ...parts)) 12 | 13 | /** 14 | * Original node `path.resolve`, but with normalized slashes 15 | * @param {String} p 16 | * @param {...String} parts 17 | * @returns {String} 18 | */ 19 | const resolve = (p, ...parts) => slash(nativePath.resolve(p, ...parts)) 20 | 21 | /** 22 | * Original node `path.basename`, but with normalized slashes 23 | * @param {String} p 24 | * @param {String=} ext 25 | * @returns {String} 26 | */ 27 | const basename = (p, ext) => slash(nativePath.basename(p, ext)) 28 | 29 | /** 30 | * Original node `path.dirname`, but with normalized slashes 31 | * @param {String} p 32 | * @returns {String} 33 | */ 34 | const dirname = (p) => slash(nativePath.dirname(p)) 35 | 36 | module.exports = { 37 | join, 38 | resolve, 39 | basename, 40 | dirname, 41 | } 42 | -------------------------------------------------------------------------------- /packages/sharec-utils/lib/std.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const nativeFS = require('fs') 3 | const { promisify } = require('util') 4 | 5 | module.exports = { 6 | readdir: promisify(nativeFS.readdir), 7 | makedir: promisify(nativeFS.mkdir), 8 | readFile: promisify(nativeFS.readFile), 9 | copyFile: promisify(nativeFS.copyFile), 10 | writeFile: promisify(nativeFS.writeFile), 11 | lstat: promisify(nativeFS.lstat), 12 | removeFile: promisify(nativeFS.unlink), 13 | stat: promisify(nativeFS.stat), 14 | } 15 | -------------------------------------------------------------------------------- /packages/sharec-utils/lib/test/fs.test.js: -------------------------------------------------------------------------------- 1 | const { vol } = require('memfs') 2 | const { safeMakeDir, find } = require('../fs') 3 | 4 | describe('utils > fs >', () => { 5 | beforeEach(() => { 6 | vol.reset() 7 | }) 8 | 9 | describe('safeMakeDir', () => { 10 | it('should create directories by given path recursively', async () => { 11 | vol.fromJSON({}, '/') 12 | 13 | await safeMakeDir('/foo/bar/baz') 14 | 15 | expect(vol.readdirSync('/foo/bar')).toEqual(['baz']) 16 | }) 17 | }) 18 | 19 | describe('find', () => { 20 | beforeEach(() => { 21 | vol.reset() 22 | }) 23 | 24 | it('should find all files matched by given path', async () => { 25 | const dir = { 26 | 'foo/bar/baz.txt': 'foo', 27 | 'bar/baz.txt': 'foo', 28 | 'baz.txt': 'foo', 29 | } 30 | 31 | vol.fromJSON(dir, '/') 32 | 33 | const res = await find('/', '**/baz.txt') 34 | 35 | expect(res).toHaveLength(3) 36 | expect(res).toEqual(expect.arrayContaining(['/baz.txt', '/bar/baz.txt', '/foo/bar/baz.txt'])) 37 | }) 38 | }) 39 | }) 40 | -------------------------------------------------------------------------------- /packages/sharec-utils/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./types", 4 | "moduleResolution": "node", 5 | "allowJs": true, 6 | "checkJs": true, 7 | "declaration": true, 8 | "types": ["node", "jest"] 9 | }, 10 | "include": ["./lib/*.js"], 11 | "exclude": ["./lib/*.test.js"] 12 | } 13 | -------------------------------------------------------------------------------- /packages/sharec-utils/types/fs.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Makes directory with standard makedir, but do not throws 3 | * any exceptions 4 | * @param {string} path Path to new directory 5 | * @returns {Promise} 6 | */ 7 | export function safeMakeDir(path: string): Promise 8 | /** 9 | * Find all files by given pattern in all directories located by 10 | * given path 11 | * @example 12 | * await find('.', '*') // will find all files in current dir 13 | * await find('.', '*.js') // will find all *.js files in current dir 14 | * @param {string} path Target path 15 | * @param {string} pattern Matching pattern 16 | * @returns {Promise} 17 | */ 18 | export function find(path: string, pattern: string): Promise 19 | -------------------------------------------------------------------------------- /packages/sharec-utils/types/index.d.ts: -------------------------------------------------------------------------------- 1 | export type FormattingRules = { 2 | indentType?: 'space' | 'tab' 3 | indentSize?: number 4 | eof?: boolean 5 | } 6 | export type MappedFormattingRules = { 7 | [x: string]: FormattingRules 8 | } 9 | import format = require('./format') 10 | import fs = require('./fs') 11 | import map = require('./map') 12 | import std = require('./std') 13 | import path = require('./path') 14 | export { format, fs, map, std, path } 15 | -------------------------------------------------------------------------------- /packages/sharec-utils/types/path.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Original node `path.join`, but with normalized slashes 3 | * @param {String} p 4 | * @param {...String} parts 5 | * @returns {String} 6 | */ 7 | export function join(p: string, ...parts: string[]): string 8 | /** 9 | * Original node `path.resolve`, but with normalized slashes 10 | * @param {String} p 11 | * @param {...String} parts 12 | * @returns {String} 13 | */ 14 | export function resolve(p: string, ...parts: string[]): string 15 | /** 16 | * Original node `path.basename`, but with normalized slashes 17 | * @param {String} p 18 | * @param {String=} ext 19 | * @returns {String} 20 | */ 21 | export function basename(p: string, ext?: string | undefined): string 22 | /** 23 | * Original node `path.dirname`, but with normalized slashes 24 | * @param {String} p 25 | * @returns {String} 26 | */ 27 | export function dirname(p: string): string 28 | -------------------------------------------------------------------------------- /packages/sharec-utils/types/std.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | import nativeFS = require('fs') 3 | export const readdir: typeof nativeFS.readdir.__promisify__ 4 | export const makedir: typeof nativeFS.mkdir.__promisify__ 5 | export const readFile: typeof nativeFS.readFile.__promisify__ 6 | export const copyFile: typeof nativeFS.copyFile.__promisify__ 7 | export const writeFile: typeof nativeFS.writeFile.__promisify__ 8 | export const lstat: typeof nativeFS.lstat.__promisify__ 9 | export const removeFile: typeof nativeFS.unlink.__promisify__ 10 | export const stat: typeof nativeFS.stat.__promisify__ 11 | -------------------------------------------------------------------------------- /packages/sharec/.npmignore: -------------------------------------------------------------------------------- 1 | src/**/*.test.js 2 | docs 3 | -------------------------------------------------------------------------------- /packages/sharec/README.md: -------------------------------------------------------------------------------- 1 | # Sharec 2 | 3 | [![.github/workflows/main.yml](https://github.com/lamartire/sharec/workflows/.github/workflows/main.yml/badge.svg)](https://github.com/lamartire/sharec/actions) 4 | [![npm](https://img.shields.io/npm/v/sharec)](https://npmjs.com/sharec) 5 | ![MIT License](https://camo.githubusercontent.com/4481c7672053be9c676fbc983c040ca59fddfa19/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f6c2f6c6f6775782d70726f636573736f722e737667) 6 | 7 | Read more on [sharec.js.org](https://sharec.js.org/overview.html) 8 | -------------------------------------------------------------------------------- /packages/sharec/bin/sharec: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | /* eslint-disable */ 3 | const sharec = require('../lib') 4 | 5 | ;(async () => { 6 | await sharec(process) 7 | })() 8 | -------------------------------------------------------------------------------- /packages/sharec/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sharec", 3 | "version": "3.2.1", 4 | "description": "Smart configuration manager for your projects", 5 | "keywords": [ 6 | "configuration", 7 | "sharec", 8 | "sharing", 9 | "reusable code", 10 | "codemods", 11 | "codegeneration" 12 | ], 13 | "homepage": "https://sharec.js.org", 14 | "repository": { 15 | "type": "git", 16 | "url": "git+https://github.com/lamartire/sharec" 17 | }, 18 | "author": "Konstantin Epishev ", 19 | "license": "MIT", 20 | "main": "./src/sharec.js", 21 | "bin": "./bin/sharec", 22 | "scripts": { 23 | "types": "echo 'types generation not applicable in this package yet'" 24 | }, 25 | "dependencies": { 26 | "minimist": "^1.2.6", 27 | "nanospinner": "^1.1.0", 28 | "picocolors": "^1.0.0", 29 | "sharec-core": "^3.2.1" 30 | }, 31 | "gitHead": "8b056dc9aedf49a712b84b4d47ea9fa1cea45b08" 32 | } 33 | -------------------------------------------------------------------------------- /packages/sharec/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "moduleResolution": "node", 4 | "allowJs": true, 5 | "checkJs": true, 6 | "types": ["node", "jest"] 7 | }, 8 | "include": ["./lib/*.js"], 9 | "exclude": ["./lib/*.test.js"] 10 | } 11 | -------------------------------------------------------------------------------- /test/fixtures/babel/json/00-base/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["env", "stage-2"], 3 | "plugins": ["syntax-dynamic-import", "lodash"], 4 | "env": { 5 | "test": { 6 | "presets": ["env"], 7 | "plugins": ["dynamic-import-node"] 8 | } 9 | }, 10 | "ignore": ["*.babelrc"] 11 | } 12 | -------------------------------------------------------------------------------- /test/fixtures/babel/json/00-base/result.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "env", 5 | { 6 | "modules": false, 7 | "targets": { 8 | "browsers": [ 9 | "> 1%", 10 | "last 2 versions", 11 | "not ie > 0" 12 | ] 13 | } 14 | } 15 | ], 16 | "stage-2" 17 | ], 18 | "plugins": [ 19 | [ 20 | "syntax-dynamic-import", 21 | { 22 | "foo": "bar" 23 | } 24 | ], 25 | "lodash" 26 | ], 27 | "env": { 28 | "test": { 29 | "presets": [ 30 | "env", 31 | "stage-2" 32 | ], 33 | "plugins": [ 34 | "dynamic-import-node" 35 | ] 36 | } 37 | }, 38 | "ignore": [ 39 | "*.babelrc" 40 | ] 41 | } 42 | -------------------------------------------------------------------------------- /test/fixtures/babel/json/00-base/upcoming.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "env", 5 | { 6 | "modules": false, 7 | "targets": { 8 | "browsers": ["> 1%", "last 2 versions", "not ie > 0"] 9 | } 10 | } 11 | ] 12 | ], 13 | "plugins": [ 14 | [ 15 | "syntax-dynamic-import", 16 | { 17 | "foo": "bar" 18 | } 19 | ] 20 | ], 21 | "env": { 22 | "test": { 23 | "presets": ["env", "stage-2"] 24 | } 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /test/fixtures/babel/json/01-with-empty/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "test": { 4 | "presets": ["env"] 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures/babel/json/01-with-empty/result.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "test": { 4 | "presets": ["env"] 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures/babel/json/01-with-empty/upcoming.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/fixtures/babel/json/02-with-empty/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "test": { 4 | "presets": ["env"] 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures/babel/json/02-with-empty/result.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "test": { 4 | "presets": ["env"] 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures/babel/json/02-with-empty/upcoming.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/fixtures/babel/json/03-unique-env/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "test": { 4 | "presets": ["env"] 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures/babel/json/03-unique-env/result.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "test": { 4 | "presets": ["env"] 5 | }, 6 | "development": { 7 | "presets": ["stage-2"] 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/fixtures/babel/json/03-unique-env/upcoming.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "test": { 4 | "presets": ["env"] 5 | }, 6 | "development": { 7 | "presets": ["stage-2"] 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/fixtures/babel/json/04-listed-values/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "env", 5 | { 6 | "modules": false, 7 | "targets": { 8 | "browsers": ["> 1%", "last 2 versions", "not ie > 0"] 9 | } 10 | } 11 | ], 12 | "stage-2" 13 | ], 14 | "plugins": [ 15 | [ 16 | "syntax-dynamic-import", 17 | { 18 | "foo": "baz" 19 | } 20 | ], 21 | "lodash" 22 | ], 23 | "env": { 24 | "test": { 25 | "presets": ["env", "stage-3"], 26 | "plugins": ["dynamic-import-node"] 27 | } 28 | }, 29 | "ignore": ["*.babelrc", "*.vue"] 30 | } 31 | -------------------------------------------------------------------------------- /test/fixtures/babel/json/04-listed-values/result.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "env", 5 | { 6 | "modules": false, 7 | "targets": { 8 | "browsers": ["> 1%", "last 2 versions", "not ie > 10", "not ie > 0"] 9 | } 10 | } 11 | ], 12 | "stage-2" 13 | ], 14 | "plugins": [ 15 | [ 16 | "syntax-dynamic-import", 17 | { 18 | "foo": "bar" 19 | } 20 | ], 21 | "lodash" 22 | ], 23 | "env": { 24 | "test": { 25 | "presets": ["env", "stage-2"], 26 | "plugins": ["dynamic-import-node"] 27 | } 28 | }, 29 | "ignore": ["*.babelrc", "*.vue"] 30 | } 31 | -------------------------------------------------------------------------------- /test/fixtures/babel/json/04-listed-values/upcoming.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "env", 5 | { 6 | "modules": false, 7 | "targets": { 8 | "browsers": ["> 1%", "last 2 versions", "not ie > 10", "not ie > 0"] 9 | } 10 | } 11 | ], 12 | "stage-2" 13 | ], 14 | "plugins": [ 15 | [ 16 | "syntax-dynamic-import", 17 | { 18 | "foo": "bar" 19 | } 20 | ], 21 | "lodash" 22 | ], 23 | "env": { 24 | "test": { 25 | "presets": ["env", "stage-2"], 26 | "plugins": ["dynamic-import-node"] 27 | } 28 | }, 29 | "ignore": ["*.babelrc"] 30 | } 31 | -------------------------------------------------------------------------------- /test/fixtures/babel/json/05-update/cached.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "env", 5 | { 6 | "modules": false, 7 | "targets": { 8 | "browsers": ["> 1%", "last 2 versions", "not ie > 0"] 9 | } 10 | } 11 | ] 12 | ], 13 | "plugins": [ 14 | [ 15 | "syntax-dynamic-import", 16 | { 17 | "foo": "bar" 18 | } 19 | ] 20 | ], 21 | "env": { 22 | "test": { 23 | "presets": ["env", "stage-2"] 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /test/fixtures/babel/json/05-update/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "env", 5 | { 6 | "modules": false, 7 | "targets": { 8 | "browsers": ["> 1%", "last 2 versions", "not ie > 0"] 9 | } 10 | } 11 | ] 12 | ], 13 | "plugins": ["syntax-dynamic-import"], 14 | "env": { 15 | "test": { 16 | "presets": ["env", "stage-2"] 17 | } 18 | }, 19 | "ignore": ["foo", "bar"] 20 | } 21 | -------------------------------------------------------------------------------- /test/fixtures/babel/json/05-update/result.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "env", 5 | { 6 | "modules": true, 7 | "targets": { 8 | "browsers": [ 9 | "> 1%", 10 | "last 2 versions" 11 | ] 12 | } 13 | } 14 | ] 15 | ], 16 | "plugins": [ 17 | "syntax-dynamic-import" 18 | ], 19 | "env": { 20 | "test": { 21 | "presets": [ 22 | "stage-3", 23 | "stage-2" 24 | ] 25 | } 26 | }, 27 | "ignore": [ 28 | "foo", 29 | "bar" 30 | ] 31 | } 32 | 33 | -------------------------------------------------------------------------------- /test/fixtures/babel/json/05-update/upcoming.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "env", 5 | { 6 | "modules": true, 7 | "targets": { 8 | "browsers": ["> 1%", "last 2 versions"] 9 | } 10 | } 11 | ] 12 | ], 13 | "plugins": [ 14 | [ 15 | "syntax-dynamic-import", 16 | { 17 | "foo": "bar", 18 | "bar": "baz" 19 | } 20 | ] 21 | ], 22 | "env": { 23 | "test": { 24 | "presets": ["stage-3"] 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /test/fixtures/babel/json/06-disappear/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["env", "stage-2"], 3 | "plugins": ["syntax-dynamic-import", "lodash"], 4 | "env": { 5 | "test": { 6 | "presets": ["env"], 7 | "plugins": ["dynamic-import-node"] 8 | } 9 | }, 10 | "ignore": ["*.babelrc"] 11 | } 12 | -------------------------------------------------------------------------------- /test/fixtures/babel/json/06-disappear/result.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "env", 5 | { 6 | "modules": false, 7 | "targets": { 8 | "browsers": [ 9 | "> 1%", 10 | "last 2 versions", 11 | "not ie > 0" 12 | ] 13 | } 14 | } 15 | ], 16 | "stage-2" 17 | ], 18 | "plugins": [ 19 | [ 20 | "syntax-dynamic-import", 21 | { 22 | "foo": "bar" 23 | } 24 | ], 25 | "lodash" 26 | ], 27 | "env": { 28 | "test": { 29 | "presets": [ 30 | "env", 31 | "stage-2" 32 | ], 33 | "plugins": [ 34 | "dynamic-import-node" 35 | ] 36 | } 37 | }, 38 | "ignore": [ 39 | "*.babelrc" 40 | ] 41 | } 42 | 43 | -------------------------------------------------------------------------------- /test/fixtures/babel/json/06-disappear/upcoming.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "env", 5 | { 6 | "modules": false, 7 | "targets": { 8 | "browsers": ["> 1%", "last 2 versions", "not ie > 0"] 9 | } 10 | } 11 | ] 12 | ], 13 | "plugins": [ 14 | [ 15 | "syntax-dynamic-import", 16 | { 17 | "foo": "bar" 18 | } 19 | ] 20 | ], 21 | "env": { 22 | "test": { 23 | "presets": ["env", "stage-2"] 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /test/fixtures/babel/json/07-format/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "env", 4 | "stage-2" 5 | ], 6 | "plugins": [ 7 | "syntax-dynamic-import", 8 | "lodash" 9 | ], 10 | "env": { 11 | "test": { 12 | "presets": [ 13 | "env" 14 | ], 15 | "plugins": [ 16 | "dynamic-import-node" 17 | ] 18 | } 19 | }, 20 | "ignore": [ 21 | "*.babelrc" 22 | ] 23 | } -------------------------------------------------------------------------------- /test/fixtures/babel/json/07-format/result.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "env", 5 | { 6 | "modules": false, 7 | "targets": { 8 | "browsers": [ 9 | "> 1%", 10 | "last 2 versions", 11 | "not ie > 0" 12 | ] 13 | } 14 | } 15 | ], 16 | "stage-2" 17 | ], 18 | "plugins": [ 19 | [ 20 | "syntax-dynamic-import", 21 | { 22 | "foo": "bar" 23 | } 24 | ], 25 | "lodash" 26 | ], 27 | "env": { 28 | "test": { 29 | "presets": [ 30 | "env", 31 | "stage-2" 32 | ], 33 | "plugins": [ 34 | "dynamic-import-node" 35 | ] 36 | } 37 | }, 38 | "ignore": [ 39 | "*.babelrc" 40 | ] 41 | } 42 | 43 | -------------------------------------------------------------------------------- /test/fixtures/babel/json/07-format/upcoming.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "env", 5 | { 6 | "modules": false, 7 | "targets": { 8 | "browsers": ["> 1%", "last 2 versions", "not ie > 0"] 9 | } 10 | } 11 | ] 12 | ], 13 | "plugins": [ 14 | [ 15 | "syntax-dynamic-import", 16 | { 17 | "foo": "bar" 18 | } 19 | ] 20 | ], 21 | "env": { 22 | "test": { 23 | "presets": ["env", "stage-2"] 24 | } 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /test/fixtures/browserslist/json/00-array-like/current.json: -------------------------------------------------------------------------------- 1 | ["last 1 version", "> 1%"] 2 | -------------------------------------------------------------------------------- /test/fixtures/browserslist/json/00-array-like/result.json: -------------------------------------------------------------------------------- 1 | ["last 1 version", "> 1%", "maintained node versions", "not dead"] 2 | -------------------------------------------------------------------------------- /test/fixtures/browserslist/json/00-array-like/upcoming.json: -------------------------------------------------------------------------------- 1 | ["maintained node versions", "not dead"] 2 | -------------------------------------------------------------------------------- /test/fixtures/browserslist/lines/00-base/current.txt: -------------------------------------------------------------------------------- 1 | last 1 version 2 | > 1% 3 | 4 | -------------------------------------------------------------------------------- /test/fixtures/browserslist/lines/00-base/result.txt: -------------------------------------------------------------------------------- 1 | last 1 version 2 | > 1% 3 | maintained node versions 4 | not dead 5 | 6 | -------------------------------------------------------------------------------- /test/fixtures/browserslist/lines/00-base/upcoming.txt: -------------------------------------------------------------------------------- 1 | maintained node versions 2 | not dead 3 | 4 | -------------------------------------------------------------------------------- /test/fixtures/commitlint/json/00-base/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "parserPreset": "conventional-changelog-conventionalcommits", 3 | "rules": { 4 | "body-leading-blank": [1, "always"], 5 | "body-max-line-length": [2, "always", 100], 6 | "footer-leading-blank": [1, "always"], 7 | "type-enum": [2, "always", ["build", "chore", "ci", "docs", "feat", "fix"]] 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/fixtures/commitlint/json/00-base/result.json: -------------------------------------------------------------------------------- 1 | { 2 | "parserPreset": "other-parser", 3 | "rules": { 4 | "body-leading-blank": [ 5 | 2, 6 | "never" 7 | ], 8 | "body-max-line-length": [ 9 | 2, 10 | "always", 11 | 100 12 | ], 13 | "footer-leading-blank": [ 14 | 1, 15 | "always" 16 | ], 17 | "type-enum": [ 18 | 2, 19 | "always", 20 | [ 21 | "feat", 22 | "fix", 23 | "perf", 24 | "refactor", 25 | "revert", 26 | "style", 27 | "test" 28 | ] 29 | ], 30 | "footer-max-line-length": [ 31 | 2, 32 | "always", 33 | 100 34 | ], 35 | "header-max-length": [ 36 | 2, 37 | "always", 38 | 100 39 | ] 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /test/fixtures/commitlint/json/00-base/upcoming.json: -------------------------------------------------------------------------------- 1 | { 2 | "parserPreset": "other-parser", 3 | "rules": { 4 | "body-leading-blank": [2, "never"], 5 | "body-max-line-length": [2, "always", 100], 6 | "footer-leading-blank": [1, "always"], 7 | "footer-max-line-length": [2, "always", 100], 8 | "header-max-length": [2, "always", 100], 9 | "type-enum": [2, "always", ["feat", "fix", "perf", "refactor", "revert", "style", "test"]] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/fixtures/commitlint/yaml/00-base/current.yaml: -------------------------------------------------------------------------------- 1 | parserPreset: conventional-changelog-conventionalcommits 2 | rules: 3 | body-leading-blank: 4 | - 1 5 | - always 6 | body-max-line-length: 7 | - 2 8 | - always 9 | - 100 10 | footer-leading-blank: 11 | - 1 12 | - always 13 | type-enum: 14 | - 2 15 | - always 16 | - - build 17 | - chore 18 | - ci 19 | - docs 20 | - feat 21 | - fix 22 | 23 | -------------------------------------------------------------------------------- /test/fixtures/commitlint/yaml/00-base/result.yaml: -------------------------------------------------------------------------------- 1 | parserPreset: other-parser 2 | rules: 3 | body-leading-blank: 4 | - 2 5 | - never 6 | body-max-line-length: 7 | - 2 8 | - always 9 | - 100 10 | footer-leading-blank: 11 | - 1 12 | - always 13 | type-enum: 14 | - 2 15 | - always 16 | - - feat 17 | - fix 18 | - perf 19 | - refactor 20 | - revert 21 | - style 22 | - test 23 | footer-max-line-length: 24 | - 2 25 | - always 26 | - 100 27 | header-max-length: 28 | - 2 29 | - always 30 | - 100 31 | 32 | -------------------------------------------------------------------------------- /test/fixtures/commitlint/yaml/00-base/upcoming.yaml: -------------------------------------------------------------------------------- 1 | parserPreset: other-parser 2 | rules: 3 | body-leading-blank: 4 | - 2 5 | - never 6 | body-max-line-length: 7 | - 2 8 | - always 9 | - 100 10 | footer-leading-blank: 11 | - 1 12 | - always 13 | footer-max-line-length: 14 | - 2 15 | - always 16 | - 100 17 | header-max-length: 18 | - 2 19 | - always 20 | - 100 21 | type-enum: 22 | - 2 23 | - always 24 | - - feat 25 | - fix 26 | - perf 27 | - refactor 28 | - revert 29 | - style 30 | - test 31 | 32 | -------------------------------------------------------------------------------- /test/fixtures/default/json/00-base/cached.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": "bar" 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/default/json/00-base/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": "bar", 3 | "bar": "baz", 4 | "baz": { 5 | "foo": "bar", 6 | "bar": "baz" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/fixtures/default/json/00-base/result.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": "baz", 3 | "bar": { 4 | "foo": "foo" 5 | }, 6 | "baz": { 7 | "foo": "bar", 8 | "bar": "baz" 9 | } 10 | } 11 | 12 | -------------------------------------------------------------------------------- /test/fixtures/default/json/00-base/upcoming.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": "baz", 3 | "bar": { 4 | "foo": "foo" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/fixtures/default/json/01-handle-removed/cached.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": "foo", 3 | "bar": "bar", 4 | "baz": "baz" 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/default/json/01-handle-removed/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "bar": "bar", 3 | "baz": "baz" 4 | } 5 | -------------------------------------------------------------------------------- /test/fixtures/default/json/01-handle-removed/result.json: -------------------------------------------------------------------------------- 1 | { 2 | "bar": "new bar", 3 | "baz": "baz" 4 | } 5 | -------------------------------------------------------------------------------- /test/fixtures/default/json/01-handle-removed/upcoming.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": "new foo", 3 | "bar": "new bar" 4 | } 5 | -------------------------------------------------------------------------------- /test/fixtures/default/json/02-formatting/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": "foo", 3 | "bar": "bar", 4 | "baz": "baz" 5 | } -------------------------------------------------------------------------------- /test/fixtures/default/json/02-formatting/result.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": "foo", 3 | "bar": "bar", 4 | "baz": "baz" 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/default/json/03-comments/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": "bar", 3 | // Comment here 4 | "bar": "baz", /* Another comment */ 5 | "baz": { 6 | "foo": "bar", 7 | /* Another comment here */ 8 | "bar": "baz" // Another comment 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/fixtures/default/yaml/00-base/cached.yml: -------------------------------------------------------------------------------- 1 | foo: bar 2 | 3 | -------------------------------------------------------------------------------- /test/fixtures/default/yaml/00-base/current.yml: -------------------------------------------------------------------------------- 1 | foo: bar 2 | bar: baz 3 | baz: 4 | foo: bar 5 | bar: baz 6 | 7 | -------------------------------------------------------------------------------- /test/fixtures/default/yaml/00-base/result.yml: -------------------------------------------------------------------------------- 1 | foo: baz 2 | bar: 3 | foo: foo 4 | baz: 5 | foo: bar 6 | bar: baz 7 | 8 | -------------------------------------------------------------------------------- /test/fixtures/default/yaml/00-base/upcoming.yml: -------------------------------------------------------------------------------- 1 | foo: baz 2 | bar: 3 | foo: foo 4 | 5 | -------------------------------------------------------------------------------- /test/fixtures/default/yaml/01-formatting/current.yml: -------------------------------------------------------------------------------- 1 | foo: 2 | bar: 3 | baz: baz 4 | -------------------------------------------------------------------------------- /test/fixtures/default/yaml/01-formatting/result.yml: -------------------------------------------------------------------------------- 1 | foo: 2 | bar: 3 | baz: baz 4 | -------------------------------------------------------------------------------- /test/fixtures/editorconfig/lines/00-base/current.txt: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | -------------------------------------------------------------------------------- /test/fixtures/editorconfig/lines/01-tabs/current.txt: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | indent_size = 4 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | -------------------------------------------------------------------------------- /test/fixtures/eslint/json/01-base/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es6": true, 5 | "node": true, 6 | "jest": true 7 | }, 8 | "globals": { 9 | "foo": true, 10 | "bar": true 11 | }, 12 | "extends": "standard", 13 | "rules": { 14 | "max-len": [ 15 | "warn", 16 | 80, 17 | 2, 18 | { 19 | "ignoreUrls": true, 20 | "ignoreComments": false, 21 | "ignoreStrings": true, 22 | "ignoreTemplateLiterals": false 23 | } 24 | ] 25 | }, 26 | "parserOptions": { 27 | "parser": "babel-eslint", 28 | "ecmaVersion": 8, 29 | "ecmaFeatures": { 30 | "spread": true 31 | }, 32 | "sourceType": "module" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /test/fixtures/eslint/json/01-base/result.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es6": true, 5 | "node": true, 6 | "jest": true 7 | }, 8 | "globals": { 9 | "foo": true, 10 | "bar": true 11 | }, 12 | "extends": "airbnb", 13 | "rules": { 14 | "max-len": [ 15 | "warn", 16 | 120, 17 | 4, 18 | { 19 | "ignoreUrls": false, 20 | "ignoreComments": true, 21 | "ignoreStrings": false 22 | } 23 | ], 24 | "space-before-function-paren": 1, 25 | "no-console": 0 26 | }, 27 | "parserOptions": { 28 | "parser": "babel-eslint", 29 | "ecmaVersion": 7, 30 | "ecmaFeatures": { 31 | "spread": true 32 | }, 33 | "sourceType": "module" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /test/fixtures/eslint/json/01-base/upcoming.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es6": true, 5 | "node": true, 6 | "jest": true 7 | }, 8 | "extends": "airbnb", 9 | "rules": { 10 | "space-before-function-paren": 1, 11 | "no-console": 0, 12 | "max-len": [ 13 | "warn", 14 | 120, 15 | 4, 16 | { 17 | "ignoreUrls": false, 18 | "ignoreComments": true, 19 | "ignoreStrings": false 20 | } 21 | ] 22 | }, 23 | "parserOptions": { 24 | "parser": "babel-eslint", 25 | "ecmaVersion": 7, 26 | "ecmaFeatures": { 27 | "spread": true 28 | }, 29 | "sourceType": "module" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /test/fixtures/eslint/json/02-update/cached.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es6": true, 5 | "node": true 6 | }, 7 | "extends": "airbnb", 8 | "rules": { 9 | "space-before-function-paren": 1, 10 | "no-console": 0, 11 | "max-len": [ 12 | "warn", 13 | 120, 14 | 4, 15 | { 16 | "ignoreUrls": false, 17 | "ignoreComments": true, 18 | "ignoreStrings": false 19 | } 20 | ] 21 | }, 22 | "parserOptions": { 23 | "parser": "babel-eslint", 24 | "ecmaVersion": 7, 25 | "ecmaFeatures": { 26 | "spread": true 27 | }, 28 | "sourceType": "module" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /test/fixtures/eslint/json/02-update/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es6": true, 5 | "node": true 6 | }, 7 | "extends": "airbnb", 8 | "rules": { 9 | "space-before-function-paren": 1, 10 | "no-console": 0, 11 | "max-len": [ 12 | "warn", 13 | 120, 14 | 2, 15 | { 16 | "ignoreUrls": false, 17 | "ignoreComments": true, 18 | "ignoreStrings": false 19 | } 20 | ] 21 | }, 22 | "parserOptions": { 23 | "parser": "babel-eslint", 24 | "ecmaVersion": 7, 25 | "ecmaFeatures": { 26 | "spread": false 27 | }, 28 | "sourceType": "module" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /test/fixtures/eslint/json/02-update/result.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es6": true, 5 | "node": true, 6 | "jest": true 7 | }, 8 | "extends": "airbnb", 9 | "rules": { 10 | "space-before-function-paren": 1, 11 | "no-console": 0, 12 | "max-len": [ 13 | "warn", 14 | 120, 15 | 2, 16 | { 17 | "ignoreUrls": false, 18 | "ignoreComments": true, 19 | "ignoreStrings": false 20 | } 21 | ], 22 | "prettier/trailingComma": "all", 23 | "prettier/semi": false, 24 | "prettier/singleQuote": true 25 | }, 26 | "parserOptions": { 27 | "parser": "babel-eslint", 28 | "ecmaVersion": "es2019", 29 | "ecmaFeatures": { 30 | "spread": false 31 | }, 32 | "sourceType": "module" 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /test/fixtures/eslint/json/02-update/upcoming.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es6": true, 5 | "node": true, 6 | "jest": true 7 | }, 8 | "extends": "airbnb", 9 | "rules": { 10 | "prettier/trailingComma": "all", 11 | "prettier/semi": false, 12 | "prettier/singleQuote": true, 13 | "space-before-function-paren": 1, 14 | "no-console": 0, 15 | "max-len": [ 16 | "warn", 17 | 80, 18 | 4, 19 | { 20 | "ignoreUrls": false, 21 | "ignoreComments": true, 22 | "ignoreStrings": false 23 | } 24 | ] 25 | }, 26 | "parserOptions": { 27 | "parser": "babel-eslint", 28 | "ecmaVersion": "es2019", 29 | "ecmaFeatures": { 30 | "spread": true 31 | }, 32 | "sourceType": "module" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /test/fixtures/eslint/json/03-disappear/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es6": true, 5 | "node": true, 6 | "jest": true 7 | }, 8 | "globals": { 9 | "foo": true, 10 | "bar": true 11 | }, 12 | "extends": "standard", 13 | "rules": { 14 | "max-len": [ 15 | "warn", 16 | 80, 17 | 2, 18 | { 19 | "ignoreUrls": true, 20 | "ignoreComments": false, 21 | "ignoreStrings": true, 22 | "ignoreTemplateLiterals": false 23 | } 24 | ] 25 | }, 26 | "parserOptions": { 27 | "parser": "babel-eslint", 28 | "ecmaVersion": 8, 29 | "ecmaFeatures": { 30 | "spread": true 31 | }, 32 | "sourceType": "module" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /test/fixtures/eslint/json/03-disappear/result.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es6": true, 5 | "node": true, 6 | "jest": true 7 | }, 8 | "globals": { 9 | "foo": true, 10 | "bar": true 11 | }, 12 | "extends": "airbnb", 13 | "rules": { 14 | "max-len": [ 15 | "warn", 16 | 120, 17 | 4, 18 | { 19 | "ignoreUrls": false, 20 | "ignoreComments": true, 21 | "ignoreStrings": false 22 | } 23 | ], 24 | "space-before-function-paren": 1, 25 | "no-console": 0 26 | }, 27 | "parserOptions": { 28 | "parser": "babel-eslint", 29 | "ecmaVersion": 7, 30 | "ecmaFeatures": { 31 | "spread": true 32 | }, 33 | "sourceType": "module" 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /test/fixtures/eslint/json/03-disappear/upcoming.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es6": true, 5 | "node": true, 6 | "jest": true 7 | }, 8 | "extends": "airbnb", 9 | "rules": { 10 | "space-before-function-paren": 1, 11 | "no-console": 0, 12 | "max-len": [ 13 | "warn", 14 | 120, 15 | 4, 16 | { 17 | "ignoreUrls": false, 18 | "ignoreComments": true, 19 | "ignoreStrings": false 20 | } 21 | ] 22 | }, 23 | "parserOptions": { 24 | "parser": "babel-eslint", 25 | "ecmaVersion": 7, 26 | "ecmaFeatures": { 27 | "spread": true 28 | }, 29 | "sourceType": "module" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /test/fixtures/eslint/json/04-format/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es6": true, 5 | "node": true, 6 | "jest": true 7 | }, 8 | "globals": { 9 | "foo": true, 10 | "bar": true 11 | }, 12 | "extends": "standard", 13 | "rules": { 14 | "max-len": [ 15 | "warn", 16 | 80, 17 | 2, 18 | { 19 | "ignoreUrls": true, 20 | "ignoreComments": false, 21 | "ignoreStrings": true, 22 | "ignoreTemplateLiterals": false 23 | } 24 | ] 25 | }, 26 | "parserOptions": { 27 | "parser": "babel-eslint", 28 | "ecmaVersion": 8, 29 | "ecmaFeatures": { 30 | "spread": true 31 | }, 32 | "sourceType": "module" 33 | } 34 | } -------------------------------------------------------------------------------- /test/fixtures/eslint/json/04-format/result.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es6": true, 5 | "node": true, 6 | "jest": true 7 | }, 8 | "globals": { 9 | "foo": true, 10 | "bar": true 11 | }, 12 | "extends": "airbnb", 13 | "rules": { 14 | "max-len": [ 15 | "warn", 16 | 120, 17 | 4, 18 | { 19 | "ignoreUrls": false, 20 | "ignoreComments": true, 21 | "ignoreStrings": false 22 | } 23 | ], 24 | "space-before-function-paren": 1, 25 | "no-console": 0 26 | }, 27 | "parserOptions": { 28 | "parser": "babel-eslint", 29 | "ecmaVersion": 7, 30 | "ecmaFeatures": { 31 | "spread": true 32 | }, 33 | "sourceType": "module" 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /test/fixtures/eslint/json/04-format/upcoming.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es6": true, 5 | "node": true, 6 | "jest": true 7 | }, 8 | "extends": "airbnb", 9 | "rules": { 10 | "space-before-function-paren": 1, 11 | "no-console": 0, 12 | "max-len": [ 13 | "warn", 14 | 120, 15 | 4, 16 | { 17 | "ignoreUrls": false, 18 | "ignoreComments": true, 19 | "ignoreStrings": false 20 | } 21 | ] 22 | }, 23 | "parserOptions": { 24 | "parser": "babel-eslint", 25 | "ecmaVersion": 7, 26 | "ecmaFeatures": { 27 | "spread": true 28 | }, 29 | "sourceType": "module" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /test/fixtures/eslint/yaml/01-base/current.yaml: -------------------------------------------------------------------------------- 1 | env: 2 | browser: true 3 | es6: true 4 | node: true 5 | jest: true 6 | globals: 7 | foo: true 8 | bar: true 9 | extends: standard 10 | rules: 11 | max-len: 12 | - warn 13 | - 80 14 | - 2 15 | - ignoreUrls: true 16 | ignoreComments: false 17 | ignoreStrings: true 18 | ignoreTemplateLiterals: false 19 | parserOptions: 20 | parser: babel-eslint 21 | ecmaVersion: 8 22 | ecmaFeatures: 23 | spread: true 24 | sourceType: module 25 | 26 | -------------------------------------------------------------------------------- /test/fixtures/eslint/yaml/01-base/result.yaml: -------------------------------------------------------------------------------- 1 | env: 2 | browser: true 3 | es6: true 4 | node: true 5 | jest: true 6 | globals: 7 | foo: true 8 | bar: true 9 | extends: airbnb 10 | rules: 11 | max-len: 12 | - warn 13 | - 120 14 | - 4 15 | - ignoreUrls: false 16 | ignoreStrings: false 17 | ignoreComments: true 18 | space-before-function-paren: 1 19 | no-console: 0 20 | parserOptions: 21 | parser: babel-eslint 22 | ecmaVersion: 7 23 | ecmaFeatures: 24 | spread: true 25 | sourceType: module 26 | 27 | -------------------------------------------------------------------------------- /test/fixtures/eslint/yaml/01-base/upcoming.yaml: -------------------------------------------------------------------------------- 1 | env: 2 | browser: true 3 | es6: true 4 | node: true 5 | jest: true 6 | extends: airbnb 7 | rules: 8 | space-before-function-paren: 1 9 | no-console: 0 10 | max-len: 11 | - warn 12 | - 120 13 | - 4 14 | - ignoreUrls: false 15 | ignoreStrings: false 16 | ignoreComments: true 17 | parserOptions: 18 | parser: babel-eslint 19 | ecmaVersion: 7 20 | ecmaFeatures: 21 | spread: true 22 | sourceType: module 23 | 24 | -------------------------------------------------------------------------------- /test/fixtures/eslintignore/json/01-array-like/current.json: -------------------------------------------------------------------------------- 1 | ["foo", "bar"] 2 | -------------------------------------------------------------------------------- /test/fixtures/eslintignore/json/01-array-like/result.json: -------------------------------------------------------------------------------- 1 | ["foo", "bar", "baz"] 2 | -------------------------------------------------------------------------------- /test/fixtures/eslintignore/json/01-array-like/upcoming.json: -------------------------------------------------------------------------------- 1 | ["bar", "baz"] 2 | -------------------------------------------------------------------------------- /test/fixtures/eslintignore/lines/00-base/current.txt: -------------------------------------------------------------------------------- 1 | node_modules 2 | 3 | -------------------------------------------------------------------------------- /test/fixtures/eslintignore/lines/00-base/result.txt: -------------------------------------------------------------------------------- 1 | node_modules 2 | foo 3 | bar 4 | baz 5 | 6 | -------------------------------------------------------------------------------- /test/fixtures/eslintignore/lines/00-base/upcoming.txt: -------------------------------------------------------------------------------- 1 | foo 2 | bar 3 | baz 4 | 5 | -------------------------------------------------------------------------------- /test/fixtures/eslintignore/lines/01-base/current.txt: -------------------------------------------------------------------------------- 1 | node_modules 2 | 3 | -------------------------------------------------------------------------------- /test/fixtures/eslintignore/lines/01-base/result.txt: -------------------------------------------------------------------------------- 1 | node_modules 2 | foo 3 | bar 4 | baz 5 | 6 | -------------------------------------------------------------------------------- /test/fixtures/eslintignore/lines/01-base/upcoming.txt: -------------------------------------------------------------------------------- 1 | foo 2 | bar 3 | baz 4 | 5 | -------------------------------------------------------------------------------- /test/fixtures/gitignore/lines/00-base/current.txt: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /test/fixtures/gitignore/lines/00-base/result.txt: -------------------------------------------------------------------------------- 1 | node_modules 2 | foo 3 | bar 4 | baz 5 | -------------------------------------------------------------------------------- /test/fixtures/gitignore/lines/00-base/upcoming.txt: -------------------------------------------------------------------------------- 1 | foo 2 | bar 3 | baz 4 | -------------------------------------------------------------------------------- /test/fixtures/gitignore/lines/01-base/current.txt: -------------------------------------------------------------------------------- 1 | node_modules 2 | 3 | -------------------------------------------------------------------------------- /test/fixtures/gitignore/lines/01-base/result.txt: -------------------------------------------------------------------------------- 1 | node_modules 2 | foo 3 | bar 4 | baz 5 | 6 | -------------------------------------------------------------------------------- /test/fixtures/gitignore/lines/01-base/upcoming.txt: -------------------------------------------------------------------------------- 1 | foo 2 | bar 3 | baz 4 | 5 | -------------------------------------------------------------------------------- /test/fixtures/gitignore/lines/02-update/cached.txt: -------------------------------------------------------------------------------- 1 | node_modules 2 | 3 | -------------------------------------------------------------------------------- /test/fixtures/gitignore/lines/02-update/current.txt: -------------------------------------------------------------------------------- 1 | node_modules 2 | yarn-error.log 3 | 4 | -------------------------------------------------------------------------------- /test/fixtures/gitignore/lines/02-update/result.txt: -------------------------------------------------------------------------------- 1 | node_modules 2 | yarn-error.log 3 | bower_components 4 | 5 | -------------------------------------------------------------------------------- /test/fixtures/gitignore/lines/02-update/upcoming.txt: -------------------------------------------------------------------------------- 1 | node_modules 2 | bower_components 3 | 4 | -------------------------------------------------------------------------------- /test/fixtures/husky/json/00-base/cached.json: -------------------------------------------------------------------------------- 1 | { 2 | "hooks": { 3 | "pre-commit": "lint-staged", 4 | "post-commit": "echo 'beep'" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/fixtures/husky/json/00-base/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "hooks": { 3 | "pre-commit": "lint-staged", 4 | "post-commit": "echo 'yay'" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/fixtures/husky/json/00-base/result.json: -------------------------------------------------------------------------------- 1 | { 2 | "hooks": { 3 | "pre-commit": "different-linter", 4 | "post-commit": "echo 'yay'" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/fixtures/husky/json/00-base/upcoming.json: -------------------------------------------------------------------------------- 1 | { 2 | "hooks": { 3 | "pre-commit": "different-linter", 4 | "post-commit": "echo 'boom!'" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/fixtures/jest/json/00-base/cached.json: -------------------------------------------------------------------------------- 1 | { 2 | "testEnvironment": "es6", 3 | "clearMocks": false, 4 | "cacheDirectory": "./.cache", 5 | "extraGlobals": ["foo", "bar"], 6 | "coverageThreshold": { 7 | "global": { 8 | "statements": 200 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/fixtures/jest/json/00-base/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "testEnvironment": "node", 3 | "clearMocks": true, 4 | "cacheDirectory": "./.cache", 5 | "extraGlobals": ["foo", "bar"], 6 | "coverageThreshold": { 7 | "global": { 8 | "statements": 100 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/fixtures/jest/json/00-base/result.json: -------------------------------------------------------------------------------- 1 | { 2 | "testEnvironment": "node", 3 | "clearMocks": true, 4 | "cacheDirectory": "./.cache", 5 | "extraGlobals": ["foo", "bar", "baz"], 6 | "coverageThreshold": { 7 | "global": { 8 | "statements": 100 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/fixtures/jest/json/00-base/upcoming.json: -------------------------------------------------------------------------------- 1 | { 2 | "testEnvironment": "es2015", 3 | "clearMocks": false, 4 | "cacheDirectory": "./.cache", 5 | "extraGlobals": ["foo", "bar", "baz"], 6 | "coverageThreshold": { 7 | "global": { 8 | "statements": 250 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/fixtures/lines/lines/00-merge/cached.txt: -------------------------------------------------------------------------------- 1 | cached foo 2 | 3 | -------------------------------------------------------------------------------- /test/fixtures/lines/lines/00-merge/current.txt: -------------------------------------------------------------------------------- 1 | foo 2 | bar 3 | baz 4 | 5 | -------------------------------------------------------------------------------- /test/fixtures/lines/lines/00-merge/result.txt: -------------------------------------------------------------------------------- 1 | foo 2 | new bar 3 | baz 4 | 5 | -------------------------------------------------------------------------------- /test/fixtures/lines/lines/00-merge/upcoming.txt: -------------------------------------------------------------------------------- 1 | new foo 2 | new bar 3 | 4 | -------------------------------------------------------------------------------- /test/fixtures/lines/lines/01-concat/current.txt: -------------------------------------------------------------------------------- 1 | foo 2 | bar 3 | baz 4 | -------------------------------------------------------------------------------- /test/fixtures/lines/lines/01-concat/result.txt: -------------------------------------------------------------------------------- 1 | foo 2 | bar 3 | baz 4 | new foo 5 | new bar 6 | -------------------------------------------------------------------------------- /test/fixtures/lines/lines/01-concat/upcoming.txt: -------------------------------------------------------------------------------- 1 | new foo 2 | new bar 3 | -------------------------------------------------------------------------------- /test/fixtures/lintStaged/json/00-base/cached.json: -------------------------------------------------------------------------------- 1 | { 2 | "src/**/*.{js,jsx,json}": ["eslint", "prettier --write", "git add"], 3 | "src/**/*.css": ["stylelint --fix", "git add"] 4 | } 5 | -------------------------------------------------------------------------------- /test/fixtures/lintStaged/json/00-base/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "src/**/*.{js,jsx,json}": ["eslint --fix", "prettier --write", "git add"], 3 | "src/**/*.css": ["stylelint --fix", "git add"] 4 | } 5 | -------------------------------------------------------------------------------- /test/fixtures/lintStaged/json/00-base/result.json: -------------------------------------------------------------------------------- 1 | { 2 | "src/**/*.{js,jsx,json}": [ 3 | "eslint --fix", 4 | "prettier --write", 5 | "git add" 6 | ], 7 | "src/**/*.css": [ 8 | "stylelint --fix", 9 | "prettier --write", 10 | "git add" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /test/fixtures/lintStaged/json/00-base/upcoming.json: -------------------------------------------------------------------------------- 1 | { 2 | "src/**/*.{js,jsx,json}": ["eslint", "prettier --write", "git add"], 3 | "src/**/*.css": ["stylelint --fix", "prettier --write", "git add"] 4 | } 5 | -------------------------------------------------------------------------------- /test/fixtures/list/json/00-concat-primitives/current.json: -------------------------------------------------------------------------------- 1 | ["foo", "bar", "baz"] 2 | -------------------------------------------------------------------------------- /test/fixtures/list/json/00-concat-primitives/result.json: -------------------------------------------------------------------------------- 1 | ["foo", "bar", "baz", "new foo", "new baz", "new beep"] 2 | -------------------------------------------------------------------------------- /test/fixtures/list/json/00-concat-primitives/upcoming.json: -------------------------------------------------------------------------------- 1 | ["new foo", "bar", "new baz", "new beep"] 2 | -------------------------------------------------------------------------------- /test/fixtures/list/json/01-merge-primitives/current.json: -------------------------------------------------------------------------------- 1 | ["foo", "bar", "baz"] 2 | -------------------------------------------------------------------------------- /test/fixtures/list/json/01-merge-primitives/result.json: -------------------------------------------------------------------------------- 1 | ["new foo", "bar", "new baz"] 2 | -------------------------------------------------------------------------------- /test/fixtures/list/json/01-merge-primitives/upcoming.json: -------------------------------------------------------------------------------- 1 | ["new foo", "bar", "new baz"] 2 | -------------------------------------------------------------------------------- /test/fixtures/list/json/02-merge-hashes/current.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "foo": "1", 4 | "bar": "2" 5 | }, 6 | { 7 | "bar": "2", 8 | "baz": "3" 9 | }, 10 | { 11 | "baz": "3", 12 | "foo": "4" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /test/fixtures/list/json/02-merge-hashes/result.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "foo": "3", 4 | "bar": "2", 5 | "baz": "1" 6 | }, 7 | { 8 | "bar": "2", 9 | "baz": "1" 10 | }, 11 | { 12 | "baz": "2", 13 | "foo": "1" 14 | } 15 | ] 16 | -------------------------------------------------------------------------------- /test/fixtures/list/json/02-merge-hashes/upcoming.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "foo": "3", 4 | "bar": "2", 5 | "baz": "1" 6 | }, 7 | { 8 | "bar": "2", 9 | "baz": "1" 10 | }, 11 | { 12 | "baz": "2", 13 | "foo": "1" 14 | } 15 | ] 16 | -------------------------------------------------------------------------------- /test/fixtures/list/json/03-concat-hashes/current.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "foo": "bar" 4 | }, 5 | { 6 | "bar": "baz" 7 | }, 8 | { 9 | "baz": "foo" 10 | } 11 | ] 12 | -------------------------------------------------------------------------------- /test/fixtures/list/json/03-concat-hashes/result.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "foo": "bar" 4 | }, 5 | { 6 | "bar": "baz" 7 | }, 8 | { 9 | "baz": "foo" 10 | }, 11 | { 12 | "foo": "new bar" 13 | }, 14 | { 15 | "baz": "new foo" 16 | } 17 | ] 18 | -------------------------------------------------------------------------------- /test/fixtures/list/json/03-concat-hashes/upcoming.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "foo": "new bar" 4 | }, 5 | { 6 | "bar": "baz" 7 | }, 8 | { 9 | "baz": "new foo" 10 | } 11 | ] 12 | -------------------------------------------------------------------------------- /test/fixtures/npmignore/lines/00-base/current.txt: -------------------------------------------------------------------------------- 1 | node_modules 2 | 3 | -------------------------------------------------------------------------------- /test/fixtures/npmignore/lines/00-base/result.txt: -------------------------------------------------------------------------------- 1 | node_modules 2 | foo 3 | bar 4 | baz 5 | -------------------------------------------------------------------------------- /test/fixtures/npmignore/lines/00-base/upcoming.txt: -------------------------------------------------------------------------------- 1 | foo 2 | bar 3 | baz 4 | 5 | -------------------------------------------------------------------------------- /test/fixtures/npmignore/lines/01-base/current.txt: -------------------------------------------------------------------------------- 1 | node_modules 2 | 3 | -------------------------------------------------------------------------------- /test/fixtures/npmignore/lines/01-base/result.txt: -------------------------------------------------------------------------------- 1 | node_modules 2 | foo 3 | bar 4 | baz 5 | 6 | -------------------------------------------------------------------------------- /test/fixtures/npmignore/lines/01-base/upcoming.txt: -------------------------------------------------------------------------------- 1 | foo 2 | bar 3 | baz 4 | 5 | -------------------------------------------------------------------------------- /test/fixtures/npmignore/lines/02-update/current.txt: -------------------------------------------------------------------------------- 1 | node_modules 2 | 3 | -------------------------------------------------------------------------------- /test/fixtures/npmignore/lines/02-update/result.txt: -------------------------------------------------------------------------------- 1 | node_modules 2 | foo 3 | bar 4 | baz 5 | 6 | -------------------------------------------------------------------------------- /test/fixtures/npmignore/lines/02-update/upcoming.txt: -------------------------------------------------------------------------------- 1 | foo 2 | bar 3 | baz 4 | 5 | -------------------------------------------------------------------------------- /test/fixtures/package/json/01-install/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-awesome-package", 3 | "scripts": { 4 | "start": "rimraf && start-script" 5 | }, 6 | "dependencies": { 7 | "react": "16.0.0" 8 | }, 9 | "sharec": { 10 | "configs": ["awesome-config"] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/fixtures/package/json/04-overwrite/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "awesome-package", 3 | "description": "This is a just awesome project", 4 | "version": "1.0.0", 5 | "scripts": { 6 | "api": "documentation build *.js -f md -o api.md" 7 | }, 8 | "devDependencies": { 9 | "@logux/eslint-config": "^29.1.1", 10 | "clean-publish": "^1.1.2", 11 | "documentation": "^12.0.3", 12 | "eslint": "^6.1.0", 13 | "eslint-ci": "^1.0.0", 14 | "husky": "^3.0.1", 15 | "jest": "^24.8.0", 16 | "lint-staged": "^9.2.0", 17 | "rimraf": "^2.6.3", 18 | "size-limit": "^1.3.7", 19 | "yaspeller-ci": "^1.0.1" 20 | }, 21 | "husky": { 22 | "hooks": { 23 | "pre-commit": "lint-staged" 24 | } 25 | }, 26 | "lint-staged": { 27 | "*.md": "yaspeller", 28 | "*.js": "eslint" 29 | }, 30 | "jest": { 31 | "testEnvironment": "node", 32 | "coverageThreshold": { 33 | "global": { 34 | "statements": 100 35 | } 36 | } 37 | }, 38 | "eslintConfig": { 39 | "extends": "@logux/eslint-config/browser" 40 | }, 41 | "eslintIgnore": ["node_modules"], 42 | "yaspeller": { 43 | "lang": "en", 44 | "ignoreCapitalization": true, 45 | "ignoreText": [" \\(by [^)]+\\)."] 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /test/fixtures/package/json/05-removed/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "api": "documentation build *.js -f md -o api.md" 4 | }, 5 | "devDependencies": { 6 | "@logux/eslint-config": "^29.1.1", 7 | "clean-publish": "^1.1.2", 8 | "documentation": "^12.0.3", 9 | "husky": "^3.0.1", 10 | "lint-staged": "^9.2.0", 11 | "rimraf": "^2.6.3", 12 | "size-limit": "^1.3.7", 13 | "yaspeller-ci": "^1.0.1", 14 | "awesome-config": "2.0.0" 15 | }, 16 | "husky": { 17 | "hooks": { 18 | "pre-commit": "lint-staged" 19 | } 20 | }, 21 | "lint-staged": { 22 | "*.md": "yaspeller" 23 | }, 24 | "yaspeller": { 25 | "lang": "en", 26 | "ignoreCapitalization": true, 27 | "ignoreText": [" \\(by [^)]+\\)."] 28 | }, 29 | "sharec": { 30 | "configs": ["awesome-config"], 31 | "locked": { 32 | "awesome-config": "1.0.0" 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /test/fixtures/package/json/05-removed/result.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "api": "documentation build *.js -f md -o api.md", 4 | "clean": "rimraf api.md coverage/", 5 | "test": "jest --coverage && eslint-ci . && size-limit && yarn spell" 6 | }, 7 | "devDependencies": { 8 | "@logux/eslint-config": "^29.1.1", 9 | "clean-publish": "^1.1.2", 10 | "documentation": "^12.0.3", 11 | "husky": "^3.0.1", 12 | "lint-staged": "^9.2.0", 13 | "rimraf": "^2.6.3", 14 | "size-limit": "^1.3.7", 15 | "yaspeller-ci": "^1.0.1", 16 | "awesome-config": "2.0.0" 17 | }, 18 | "husky": { 19 | "hooks": { 20 | "pre-commit": "lint-staged" 21 | } 22 | }, 23 | "lint-staged": { 24 | "*.md": "yaspeller" 25 | }, 26 | "yaspeller": { 27 | "lang": "en", 28 | "ignoreCapitalization": true, 29 | "ignoreText": [ 30 | " \\(by [^)]+\\)." 31 | ] 32 | }, 33 | "sharec": { 34 | "configs": [ 35 | "awesome-config" 36 | ], 37 | "locked": { 38 | "awesome-config": "2.0.0" 39 | } 40 | } 41 | } 42 | 43 | -------------------------------------------------------------------------------- /test/fixtures/package/json/06-format/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-awesome-package", 3 | "scripts": { 4 | "start": "start-script" 5 | }, 6 | "dependencies": { 7 | "react": "16.0.0" 8 | } 9 | } -------------------------------------------------------------------------------- /test/fixtures/package/json/07-sharec-config/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "sharec": { 3 | "configs": { 4 | ".eslintrc": { 5 | "overwrite": true 6 | }, 7 | "foo.yaml": { 8 | "ignore": true 9 | } 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/fixtures/package/json/08-install-missing-name/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "rimraf && start-script" 4 | }, 5 | "dependencies": { 6 | "react": "16.0.0", 7 | "awesome-config": "1.0.0" 8 | }, 9 | "sharec": { 10 | "configs": [ 11 | "awesome-config" 12 | ] 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/fixtures/package/json/09-install-mishandled/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-awesome-package", 3 | "scripts": { 4 | "start": "rimraf && start-script" 5 | }, 6 | "dependencies": { 7 | "react": "16.0.0", 8 | "awesome-config": "1.0.0" 9 | }, 10 | "sharec": { 11 | "configs": ["awesome-config"] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/fixtures/pair/json/00-base/cached.json: -------------------------------------------------------------------------------- 1 | [ 2 | "foo", 3 | { 4 | "foo": "cached foo" 5 | } 6 | ] 7 | -------------------------------------------------------------------------------- /test/fixtures/pair/json/00-base/current.json: -------------------------------------------------------------------------------- 1 | [ 2 | "foo", 3 | { 4 | "foo": "foo", 5 | "bar": "bar", 6 | "baz": "baz" 7 | } 8 | ] 9 | -------------------------------------------------------------------------------- /test/fixtures/pair/json/00-base/result.json: -------------------------------------------------------------------------------- 1 | [ 2 | "foo", 3 | { 4 | "foo": "foo", 5 | "bar": "bar", 6 | "baz": "baz" 7 | } 8 | ] 9 | -------------------------------------------------------------------------------- /test/fixtures/pair/json/00-base/upcoming.json: -------------------------------------------------------------------------------- 1 | [ 2 | "foo", 3 | { 4 | "foo": "new foo", 5 | "bar": "new bar" 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /test/fixtures/pair/json/01-different-keys/current.json: -------------------------------------------------------------------------------- 1 | [ 2 | "foo", 3 | { 4 | "foo": "foo", 5 | "bar": "bar", 6 | "baz": "baz" 7 | } 8 | ] 9 | -------------------------------------------------------------------------------- /test/fixtures/pair/json/01-different-keys/result.json: -------------------------------------------------------------------------------- 1 | [ 2 | "bar", 3 | { 4 | "foo": "new foo", 5 | "bar": "new bar" 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /test/fixtures/pair/json/01-different-keys/upcoming.json: -------------------------------------------------------------------------------- 1 | [ 2 | "bar", 3 | { 4 | "foo": "new foo", 5 | "bar": "new bar" 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /test/fixtures/postcss/json/00-base/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": { 3 | "postcss-partial-import": {}, 4 | "postcss-custom-properties": { 5 | "preserve": false 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/fixtures/postcss/json/00-base/result.json: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": { 3 | "postcss-partial-import": {}, 4 | "postcss-custom-properties": { 5 | "preserve": true 6 | }, 7 | "postcss-nested": {}, 8 | "autoprefixer": {} 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/fixtures/postcss/json/00-base/upcoming.json: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": { 3 | "postcss-custom-properties": { 4 | "preserve": true 5 | }, 6 | "postcss-nested": {}, 7 | "autoprefixer": {} 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/fixtures/prettier/json/00-base/cached.json: -------------------------------------------------------------------------------- 1 | { 2 | "tab": false, 3 | "tabWidth": 4 4 | } 5 | -------------------------------------------------------------------------------- /test/fixtures/prettier/json/00-base/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "tab": false, 3 | "tabWidth": 2 4 | } 5 | -------------------------------------------------------------------------------- /test/fixtures/prettier/json/00-base/result.json: -------------------------------------------------------------------------------- 1 | { 2 | "tab": true, 3 | "tabWidth": 2, 4 | "semi": true 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/prettier/json/00-base/upcoming.json: -------------------------------------------------------------------------------- 1 | { 2 | "tab": true, 3 | "tabWidth": 4, 4 | "semi": true 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/prettier/json/01-tabs/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "tab": true 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/prettier/yaml/00-base/cached.yml: -------------------------------------------------------------------------------- 1 | tab: false 2 | tabWidth: 4 3 | -------------------------------------------------------------------------------- /test/fixtures/prettier/yaml/00-base/current.yml: -------------------------------------------------------------------------------- 1 | tab: false 2 | tabWidth: 2 3 | -------------------------------------------------------------------------------- /test/fixtures/prettier/yaml/00-base/result.yml: -------------------------------------------------------------------------------- 1 | tab: true 2 | tabWidth: 2 3 | semi: true 4 | 5 | -------------------------------------------------------------------------------- /test/fixtures/prettier/yaml/00-base/upcoming.yml: -------------------------------------------------------------------------------- 1 | tab: true 2 | tabWidth: 4 3 | semi: true 4 | -------------------------------------------------------------------------------- /test/fixtures/rule/json/00-eslint/cached.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": "cached bar" 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/rule/json/00-eslint/current.json: -------------------------------------------------------------------------------- 1 | [ 2 | "warn", 3 | 80, 4 | { 5 | "ignoreUrls": true, 6 | "ignoreComments": false, 7 | "ignoreStrings": true, 8 | "ignoreTemplateLiterals": false 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /test/fixtures/rule/json/00-eslint/result.json: -------------------------------------------------------------------------------- 1 | [ 2 | "warn", 3 | 120, 4 | { 5 | "ignoreUrls": true, 6 | "ignoreComments": true 7 | } 8 | ] 9 | -------------------------------------------------------------------------------- /test/fixtures/rule/json/00-eslint/upcoming.json: -------------------------------------------------------------------------------- 1 | [ 2 | "warn", 3 | 120, 4 | { 5 | "ignoreUrls": true, 6 | "ignoreComments": true 7 | } 8 | ] 9 | -------------------------------------------------------------------------------- /test/fixtures/rule/json/01-hash/cached.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": "cached foo" 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/rule/json/01-hash/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": "foo", 3 | "bar": "bar", 4 | "baz": "baz" 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/rule/json/01-hash/result.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": "foo", 3 | "bar": "new bar", 4 | "baz": "baz" 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/rule/json/01-hash/upcoming.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": "new foo", 3 | "bar": "new bar", 4 | "baz": "baz" 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/sharec/json/00-base/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "configs": { 3 | ".eslintrc": { 4 | "overwrite": true 5 | }, 6 | "foo.yaml": { 7 | "ignore": true 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/fixtures/stylelint/json/00-base/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["stylelint-config-standard", "stylelint-config-recess-order"], 3 | "rules": { 4 | "declaration-block-trailing-semicolon": null, 5 | "block-closing-brace-newline-before": null, 6 | "block-opening-brace-space-before": null, 7 | "at-rule-no-unknown": [ 8 | true, 9 | { 10 | "ignoreAtRules": ["define-mixin", "mixin"] 11 | } 12 | ], 13 | "color-named": "never" 14 | }, 15 | "processors": ["stylelint-my-processor", ["some-other-processor", { "optionOne": true, "optionTwo": false }]] 16 | } 17 | -------------------------------------------------------------------------------- /test/fixtures/stylelint/json/00-base/result.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "stylelint-config-standard", 4 | "stylelint-config-recess-order" 5 | ], 6 | "rules": { 7 | "declaration-block-trailing-semicolon": null, 8 | "block-closing-brace-newline-before": null, 9 | "block-opening-brace-space-before": null, 10 | "at-rule-no-unknown": [ 11 | false, 12 | { 13 | "ignoreAtRules": [ 14 | "define-mixin", 15 | "mixin" 16 | ] 17 | } 18 | ], 19 | "color-named": "never" 20 | }, 21 | "processors": [ 22 | [ 23 | "stylelint-my-processor", 24 | { 25 | "optionOne": false 26 | } 27 | ], 28 | [ 29 | "some-other-processor", 30 | { 31 | "optionOne": false, 32 | "optionTwo": true 33 | } 34 | ], 35 | "another-processor" 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /test/fixtures/stylelint/json/00-base/upcoming.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["stylelint-config-standard", "stylelint-config-recess-order"], 3 | "rules": { 4 | "at-rule-no-unknown": [ 5 | false, 6 | { 7 | "ignoreAtRules": ["define-mixin", "mixin"] 8 | } 9 | ], 10 | "color-named": "never" 11 | }, 12 | "processors": [ 13 | ["stylelint-my-processor", { "optionOne": false }], 14 | ["some-other-processor", { "optionOne": false, "optionTwo": true }], 15 | "another-processor" 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /test/fixtures/travis/yaml/00-base/cached.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | cache: yarn 3 | node_js: 4 | - node 5 | - '8' 6 | 7 | -------------------------------------------------------------------------------- /test/fixtures/travis/yaml/00-base/current.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | cache: yarn 3 | node_js: 4 | - node 5 | - '10' 6 | - '8' 7 | 8 | -------------------------------------------------------------------------------- /test/fixtures/travis/yaml/00-base/result.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - node 4 | - '12' 5 | - '10' 6 | - '8' 7 | 8 | -------------------------------------------------------------------------------- /test/fixtures/travis/yaml/00-base/upcoming.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - node 4 | - '12' 5 | - '10' 6 | - '8' 7 | 8 | -------------------------------------------------------------------------------- /test/fixtures/yaspeller/json/00-base/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "lang": "ru", 3 | "ignoreCapitalization": true, 4 | "excludeFiles": ["README-*.md"], 5 | "ignoreText": [" \\(by [^)]+\\)."], 6 | "ignoreTags": ["foo"], 7 | "dictionary": [ 8 | "cryptographically", 9 | "formatAsync", 10 | "generateAsync", 11 | "gzip", 12 | "gzipped", 13 | "Haskell", 14 | "js", 15 | "JSDoc", 16 | "nanoid", 17 | "Nim", 18 | "nonSecure", 19 | "npm", 20 | "UUID", 21 | "v4", 22 | "Versioning", 23 | "JS", 24 | "PouchDB", 25 | "CouchDB" 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /test/fixtures/yaspeller/json/00-base/result.json: -------------------------------------------------------------------------------- 1 | { 2 | "lang": "en", 3 | "ignoreCapitalization": false, 4 | "excludeFiles": [ 5 | "README-*.md", 6 | "CHANGELOG.md" 7 | ], 8 | "ignoreText": [ 9 | " \\(by [^)]+\\)." 10 | ], 11 | "ignoreTags": [ 12 | "foo" 13 | ], 14 | "dictionary": [ 15 | "cryptographically", 16 | "formatAsync", 17 | "generateAsync", 18 | "gzip", 19 | "gzipped", 20 | "Haskell", 21 | "js", 22 | "JSDoc", 23 | "nanoid", 24 | "Nim", 25 | "nonSecure", 26 | "npm", 27 | "UUID", 28 | "v4", 29 | "Versioning", 30 | "JS", 31 | "PouchDB", 32 | "CouchDB", 33 | "Async", 34 | "asyncGenerator", 35 | "CLI", 36 | "Clojure", 37 | "ClojureScript", 38 | "Crypto" 39 | ], 40 | "fileExtensions": [ 41 | "bar" 42 | ] 43 | } 44 | -------------------------------------------------------------------------------- /test/fixtures/yaspeller/json/00-base/upcoming.json: -------------------------------------------------------------------------------- 1 | { 2 | "lang": "en", 3 | "ignoreCapitalization": false, 4 | "fileExtensions": [ 5 | "bar" 6 | ], 7 | "excludeFiles": [ 8 | "README-*.md", 9 | "CHANGELOG.md" 10 | ], 11 | "ignoreText": [ 12 | " \\(by [^)]+\\)." 13 | ], 14 | "dictionary": [ 15 | "Async", 16 | "asyncGenerator", 17 | "CLI", 18 | "Clojure", 19 | "ClojureScript", 20 | "Crypto", 21 | "cryptographically", 22 | "formatAsync", 23 | "generateAsync" 24 | ] 25 | } 26 | 27 | -------------------------------------------------------------------------------- /test/fixtures/yaspeller/json/01-update/cached.json: -------------------------------------------------------------------------------- 1 | { 2 | "lang": "en", 3 | "ignoreCapitalization": false, 4 | "fileExtensions": ["bar"], 5 | "excludeFiles": ["README-*.md", "CHANGELOG.md"], 6 | "ignoreText": [" \\(by [^)]+\\)."], 7 | "dictionary": [ 8 | "Async", 9 | "asyncGenerator", 10 | "CLI", 11 | "Clojure", 12 | "ClojureScript", 13 | "Crypto", 14 | "cryptographically", 15 | "formatAsync", 16 | "generateAsync" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /test/fixtures/yaspeller/json/01-update/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "lang": "ru", 3 | "ignoreCapitalization": false, 4 | "fileExtensions": ["foo", "bar"], 5 | "excludeFiles": ["README-*.md", "CHANGELOG.md"], 6 | "ignoreText": [" \\(by [^)]+\\)."], 7 | "dictionary": [ 8 | "Async", 9 | "asyncGenerator", 10 | "CLI", 11 | "Clojure", 12 | "ClojureScript", 13 | "Crypto", 14 | "cryptographically", 15 | "formatAsync", 16 | "generateAsync" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /test/fixtures/yaspeller/json/01-update/result.json: -------------------------------------------------------------------------------- 1 | { 2 | "lang": "ru", 3 | "ignoreCapitalization": false, 4 | "fileExtensions": [ 5 | "foo", 6 | "bar", 7 | "baz" 8 | ], 9 | "excludeFiles": [ 10 | "README-*.md", 11 | "CHANGELOG.md" 12 | ], 13 | "ignoreText": [ 14 | " \\(by [^)]+\\)." 15 | ], 16 | "dictionary": [ 17 | "Async", 18 | "asyncGenerator", 19 | "CLI", 20 | "Clojure", 21 | "ClojureScript", 22 | "Crypto", 23 | "cryptographically", 24 | "formatAsync", 25 | "generateAsync", 26 | "foo", 27 | "bar", 28 | "baz" 29 | ] 30 | } 31 | 32 | -------------------------------------------------------------------------------- /test/fixtures/yaspeller/json/01-update/upcoming.json: -------------------------------------------------------------------------------- 1 | { 2 | "lang": "en", 3 | "ignoreCapitalization": false, 4 | "fileExtensions": ["baz"], 5 | "excludeFiles": ["README-*.md", "CHANGELOG.md"], 6 | "ignoreText": [" \\(by [^)]+\\)."], 7 | "dictionary": [ 8 | "Async", 9 | "asyncGenerator", 10 | "CLI", 11 | "Clojure", 12 | "ClojureScript", 13 | "Crypto", 14 | "cryptographically", 15 | "formatAsync", 16 | "generateAsync", 17 | "foo", 18 | "bar", 19 | "baz" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /test/fixtures/yaspeller/json/02-disappear/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "lang": "ru", 3 | "ignoreCapitalization": true, 4 | "excludeFiles": ["README-*.md"], 5 | "ignoreText": [" \\(by [^)]+\\)."], 6 | "ignoreTags": ["foo"], 7 | "dictionary": [ 8 | "cryptographically", 9 | "formatAsync", 10 | "generateAsync", 11 | "gzip", 12 | "gzipped", 13 | "Haskell", 14 | "js", 15 | "JSDoc", 16 | "nanoid", 17 | "Nim", 18 | "nonSecure", 19 | "npm", 20 | "UUID", 21 | "v4", 22 | "Versioning", 23 | "JS", 24 | "PouchDB", 25 | "CouchDB" 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /test/fixtures/yaspeller/json/02-disappear/result.json: -------------------------------------------------------------------------------- 1 | { 2 | "lang": "en", 3 | "ignoreCapitalization": false, 4 | "excludeFiles": [ 5 | "README-*.md", 6 | "CHANGELOG.md" 7 | ], 8 | "ignoreText": [ 9 | " \\(by [^)]+\\)." 10 | ], 11 | "ignoreTags": [ 12 | "foo" 13 | ], 14 | "dictionary": [ 15 | "cryptographically", 16 | "formatAsync", 17 | "generateAsync", 18 | "gzip", 19 | "gzipped", 20 | "Haskell", 21 | "js", 22 | "JSDoc", 23 | "nanoid", 24 | "Nim", 25 | "nonSecure", 26 | "npm", 27 | "UUID", 28 | "v4", 29 | "Versioning", 30 | "JS", 31 | "PouchDB", 32 | "CouchDB", 33 | "Async", 34 | "asyncGenerator", 35 | "CLI", 36 | "Clojure", 37 | "ClojureScript", 38 | "Crypto" 39 | ], 40 | "fileExtensions": [ 41 | "bar" 42 | ] 43 | } 44 | 45 | -------------------------------------------------------------------------------- /test/fixtures/yaspeller/json/02-disappear/upcoming.json: -------------------------------------------------------------------------------- 1 | { 2 | "lang": "en", 3 | "ignoreCapitalization": false, 4 | "fileExtensions": ["bar"], 5 | "excludeFiles": ["README-*.md", "CHANGELOG.md"], 6 | "ignoreText": [" \\(by [^)]+\\)."], 7 | "dictionary": [ 8 | "Async", 9 | "asyncGenerator", 10 | "CLI", 11 | "Clojure", 12 | "ClojureScript", 13 | "Crypto", 14 | "cryptographically", 15 | "formatAsync", 16 | "generateAsync" 17 | ] 18 | } 19 | --------------------------------------------------------------------------------