Skip to content

Commit

Permalink
drop fb from fbkpm (yarnpkg#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian McKenzie authored and bestander committed Jul 25, 2016
1 parent 34cc2a9 commit 95aaa2f
Show file tree
Hide file tree
Showing 48 changed files with 148 additions and 95 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD License

For fbkpm software
For kpm software

Copyright (c) 2016-present, Facebook, Inc. All rights reserved.

Expand Down
2 changes: 1 addition & 1 deletion PATENTS
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Additional Grant of Patent Rights Version 2

"Software" means the fbkpm software distributed by Facebook, Inc.
"Software" means the kpm software distributed by Facebook, Inc.

Facebook, Inc. ("Facebook") hereby grants to each recipient of the Software
("you") a perpetual, worldwide, royalty-free, non-exclusive, irrevocable
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "fbkpm",
"name": "kpm",
"version": "0.7.1",
"license": "BSD-3-Clause",
"preferGlobal": true,
Expand Down
8 changes: 4 additions & 4 deletions src/cli/commands/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ export { check };
import buildUseless from "./_useless.js";

export let runScript = buildUseless(
"Use `fbkpm <script-name>` instead of `fbkpm run-script <script-name>`"
"Use `kpm <script-name>` instead of `kpm run-script <script-name>`"
);

export let lockfile = buildUseless(
"The lockfile command isn't necessary. `fbkpm install` will produce a lockfile."
"The lockfile command isn't necessary. `kpm install` will produce a lockfile."
);

export let dedupe = buildUseless(
"The dedupe command isn't necessary. `fbkpm install` will already dedupe."
"The dedupe command isn't necessary. `kpm install` will already dedupe."
);

export let prune = buildUseless(
"The prune command isn't necessary. `fbkpm install` will now automatically prune extraneous packages."
"The prune command isn't necessary. `kpm install` will now automatically prune extraneous packages."
);
6 changes: 3 additions & 3 deletions src/cli/commands/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ export class Install {
util.hash(lockSource)
);

this.reporter.success(`Saved fbkpm lockfile to ${constants.LOCKFILE_FILENAME}`);
this.reporter.success(`Saved lockfile to ${constants.LOCKFILE_FILENAME}`);
}
}

Expand All @@ -350,7 +350,7 @@ function isStrictLockfile(flags: Object, args: Array<string>): boolean {
}

if (!args.length) {
// we're running `fbkpm install` so should be strict on lockfile usage
// we're running `kpm install` so should be strict on lockfile usage
return true;
}

Expand Down Expand Up @@ -385,7 +385,7 @@ function shouldWriteLockfile(flags: Object, args: Array<string>): boolean {
}

if (!args.length) {
// we're running `fbkpm install` so should save a new lockfile
// we're running `kpm install` so should save a new lockfile
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ if (network.isOffline()) {

//
if (command.requireLockfile && !fs.existsSync(path.join(config.cwd, constants.LOCKFILE_FILENAME))) {
reporter.error("No lockfile in this directory. Run `fbkpm install` to generate one.");
reporter.error("No lockfile in this directory. Run `kpm install` to generate one.");
process.exit(1);
}

Expand Down
8 changes: 4 additions & 4 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export default class Config {
}

/**
* Generate an absolute module path in fbkpm_modules.
* Generate an absolute module path.
*/

generateHardModulePath(pkg: ?{
Expand Down Expand Up @@ -189,21 +189,21 @@ export default class Config {
return opts.packagesRoot;
}

// walk up from current directory looking for .fbkpm folders
// walk up from current directory looking for .kpm folders
let parts = this.cwd.split(path.sep);
for (let i = parts.length; i > 0; i--) {
let loc = parts.slice(0, i).concat(constants.MODULE_CACHE_DIRECTORY).join(path.sep);
if (await fs.exists(loc)) return loc;
}

// try and create <cwd>/fbkpm_modules
// try and create ~/.kpm
let loc = path.join(userHome, constants.MODULE_CACHE_DIRECTORY);
await fs.mkdirp(loc);
return loc;
}

/**
* Checker whether the folder input is a valid module folder. We output a fbkpm metadata
* Checker whether the folder input is a valid module folder. We output a kpm metadata
* file when we've successfully setup a folder so use this as a marker.
*/

Expand Down
30 changes: 24 additions & 6 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
* @flow
*/

let userHome = require("user-home");
let path = require("path");
let pkg = require("../package.json");
let fs = require("fs");

let cwd = process.cwd();

// max amount of network requests to perform concurrently
export const NETWORK_CONCURRENCY = 15;

Expand All @@ -17,13 +24,24 @@ export const CHILD_CONCURRENCY = 5;

export const REQUIRED_PACKAGE_KEYS = ["name", "version", "uid"];

export const MODULE_CACHE_DIRECTORY = ".fbkpm";
export const LOCKFILE_FILENAME = "fbkpm.lock";
export const INTEGRITY_FILENAME = ".fbkpm-integrity";
export const METADATA_FILENAME = ".fbkpm-metadata.json";
export const SINGLE_SOCKET_FILENAME = ".fbkpm-single-socket";
function or(filenames: Array<string>, cwd: string): string {
for (let filename of filenames) {
let loc = path.join(cwd, filename);
if (fs.existsSync(loc)) {
return filename;
}
}

return filenames.pop();
}

export const MODULE_CACHE_DIRECTORY = or([".fbkpm", ".kpm"], userHome);
export const SINGLE_SOCKET_FILENAME = ".kpm-single-socket";
export const INTEGRITY_FILENAME = or([".fbkpm-integrity", ".kpm-integrity"], path.join(cwd, "node_modules"));
export const LOCKFILE_FILENAME = or(["fbkpm.lock", "kpm.lock"], cwd);
export const METADATA_FILENAME = ".kpm-metadata.json";

export const USER_AGENT = "fbkpm";
export const USER_AGENT = `kpm v${pkg.version}`;

export const ENV_PATH_KEY = getPathKey(process.platform, process.env);

Expand Down
4 changes: 2 additions & 2 deletions src/package-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export default class PackageRequest {
let ref = new PackageReference(this, info, remote, this.resolver.lockfile.save);

// in order to support lockfiles inside transitive dependencies we need to block
// resolution to fetch the package so we can peek inside of it for a fbkpm.lock
// resolution to fetch the package so we can peek inside of it for a kpm.lock
// only do this in strict lockfile mode as otherwise we can just use our root lockfile
let subLockfile = null;

Expand Down Expand Up @@ -285,7 +285,7 @@ export default class PackageRequest {
newInfo.remote = remote;
info = newInfo;

// find and load in fbkpm.lock from this module if it exists
// find and load in kpm.lock from this module if it exists
let lockfileLoc = path.join(dest, constants.LOCKFILE_FILENAME);
if (await fs.exists(lockfileLoc)) {
let rawLockfile = await fs.readFile(lockfileLoc);
Expand Down
1 change: 1 addition & 0 deletions src/registries/_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default class Registry {
async loadConfig(): Promise<void> {}

async init(): Promise<void> {
this.mergeEnv("kpm_");
this.mergeEnv("fbkpm_");
await this.loadConfig();

Expand Down
2 changes: 1 addition & 1 deletion src/registries/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function getGlobalPrefix(): string {
}

export default class NpmRegistry extends Registry {
static filenames = ["fbkpm.json", "package.json"];
static filenames = ["package.json"];

async loadConfig(): Promise<void> {
// docs: https://docs.npmjs.com/misc/config
Expand Down
4 changes: 2 additions & 2 deletions src/util/blocking-queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default class BlockingQueue {
if (this.runningCount === 1) {
this.warnedStuck = true;
console.warn(
`[fbkpm] The ${JSON.stringify(this.alias)} blocking queue may be stuck. 5 seconds ` +
`[kpm] The ${JSON.stringify(this.alias)} blocking queue may be stuck. 5 seconds ` +
`without any activity with 1 worker: ${Object.keys(this.running)[0]}`
);
}
Expand Down Expand Up @@ -91,7 +91,7 @@ export default class BlockingQueue {
if (this.warnedStuck) {
this.warnedStuck = false;
console.log(
`[fbkpm] ${JSON.stringify(this.alias)} blocking queue finally resolved. Nothing to worry about.`
`[kpm] ${JSON.stringify(this.alias)} blocking queue finally resolved. Nothing to worry about.`
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/util/execute-lifecycle-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default async function (config: Config, cwd: string, cmds: Array<string>)
let env = Object.assign({}, process.env);

// this is used in some places apparently..
env.npm_execpath = path.join(__dirname, "..", "..", "bin", "fbkpm.js");
env.npm_execpath = path.join(__dirname, "..", "..", "bin", "kpm.js");

// split up the path
let pathParts = (env[constants.ENV_PATH_KEY] || "").split(path.delimiter);
Expand Down
Loading

0 comments on commit 95aaa2f

Please sign in to comment.