Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ms-cloudpack/package-utilities

Package Overview
Dependencies
Maintainers
2
Versions
217
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ms-cloudpack/package-utilities - npm Package Compare versions

Comparing version 2.1.2 to 2.2.0

17

CHANGELOG.json

@@ -5,3 +5,18 @@ {

{
"date": "Sat, 03 Dec 2022 08:10:22 GMT",
"date": "Thu, 08 Dec 2022 08:12:30 GMT",
"tag": "@ms-cloudpack/package-utilities_v2.2.0",
"version": "2.2.0",
"comments": {
"minor": [
{
"author": "dake.3601@gmail.com",
"package": "@ms-cloudpack/package-utilities",
"commit": "4cd4bb346236dcd0d1a18ea6eab6eafa73d80724",
"comment": "Adding method to clear transforms"
}
]
}
},
{
"date": "Sat, 03 Dec 2022 08:10:45 GMT",
"tag": "@ms-cloudpack/package-utilities_v2.1.2",

@@ -8,0 +23,0 @@ "version": "2.1.2",

# Change Log - @ms-cloudpack/package-utilities
This log was last generated on Sat, 03 Dec 2022 08:10:22 GMT and should not be manually modified.
This log was last generated on Thu, 08 Dec 2022 08:12:30 GMT and should not be manually modified.
<!-- Start content -->
## 2.2.0
Thu, 08 Dec 2022 08:12:30 GMT
### Minor changes
- Adding method to clear transforms (dake.3601@gmail.com)
## 2.1.2
Sat, 03 Dec 2022 08:10:22 GMT
Sat, 03 Dec 2022 08:10:45 GMT

@@ -11,0 +19,0 @@ ### Patches

43

lib/addExportsMapEntry.test.js

@@ -1,12 +0,21 @@

import { describe, expect, it } from '@jest/globals';
import { describe, expect, it, afterEach } from '@jest/globals';
import { addExportsMapEntry } from './addExportsMapEntry.js';
import { createTestFileStructure } from '@ms-cloudpack/test-utilities';
import path from 'path';
import fs from 'fs';
const { rm } = fs.promises;
describe('await addExportsMapEntry', () => {
let testPath;
afterEach(async () => {
if (testPath) {
await rm(testPath, { recursive: true });
testPath = undefined;
}
});
it('can ignore entries that have no physical file', async () => {
const exportsMap = {};
const packagePath = await createTestFileStructure({});
testPath = await createTestFileStructure({});
await addExportsMapEntry({
exports: exportsMap,
packagePath,
packagePath: testPath,
filePath: './lib/foo-sub1',

@@ -18,3 +27,3 @@ });

const exportsMap = {};
const packagePath = await createTestFileStructure({
testPath = await createTestFileStructure({
'lib/foo-sub1.js': '',

@@ -24,3 +33,3 @@ });

exports: exportsMap,
packagePath,
packagePath: testPath,
importPath: './lib/foo-sub1',

@@ -38,3 +47,3 @@ });

const exportsMap = {};
const packagePath = await createTestFileStructure({
testPath = await createTestFileStructure({
'lib/foo-sub1.js': '',

@@ -44,3 +53,3 @@ });

exports: exportsMap,
packagePath,
packagePath: testPath,
filePath: './lib/foo-sub1',

@@ -58,3 +67,3 @@ });

const exportsMap = {};
const packagePath = await createTestFileStructure({
testPath = await createTestFileStructure({
'lib/foo-sub1.js': '',

@@ -64,3 +73,3 @@ });

exports: exportsMap,
packagePath,
packagePath: testPath,
importPath: './foo',

@@ -79,3 +88,3 @@ filePath: './lib/foo-sub1',

const exportsMap = {};
const packagePath = await createTestFileStructure({
testPath = await createTestFileStructure({
'src/foo-sub1.tsx': '',

@@ -85,3 +94,3 @@ });

exports: exportsMap,
packagePath,
packagePath: testPath,
importPath: '.',

@@ -104,3 +113,3 @@ filePath: './lib/foo-sub1',

};
const packagePath = await createTestFileStructure({
testPath = await createTestFileStructure({
'src/foo.tsx': '',

@@ -110,3 +119,3 @@ });

exports: exportsMap,
packagePath,
packagePath: testPath,
importPath: './lib/foo',

@@ -127,3 +136,3 @@ });

const exportsMap = {};
const repoPath = await createTestFileStructure({
testPath = await createTestFileStructure({
'node_modules/debug/package.json': {

@@ -137,3 +146,3 @@ name: 'debug',

});
const packagePath = path.join(repoPath, 'node_modules/debug');
const packagePath = path.join(testPath, 'node_modules/debug');
await addExportsMapEntry({

@@ -164,3 +173,3 @@ exports: exportsMap,

const exportsMap = {};
const packagePath = await createTestFileStructure({
testPath = await createTestFileStructure({
'index.js': '',

@@ -171,3 +180,3 @@ 'typings/index.d.ts': '',

exports: exportsMap,
packagePath,
packagePath: testPath,
importPath: '.',

@@ -174,0 +183,0 @@ filePath: './index.js',

@@ -1,7 +0,16 @@

import { describe, it, expect } from '@jest/globals';
import { describe, it, expect, afterEach } from '@jest/globals';
import { createExportsMap } from './createExportsMap.js';
import { createTestFileStructure } from '@ms-cloudpack/test-utilities';
import fs from 'fs';
const { rm } = fs.promises;
describe('createExportsMap', () => {
let packagePath;
afterEach(async () => {
if (packagePath) {
await rm(packagePath, { recursive: true });
packagePath = undefined;
}
});
it('can return a blank import map for something with nothing to export', async () => {
const packagePath = await createTestFileStructure({
packagePath = await createTestFileStructure({
'package.json': {},

@@ -12,3 +21,3 @@ });

it('can generate an exports map for a package with an implicit index.js file', async () => {
const packagePath = await createTestFileStructure({
packagePath = await createTestFileStructure({
'package.json': {},

@@ -24,3 +33,3 @@ 'index.js': '',

it('can generate an exports map for a package with a main export as esm', async () => {
const packagePath = await createTestFileStructure({
packagePath = await createTestFileStructure({
'package.json': {

@@ -39,3 +48,3 @@ type: 'module',

it('can generate an exports map for a package with a main export as cjs and types', async () => {
const packagePath = await createTestFileStructure({
packagePath = await createTestFileStructure({
'package.json': { main: 'main', types: 'main.d.ts' },

@@ -55,3 +64,3 @@ 'main.js': '',

it('can generate an exports map for a package with a module export', async () => {
const packagePath = await createTestFileStructure({
packagePath = await createTestFileStructure({
'package.json': { module: 'module', types: 'module.d.ts' },

@@ -71,3 +80,3 @@ 'module.js': '',

it('can generate an exports map for a package with a main, module, and browser entry', async () => {
const packagePath = await createTestFileStructure({
packagePath = await createTestFileStructure({
'package.json': {

@@ -94,3 +103,3 @@ name: 'browser-export',

it('can expand browser mappings into additional entries', async () => {
const packagePath = await createTestFileStructure({
packagePath = await createTestFileStructure({
'package.json': {

@@ -122,3 +131,3 @@ name: 'browser-export',

it('can generate an exports map for a package with a type/source exports', async () => {
const packagePath = await createTestFileStructure({
packagePath = await createTestFileStructure({
'package.json': {

@@ -144,3 +153,3 @@ name: 'browser-export',

it('can generate an exports map for an internal unbuilt package', async () => {
const packagePath = await createTestFileStructure({
packagePath = await createTestFileStructure({
'package.json': {

@@ -164,3 +173,3 @@ name: 'browser-export',

it('can generate an exports map and ignore a browser entry does not exist', async () => {
const testPath = await createTestFileStructure({
packagePath = await createTestFileStructure({
'package.json': {

@@ -174,3 +183,3 @@ main: 'main.js',

});
expect(await createExportsMap(testPath)).toMatchInlineSnapshot(`
expect(await createExportsMap(packagePath)).toMatchInlineSnapshot(`
{

@@ -185,3 +194,3 @@ ".": {

it('can generate an exports map for an external package with implicit type exports', async () => {
const packagePath = await createTestFileStructure({
packagePath = await createTestFileStructure({
'package.json': {

@@ -204,3 +213,3 @@ main: 'lib/main.js',

it(`can find exports from browser-only packages like uuid@3.4.0`, async () => {
const packagePath = await createTestFileStructure({
packagePath = await createTestFileStructure({
'package.json': {

@@ -240,3 +249,3 @@ name: 'uuid',

it(`can build an exports map for styled components`, async () => {
const packagePath = await createTestFileStructure({
packagePath = await createTestFileStructure({
'package.json': {

@@ -270,3 +279,3 @@ name: 'styled-components',

it(`can build an exports map for a CRA TS scenario`, async () => {
const packagePath = await createTestFileStructure({
packagePath = await createTestFileStructure({
'package.json': {},

@@ -288,3 +297,3 @@ 'src/index.tsx': '',

it(`can build an exports map for a CRA JS scenario`, async () => {
const packagePath = await createTestFileStructure({
packagePath = await createTestFileStructure({
'package.json': {},

@@ -305,3 +314,3 @@ 'src/index.js': '',

it(`can find a root index file.`, async () => {
const packagePath = await createTestFileStructure({
packagePath = await createTestFileStructure({
'package.json': {},

@@ -308,0 +317,0 @@ 'index.js': '',

@@ -1,9 +0,18 @@

import { describe, it, expect } from '@jest/globals';
import { describe, it, expect, afterEach } from '@jest/globals';
import { createTestFileStructure } from '@ms-cloudpack/test-utilities';
import { createImportMap } from './createImportMap.js';
import { PackageDefinitions } from './PackageDefinitions.js';
import fs from 'fs';
const { rm } = fs.promises;
const defaultServer = 'http://localhost:8080';
describe('createImportMap', () => {
let testPath;
afterEach(async () => {
if (testPath) {
await rm(testPath, { recursive: true });
testPath = undefined;
}
});
it('can generate an import map for a package with a main', async () => {
const testPath = await createTestFileStructure({
testPath = await createTestFileStructure({
'package.json': {

@@ -93,3 +102,3 @@ name: 'foo',

it('can generate an import map for a package and append a refresh version', async () => {
const testPath = await createTestFileStructure({
testPath = await createTestFileStructure({
'package.json': {

@@ -119,3 +128,3 @@ name: 'foo',

it('can generate an import map for a package and append a refresh and task version', async () => {
const testPath = await createTestFileStructure({
testPath = await createTestFileStructure({
'package.json': {

@@ -122,0 +131,0 @@ name: 'foo',

@@ -1,27 +0,42 @@

import { describe, it, expect } from '@jest/globals';
import { describe, it, expect, afterEach } from '@jest/globals';
import { createTestFileStructure } from '@ms-cloudpack/test-utilities';
import { findFileInPackage } from './findFileInPackage.js';
import path from 'path';
import fs from 'fs';
const { rm } = fs.promises;
describe('findFileInPackage', () => {
let testPath;
afterEach(async () => {
if (testPath) {
await rm(testPath, { recursive: true });
testPath = undefined;
}
});
it('can return undefined for missing files', async () => {
const packagePath = await createTestFileStructure({});
expect(await findFileInPackage({ packagePath, filePath: 'foo.js' })).toEqual({});
testPath = await createTestFileStructure({});
expect(await findFileInPackage({ packagePath: testPath, filePath: 'foo.js' })).toEqual({});
});
it('can find a file in a package', async () => {
const packagePath = await createTestFileStructure({ 'index.js': '', 'subpath/index.js': '' });
expect(await findFileInPackage({ packagePath, filePath: 'index.js' })).toEqual({ filePath: './index.js' });
expect(await findFileInPackage({ packagePath, filePath: 'index' })).toEqual({ filePath: './index.js' });
expect(await findFileInPackage({ packagePath, filePath: '.' })).toEqual({ filePath: './index.js' });
expect(await findFileInPackage({ packagePath, filePath: '' })).toEqual({ filePath: './index.js' });
expect(await findFileInPackage({ packagePath, filePath: 'subpath/index.js' })).toEqual({
testPath = await createTestFileStructure({ 'index.js': '', 'subpath/index.js': '' });
expect(await findFileInPackage({ packagePath: testPath, filePath: 'index.js' })).toEqual({
filePath: './index.js',
});
expect(await findFileInPackage({ packagePath: testPath, filePath: 'index' })).toEqual({ filePath: './index.js' });
expect(await findFileInPackage({ packagePath: testPath, filePath: '.' })).toEqual({ filePath: './index.js' });
expect(await findFileInPackage({ packagePath: testPath, filePath: '' })).toEqual({ filePath: './index.js' });
expect(await findFileInPackage({ packagePath: testPath, filePath: 'subpath/index.js' })).toEqual({
filePath: './subpath/index.js',
});
expect(await findFileInPackage({ packagePath, filePath: 'subpath/index' })).toEqual({
expect(await findFileInPackage({ packagePath: testPath, filePath: 'subpath/index' })).toEqual({
filePath: './subpath/index.js',
});
expect(await findFileInPackage({ packagePath, filePath: 'subpath/' })).toEqual({ filePath: './subpath/index.js' });
expect(await findFileInPackage({ packagePath, filePath: 'subpath' })).toEqual({ filePath: './subpath/index.js' });
expect(await findFileInPackage({ packagePath: testPath, filePath: 'subpath/' })).toEqual({
filePath: './subpath/index.js',
});
expect(await findFileInPackage({ packagePath: testPath, filePath: 'subpath' })).toEqual({
filePath: './subpath/index.js',
});
});
it('can find an intermediate path in an internal unbuilt package with only source files', async () => {
const packagePath = await createTestFileStructure({
testPath = await createTestFileStructure({
'lib/index.js': '',

@@ -31,4 +46,6 @@ 'src/ts.ts': '',

});
expect(await findFileInPackage({ packagePath, filePath: 'lib/index' })).toEqual({ filePath: './lib/index.js' });
expect(await findFileInPackage({ packagePath, filePath: 'lib/ts' })).toEqual({
expect(await findFileInPackage({ packagePath: testPath, filePath: 'lib/index' })).toEqual({
filePath: './lib/index.js',
});
expect(await findFileInPackage({ packagePath: testPath, filePath: 'lib/ts' })).toEqual({
filePath: './lib/ts.js',

@@ -38,3 +55,3 @@ typesPath: './lib/ts.d.ts',

});
expect(await findFileInPackage({ packagePath, filePath: 'lib/ts.js' })).toEqual({
expect(await findFileInPackage({ packagePath: testPath, filePath: 'lib/ts.js' })).toEqual({
filePath: './lib/ts.js',

@@ -44,3 +61,3 @@ typesPath: './lib/ts.d.ts',

});
expect(await findFileInPackage({ packagePath, filePath: 'lib/bar' })).toEqual({
expect(await findFileInPackage({ packagePath: testPath, filePath: 'lib/bar' })).toEqual({
filePath: './lib/bar/index.js',

@@ -50,3 +67,3 @@ typesPath: './lib/bar/index.d.ts',

});
expect(await findFileInPackage({ packagePath, filePath: 'lib/bar/index' })).toEqual({
expect(await findFileInPackage({ packagePath: testPath, filePath: 'lib/bar/index' })).toEqual({
filePath: './lib/bar/index.js',

@@ -56,3 +73,3 @@ typesPath: './lib/bar/index.d.ts',

});
expect(await findFileInPackage({ packagePath, filePath: 'lib/bar/index.js' })).toEqual({
expect(await findFileInPackage({ packagePath: testPath, filePath: 'lib/bar/index.js' })).toEqual({
filePath: './lib/bar/index.js',

@@ -64,7 +81,7 @@ typesPath: './lib/bar/index.d.ts',

it('returns undefined for external packages with only source files', async () => {
const repoPath = await createTestFileStructure({
testPath = await createTestFileStructure({
'node_modules/foo/src/index.ts': '',
'node_modules/foo/src/bar/index.tsx': '',
});
const packagePath = path.join(repoPath, 'node_modules/foo');
const packagePath = path.join(testPath, 'node_modules/foo');
expect(await findFileInPackage({ packagePath, filePath: 'lib/index.js' })).toEqual({});

@@ -76,3 +93,3 @@ expect(await findFileInPackage({ packagePath, filePath: 'lib' })).toEqual({});

it('can find a nested package, such as rtl-css-js/core', async () => {
const repoPath = await createTestFileStructure({
testPath = await createTestFileStructure({
'node_modules/rtl-css-js/package.json': {

@@ -95,3 +112,3 @@ main: 'dist/cjs/index.js',

});
const packagePath = path.join(repoPath, 'node_modules/rtl-css-js');
const packagePath = path.join(testPath, 'node_modules/rtl-css-js');
expect(await findFileInPackage({ packagePath, filePath: './core' })).toEqual({

@@ -98,0 +115,0 @@ filePath: './dist/esm/core.js',

@@ -13,2 +13,3 @@ import type { PackageJson } from 'type-fest';

clear(): void;
clearTransforms(): void;
}

@@ -41,3 +41,6 @@ import path from 'path';

}
clearTransforms() {
this._transforms = [applyOverrides];
}
}
//# sourceMappingURL=PackageDefinitions.js.map
{
"name": "@ms-cloudpack/package-utilities",
"version": "2.1.2",
"version": "2.2.0",
"description": "Utilities for resolving/parsing packages and their imports.",

@@ -5,0 +5,0 @@ "license": "MIT",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc