Skip to content

Commit

Permalink
Merge pull request #6 from yowainwright/init-build-node-modules
Browse files Browse the repository at this point in the history
Init build node modules
  • Loading branch information
kodiakhq[bot] committed Jan 14, 2021
2 parents 5dd5e02 + 3a0e396 commit cfe35ed
Show file tree
Hide file tree
Showing 11 changed files with 1,770 additions and 118 deletions.
7 changes: 5 additions & 2 deletions package.json
Expand Up @@ -13,6 +13,7 @@
"dependencies": {
"chalk": "^4.1.0",
"ink": "^3.0.8",
"react": "^17.0.1",
"sade": "^1.7.4"
},
"devDependencies": {
Expand All @@ -25,16 +26,18 @@
"@types/eslint": "^7.2.6",
"@types/fs-extra": "^9.0.6",
"@types/ink": "^2.0.3",
"@types/jest": "^26.0.20",
"@types/jest": "^26.0.4",
"@types/node": "^14.14.11",
"@types/react": "^17.0.0",
"@types/sade": "^1.7.2",
"commitizen": "^4.2.2",
"eslint": "^7.17.0",
"husky": "^4.3.5",
"jest": "^26.6.3",
"lerna": "^3.22.1",
"lint-staged": "^10.5.3",
"prettier": "^2.2.1",
"ts-jest": "^26.4.4",
"ts-jest": "^25.2.1",
"ts-node": "^9.1.1",
"tsconfig-paths": "^3.9.0",
"tslib": "^2.0.3",
Expand Down
14 changes: 4 additions & 10 deletions packages/install-dependencies/README.md
Expand Up @@ -26,20 +26,14 @@ install-dependencies <path>
$ install-dependencies <command> [options]
Available Commands
to installs a package.json's dependencies to a specificied path
run installs a package.json's dependencies to a specificied path
For more info, run any command with the `--help` flag
$ install-dependencies to --help
$ install-dependencies run --help
Options
--ignore ignore specific dependencies
-include, --inc include specific dependencies
-v, --version Displays current version
-h, --help Displays this message
Examples
$ install-dependencies to dist --ignore [lodash, jquery]
$ install-dependencies to dist --include .dependenciesrc
-v, --version Displays current version
-h, --help Displays this message
```

## Why
Expand Down
22 changes: 22 additions & 0 deletions packages/install-dependencies/__fixtures__/test.all.package.json
@@ -0,0 +1,22 @@
{
"name": "test-all-install-dependencies",
"dependencies": {
"ramda": "0.27.1",
"typescript": "4.1.3",
"ink": "^3.0.8"
},
"devDependencies": {
"jest": "26.6.3",
"@types/ramda": "0.27.34"
},
"installDependencies": {
"include": {
"react": "17.0.1",
"@babel/core": "7.12.10",
"typescript": "4.1.2"
},
"ignore": [
"ramda"
]
}
}
@@ -0,0 +1,17 @@
{
"name": "test-ignore-install-dependencies",
"dependencies": {
"ramda": "0.27.1",
"typescript": "4.1.3",
"ink": "^3.0.8"
},
"devDependencies": {
"jest": "26.6.3",
"@types/ramda": "0.27.34"
},
"installDependencies": {
"ignore": [
"ramda"
]
}
}
@@ -0,0 +1,19 @@
{
"name": "test-include-install-dependencies",
"dependencies": {
"ramda": "0.27.1",
"typescript": "4.1.3",
"ink": "^3.0.8"
},
"devDependencies": {
"jest": "26.6.3",
"@types/ramda": "0.27.34"
},
"installDependencies": {
"include": {
"react": "17.0.1",
"@babel/core": "7.12.10",
"typescript": "4.1.2"
}
}
}
13 changes: 13 additions & 0 deletions packages/install-dependencies/__fixtures__/test.package.json
@@ -0,0 +1,13 @@
{
"name": "test-install-dependencies",
"description": "test install-dependencies",
"dependencies": {
"ramda": "0.27.1",
"typescript": "4.1.3",
"ink": "^3.0.8"
},
"devDependencies": {
"jest": "26.6.3",
"@types/ramda": "0.27.34"
}
}
31 changes: 30 additions & 1 deletion packages/install-dependencies/package.json
Expand Up @@ -6,11 +6,25 @@
"bin": {
"install-dependencies": "./dist/index.js"
},
"dependencies": {
"chalk": "^4.1.0",
"ink": "^3.0.8",
"react": "^17.0.1",
"sade": "^1.7.4"
},
"keywords": [
"node_modules",
"build",
"environment",
"dist"
"dist",
"installing",
"package-management",
"node-apps",
"node-services",
"services",
"monorepos",
"yarn",
"yarn-workspaces"
],
"author": "yowainwright <yowainwright@gmail.com>",
"homepage": "https://github.com/yowainwright/monorepo-utilities#readme",
Expand All @@ -25,5 +39,20 @@
},
"bugs": {
"url": "https://github.com/yowainwright/monorepo-utilities/issues"
},
"jest": {
"name": "@common-utilities/compose",
"projects": [
"<rootDir>/packages/*"
],
"resetMocks": true,
"rootDir": "./",
"roots": [
"<rootDir>/src"
],
"testEnvironment": "node",
"transform": {
"^.+\\.(ts)$": "ts-jest"
}
}
}
32 changes: 30 additions & 2 deletions packages/install-dependencies/src/index.test.ts
@@ -1,3 +1,31 @@
describe('build-node-modules', () => {
it('needs tests')
import fs from 'fs'
import { exec } from 'child_process'

const pathToInstallDependencies = './packages/install-dependencies/'
const installDependencies = `ts-node ${pathToInstallDependencies}src/index.ts run`
const configFixtureDirectory = `${pathToInstallDependencies}__fixtures__/`
const standardTestPackageJson = `test.package.json`
const testDirectory = `${pathToInstallDependencies}tests/`
const standardTestDirectory = 'standard/'
/**
* @todo write more tests!
* const ignoreTestPackageJson = `test.ignore.package.json`
* const includeTestPackageJson = `test.include.package.json`
* const allTestPackageJson = `test.all.package.json`
*/

const cleanUpTestDirectory = () => exec(`rm -rf ${testDirectory}`)

describe('install-dependencies', () => {
it('installed dependencies', (done) => {
const config = `${configFixtureDirectory}${standardTestPackageJson}`
const dest = `${testDirectory}${standardTestDirectory}`
const script = `${installDependencies} ${config} ${dest}`
exec(script, () => {
const isTestFolderEmpty = fs.readdirSync(dest)
expect(isTestFolderEmpty.length).toEqual(2)
cleanUpTestDirectory()
done()
})
})
})
7 changes: 6 additions & 1 deletion packages/install-dependencies/src/index.ts
Expand Up @@ -4,7 +4,6 @@ import sade from 'sade'
import * as fs from 'fs'
import { exec } from 'child_process'
import path from 'path'
// ts-ignore
import pkg = require('../package.json')

/**
Expand All @@ -26,6 +25,12 @@ prog
.describe("installs a package.json's dependencies to a specificied path")
.example('run package.json dist')
.action((config, dest) => {
if (!config) {
console.error({
'@monorepo-utilities/install-dependencies:error:config': config,
})
process.exit(1)
}
/**
* @note construct json to be read or exit the program
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/install-dependencies/tsconfig.json
Expand Up @@ -2,7 +2,7 @@
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "."
"rootDir": "src"
},
"include": ["src"]
}

0 comments on commit cfe35ed

Please sign in to comment.