Skip to content

feat: support package.yaml and package.json5 #1799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
May 1, 2019
Merged
Prev Previous commit
Next Next commit
test(pkgs-graph): fix for Windows
  • Loading branch information
zkochan committed May 1, 2019
commit 9b4044eb6707caac13f3368a712356666896e2e1
1 change: 1 addition & 0 deletions packages/pkgs-graph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"homepage": "https://github.com/zkochan/pkgs-graph#readme",
"devDependencies": {
"@types/tape": "^4.2.29",
"better-path-resolve": "1.0.0",
"pkgs-graph": "link:",
"tape": "^4.6.3",
"ts-node": "^8.0.3",
Expand Down
3 changes: 2 additions & 1 deletion packages/pkgs-graph/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import path = require('path')
import semver = require('semver')
import R = require('ramda')
import npa = require('@zkochan/npm-package-arg')
Expand Down Expand Up @@ -59,7 +60,7 @@ export default function<T> (pkgs: Array<Package & T>): {
}

if (spec.type === 'directory') {
const matchedPkg = R.values(pkgMap).find(pkg => pkg.path === spec.fetchSpec)
const matchedPkg = R.values(pkgMap).find(pkg => path.relative(pkg.path, spec.fetchSpec) === '')
if (!matchedPkg) {
return ''
}
Expand Down
63 changes: 34 additions & 29 deletions packages/pkgs-graph/test/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import test = require('tape')
import createPkgGraph from 'pkgs-graph'
import path = require('path')
import pathResolve = require('better-path-resolve')

const BAR1_PATH = pathResolve('/zkochan/src/bar')
const FOO1_PATH = pathResolve('/zkochan/src/foo')
const BAR2_PATH = pathResolve('/zkochan/src/bar@2')
const FOO2_PATH = pathResolve('/zkochan/src/foo@2')

test('create package graph', t => {
const result = createPkgGraph([
Expand All @@ -13,7 +18,7 @@ test('create package graph', t => {
foo: '^1.0.0'
}
},
path: '/zkochan/src/bar',
path: BAR1_PATH,
},
{
manifest: {
Expand All @@ -23,7 +28,7 @@ test('create package graph', t => {
bar: '^10.0.0'
}
},
path: '/zkochan/src/foo',
path: FOO1_PATH,
},
{
manifest: {
Expand All @@ -33,19 +38,19 @@ test('create package graph', t => {
foo: '^2.0.0'
}
},
path: '/zkochan/src/bar@2',
path: BAR2_PATH,
},
{
manifest: {
name: 'foo',
version: '2.0.0',
},
path: '/zkochan/src/foo@2',
path: FOO2_PATH,
},
])
t.deepEqual(result.unmatched, [{pkgName: 'bar', range: '^10.0.0'}])
t.deepEqual(result.graph, {
'/zkochan/src/bar': {
[BAR1_PATH]: {
package: {
manifest: {
name: 'bar',
Expand All @@ -55,11 +60,11 @@ test('create package graph', t => {
foo: '^1.0.0'
}
},
path: '/zkochan/src/bar',
path: BAR1_PATH,
},
dependencies: ['/zkochan/src/foo'],
dependencies: [FOO1_PATH],
},
'/zkochan/src/foo': {
[FOO1_PATH]: {
package: {
manifest: {
name: 'foo',
Expand All @@ -68,11 +73,11 @@ test('create package graph', t => {
bar: '^10.0.0'
}
},
path: '/zkochan/src/foo',
path: FOO1_PATH,
},
dependencies: [],
},
'/zkochan/src/bar@2': {
[BAR2_PATH]: {
package: {
manifest: {
name: 'bar',
Expand All @@ -81,17 +86,17 @@ test('create package graph', t => {
foo: '^2.0.0'
}
},
path: '/zkochan/src/bar@2',
path: BAR2_PATH,
},
dependencies: ['/zkochan/src/foo@2'],
dependencies: [FOO2_PATH],
},
'/zkochan/src/foo@2': {
[FOO2_PATH]: {
package: {
manifest: {
name: 'foo',
version: '2.0.0',
},
path: '/zkochan/src/foo@2',
path: FOO2_PATH,
},
dependencies: [],
},
Expand All @@ -111,7 +116,7 @@ test('create package graph for local directory dependencies', t => {
foo: '../foo'
}
},
path: '/zkochan/src/bar',
path: BAR1_PATH,
},
{
manifest: {
Expand All @@ -121,7 +126,7 @@ test('create package graph for local directory dependencies', t => {
bar: '^10.0.0'
}
},
path: '/zkochan/src/foo',
path: FOO1_PATH,
},
{
manifest: {
Expand All @@ -131,19 +136,19 @@ test('create package graph for local directory dependencies', t => {
foo: 'file:../foo@2'
}
},
path: '/zkochan/src/bar@2',
path: BAR2_PATH,
},
{
manifest: {
name: 'foo',
version: '2.0.0',
},
path: '/zkochan/src/foo@2',
path: FOO2_PATH,
},
])
t.deepEqual(result.unmatched, [{pkgName: 'bar', range: '^10.0.0'}])
t.deepEqual(result.graph, {
'/zkochan/src/bar': {
[BAR1_PATH]: {
package: {
manifest: {
name: 'bar',
Expand All @@ -154,11 +159,11 @@ test('create package graph for local directory dependencies', t => {
foo: '../foo'
}
},
path: '/zkochan/src/bar',
path: BAR1_PATH,
},
dependencies: ['/zkochan/src/foo'],
dependencies: [FOO1_PATH],
},
'/zkochan/src/foo': {
[FOO1_PATH]: {
package: {
manifest: {
name: 'foo',
Expand All @@ -167,11 +172,11 @@ test('create package graph for local directory dependencies', t => {
bar: '^10.0.0'
}
},
path: '/zkochan/src/foo',
path: FOO1_PATH,
},
dependencies: [],
},
'/zkochan/src/bar@2': {
[BAR2_PATH]: {
package: {
manifest: {
name: 'bar',
Expand All @@ -180,17 +185,17 @@ test('create package graph for local directory dependencies', t => {
foo: 'file:../foo@2'
},
},
path: '/zkochan/src/bar@2',
path: BAR2_PATH,
},
dependencies: ['/zkochan/src/foo@2'],
dependencies: [FOO2_PATH],
},
'/zkochan/src/foo@2': {
[FOO2_PATH]: {
package: {
manifest: {
name: 'foo',
version: '2.0.0',
},
path: '/zkochan/src/foo@2',
path: FOO2_PATH,
},
dependencies: [],
},
Expand Down
2 changes: 2 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy