Socket
Socket
Sign inDemoInstall

@changesets/config

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@changesets/config - npm Package Compare versions

Comparing version 0.1.0 to 0.1.2

dist/config.cjs.d.ts

7

CHANGELOG.md
# @changesets/config
## 0.1.2
### Patch Changes
- [a15abbf9](https://github.com/changesets/changesets/commit/a15abbf9) - Previous release shipped unbuilt code - fixing that
## 0.1.0
### Minor Changes

@@ -5,0 +12,0 @@

12

dist/config.cjs.js

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

"use strict";
'use strict';
let unregister = require("/Users/bconolly/Development/changesets/node_modules/@preconstruct/hook/dist/hook.cjs.js").___internalHook("/Users/bconolly/Development/changesets");
module.exports = require("/Users/bconolly/Development/changesets/packages/config/src/index.ts");
unregister();
if (process.env.NODE_ENV === "production") {
module.exports = require("./config.cjs.prod.js");
} else {
module.exports = require("./config.cjs.dev.js");
}

@@ -1,15 +0,117 @@

// 👋 hey!!
// you might be reading this and seeing .esm in the filename
// and being confused why there is commonjs below this filename
// DON'T WORRY!
// this is intentional
// it's only commonjs with `preconstruct dev`
// when you run `preconstruct build`, it will be ESM
// why is it commonjs?
// we need to re-export every export from the source file
// but we can't do that with ESM without knowing what the exports are (because default exports aren't included in export/import *)
// and they could change after running `preconstruct dev` so we can't look at the file without forcing people to
// run preconstruct dev again which wouldn't be ideal
// this solution could change but for now, it's working
import { readJSON } from 'fs-extra';
import path from 'path';
module.exports = require("/Users/bconolly/Development/changesets/packages/config/src/index.ts")
var packageJson = {
name: "@changesets/config",
version: "0.1.2",
description: "Utilities for reading and parsing Changeset's config",
main: "dist/config.cjs.js",
module: "dist/config.esm.js",
license: "MIT",
repository: "https://github.com/changesets/changesets/tree/master/packages/config",
files: [
"dist",
"schema.json"
],
dependencies: {
"@changesets/types": "^0.1.2",
"fs-extra": "^7.0.1"
},
devDependencies: {
fixturez: "^1.1.0",
"jest-in-case": "^1.0.2"
}
};
let defaultWrittenConfig = {
$schema: `https://unpkg.com/@changesets/config@${packageJson.version}/schema.json`,
changelog: "@changesets/cli/changelog",
commit: false,
linked: [],
access: "private"
};
function getNormalisedChangelogOption(thing) {
if (thing === false) {
return false;
}
if (typeof thing === "string") {
return [thing, null];
}
return thing;
}
let read = async (cwd, workspaces) => {
let json = await readJSON(path.join(cwd, ".changeset", "config.json"));
return parse(json, workspaces);
};
let parse = (json, workspaces) => {
let messages = [];
if (json.changelog !== undefined && json.changelog !== false && typeof json.changelog !== "string" && !(Array.isArray(json.changelog) && json.changelog.length === 2 && typeof json.changelog[0] === "string")) {
messages.push(`The \`changelog\` option is set as ${JSON.stringify(json.changelog, null, 2)} when the only valid values are undefined, a module path(e.g. "@changesets/cli/changelog" or "./some-module") or a tuple with a module path and config for the changelog generator(e.g. ["@changesets/cli/changelog", { someOption: true }])`);
}
if (json.access !== undefined && json.access !== "private" && json.access !== "public") {
messages.push(`The \`access\` option is set as ${JSON.stringify(json.access, null, 2)} when the only valid values are undefined, "public" or "private"`);
}
if (json.commit !== undefined && typeof json.commit !== "boolean") {
messages.push(`The \`commit\` option is set as ${JSON.stringify(json.commit, null, 2)} when the only valid values are undefined or a boolean`);
}
if (json.linked !== undefined) {
if (!(Array.isArray(json.linked) && json.linked.every(arr => Array.isArray(arr) && arr.every(pkgName => typeof pkgName === "string")))) {
messages.push(`The \`linked\` option is set as ${JSON.stringify(json.linked, null, 2)} when the only valid values are undefined or an array of arrays of package names`);
} else {
let pkgNames = new Set(workspaces.map(({
name
}) => name));
let foundPkgNames = new Set();
let duplicatedPkgNames = new Set();
for (let linkedGroup of json.linked) {
for (let linkedPkgName of linkedGroup) {
if (!pkgNames.has(linkedPkgName)) {
messages.push(`The package "${linkedPkgName}" is specified in the \`linked\` option but it is not found in the project. You may have misspelled the package name.`);
}
if (foundPkgNames.has(linkedPkgName)) {
duplicatedPkgNames.add(linkedPkgName);
}
foundPkgNames.add(linkedPkgName);
}
}
if (duplicatedPkgNames.size) {
duplicatedPkgNames.forEach(pkgName => {
messages.push(`The package "${pkgName}" is in multiple sets of linked packages. Packages can only be in a single set of linked packages.`);
});
}
}
}
if (messages.length) {
throw new ValidationError(messages);
}
let config = {
changelog: getNormalisedChangelogOption(json.changelog === undefined ? defaultWrittenConfig.changelog : json.changelog),
access: json.access === undefined ? defaultWrittenConfig.access : json.access,
commit: json.commit === undefined ? defaultWrittenConfig.commit : json.commit,
linked: json.linked === undefined ? defaultWrittenConfig.linked : json.linked
};
return config;
};
let defaultConfig = parse(defaultWrittenConfig, []);
class ValidationError extends Error {
constructor(messages) {
super(`Some errors occurred when validating the changesets config:\n` + messages.join("\n"));
}
}
export { ValidationError, defaultConfig, defaultWrittenConfig, parse, read };
{
"name": "@changesets/config",
"version": "0.1.0",
"version": "0.1.2",
"description": "Utilities for reading and parsing Changeset's config",

@@ -14,3 +14,3 @@ "main": "dist/config.cjs.js",

"dependencies": {
"@changesets/types": "^0.1.0",
"@changesets/types": "^0.1.2",
"fs-extra": "^7.0.1"

@@ -17,0 +17,0 @@ },

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