Skip to content

[cli] project init overwrites existing package.json with cli package.json #874

@bmuenzenmeyer

Description

@bmuenzenmeyer

cli version: 0.0.1-alpha.20

Follow Established npm projects instructions exactly at https://github.com/pattern-lab/patternlab-node#installation

after install of cli

{
  "name": "new-project2",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@pattern-lab/cli": "0.0.1-alpha.20"
  }
}

add scripts

{
  "name": "new-project2",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "patternlab": "patternlab"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@pattern-lab/cli": "0.0.1-alpha.20"
  }
}

npm run patternlab init

Choose a edition-node. it doesnt matter which one

package.json after

{
  "_from": "@pattern-lab/cli",
  "_id": "@pattern-lab/cli@0.0.1-alpha.20",
  "_inBundle": false,
  "_integrity": "sha512-zzE14x3KcL4WF9aA9gHlFFbfRVfSeIyAONrE64yPkTInSs4NLGt+9T/RyhR4esuTUgrhKtUZLgDoBPca5Bqg0w==",
  "_location": "/@pattern-lab/cli",
  "_phantomChildren": {},
  "_requested": {
    "type": "tag",
    "registry": true,
    "raw": "@pattern-lab/cli",
    "name": "@pattern-lab/cli",
    "escapedName": "@pattern-lab%2fcli",
    "scope": "@pattern-lab",
    "rawSpec": "",
    "saveSpec": null,
    "fetchSpec": "latest"
  },
  "_requiredBy": [
    "#DEV:/",
    "#USER"
  ],
  "_resolved": "https://registry.npmjs.org/@pattern-lab/cli/-/cli-0.0.1-alpha.20.tgz",
  "_shasum": "49983f59cbf5f0380c5b4721add13d0324f6a094",
  "_spec": "@pattern-lab/cli",
  "_where": "D:\\src\\test\\new-project2",
  "author": {
    "name": "Raphael Okon"
  },
  "bin": {
    "patternlab": "bin/patternlab.js"
  },
  "bugs": {
    "url": "https://github.com/pattern-lab/patternlab-node/issues"
  },
  "bundleDependencies": false,
  "dependencies": {
    "@pattern-lab/core": "^3.0.0-alpha.14",
    "@pattern-lab/live-server": "^1.3.3-alpha.4",
    "@pattern-lab/starterkit-mustache-demo": "^4.0.4",
    "archiver": "2.1.1",
    "chalk": "2.4.1",
    "commander": "2.15.1",
    "execa": "0.10.0",
    "fs-extra": "6.0.1",
    "glob": "7.1.2",
    "has-yarn": "1.0.0",
    "inquirer": "5.1.0",
    "lodash": "4.17.10",
    "ora": "2.1.0",
    "path-exists": "3.0.0",
    "sanitize-filename": "1.6.1"
  },
  "deprecated": false,
  "description": "Command-line interface (CLI) for the @pattern-lab/core.",
  "devDependencies": {
    "eslint": "4.18.2",
    "eslint-config-prettier": "2.9.0",
    "eslint-plugin-prettier": "2.6.0",
    "prettier": "1.11.1",
    "proxyquire": "2.0.1",
    "tap": "11.1.1"
  },
  "engines": {
    "node": ">=6.0"
  },
  "files": [
    "bin"
  ],
  "keywords": [
    "Pattern Lab",
    "Atomic Web Design",
    "Node",
    "JavaScript"
  ],
  "license": "MIT",
  "name": "@pattern-lab/cli",
  "publishConfig": {
    "access": "public"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli"
  },
  "scripts": {
    "lint": "eslint ./{bin,test}",
    "test:separate": "tap './test/*.test.js' --reporter spec --timeout=120",
    "pl:build": "patternlab build --config ./patternlab-config.json",
    "pl:help": "patternlab --help",
    "pl:install": "patternlab install --config ./patternlab-config.json",
    "pl:serve": "patternlab serve --config ./patternlab-config.json",
    "pl:version": "patternlab --version"
  },
  "version": "0.0.1-alpha.20"
}

this likely occurs because the entire contents of the cli's package.json is being written: https://github.com/pattern-lab/patternlab-node/blob/master/packages/cli/bin/install-edition.js#L3

we need to grab the current running directory's package.json, not the CLI's (I think process.cwd() should work since that is used throughout core for similar tasks

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions