Skip to content

Commit

Permalink
Merge branch 'master' into update
Browse files Browse the repository at this point in the history
# Conflicts:
#	Jenkinsfile
  • Loading branch information
Eyal Segal committed Jan 9, 2017
2 parents 5f3c1a3 + 3daa7a9 commit 2b9d1a8
Show file tree
Hide file tree
Showing 32 changed files with 294 additions and 61 deletions.
2 changes: 1 addition & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ suppress_comment= \\(.\\|\n\\)*\\$FlowFixMe
unsafe.enable_getters_and_setters=true

[version]
0.37.4
0.36.0
16 changes: 11 additions & 5 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
node {
properties([[$class: 'ParametersDefinitionProperty', parameterDefinitions: [[$class: 'ChoiceParameterDefinition', choices: 'stage\nproduction', description: '', name: 'environment']]]])

checkout scm
def releaseServer = "${env.BIT_STAGE_SERVER}"
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'b0cc61f6-f63c-44ce-b004-c7ce63415d3f', url: '[email protected]:core/bit.git']]])
def releaseServer = "${env.BIT_STAGE_SERVER}"
def assets = "${env.BIT_ASSETS}"
print releaseServer
def env = "${environment}"
Expand All @@ -13,7 +12,7 @@ node {
def uploadfolder = "gs://bit-assets/release/${currentVersion}/"

stage 'remove old zip files '
sh("rm -rf *.tar.gz && rm -rf ./distribution ")
sh("rm -rf *.tar.gz && rm -rf ./distribution && rm -rf ./node_modules")

stage 'Running tar'
sh('cd ./scripts && ./build-tar.sh tar')
Expand All @@ -22,9 +21,13 @@ node {
sh("cd ./scripts && ./build-brew.sh ")


stage 'Running deb'
sh('cd ./scripts && ./build-deb.sh')


stage 'export to google storage'
sh("gsutil -m cp -a public-read ./distribution/brew_pkg/${bundleName}_brew.tar.gz ${uploadfolder}")
//sh("gsutil -m cp -a public-read ./distribution/debian_pkg/${bundleName}_deb.deb ${uploadfolder}")
sh("gsutil -m cp -a public-read ./distribution/debian_pkg/${bundleName}_deb.deb ${uploadfolder}")



Expand All @@ -35,6 +38,9 @@ node {
sh("cd ./scripts && ./generate-formula.sh ${assets}/${currentVersion}/${bundleName}_brew.tar.gz")
sh("cd ./distribution && gsutil -m cp bit.rb ${uploadfolder}")

sh("curl -X PURGE http://assets.bitsrc.io/release/${currentVersion}/bit_${currentVersion}_brew.tar.gz")


}
import groovy.json.JsonOutput
def notifyReleaseServer(version,url) {
Expand Down
2 changes: 1 addition & 1 deletion src/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @flow */
import buildRegistrar from './cli/command-registrar-builder';
import loudRejection from 'loud-rejection';
import buildRegistrar from './cli/command-registrar-builder';

loudRejection();

Expand Down
5 changes: 2 additions & 3 deletions src/bit/bit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import { mkdirp } from '../utils';
import BitJson from '../bit-json';
import { Scope } from '../scope';
import PartialBit from './partial-bit';
import { getContents } from '../tar';
import { BIT_JSON } from '../constants';
import { getContents } from '../utils/tar';
import { BitId } from '../bit-id';
import { DEFAULT_DIST_DIRNAME, DEFAULT_BUNDLE_FILENAME } from '../constants';
import { DEFAULT_DIST_DIRNAME, BIT_JSON, DEFAULT_BUNDLE_FILENAME } from '../constants';

export type BitProps = {
name: string;
Expand Down
2 changes: 1 addition & 1 deletion src/bit/partial-bit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import fs from 'fs-extra';
import path from 'path';
import R from 'ramda';
import { pack } from '../tar';
import { pack } from '../utils/tar';
import * as bitCache from '../cache';
import { CacheNotFound } from '../cache/exceptions';
import { Impl, Specs } from './sources';
Expand Down
17 changes: 0 additions & 17 deletions src/box/box.js

This file was deleted.

3 changes: 0 additions & 3 deletions src/box/index.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/cli/commands/init-cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class Init extends Command {
alias = '';
opts = [
['b', 'bare [name]', 'initialize an empty bit bare scope'],
['s', 'shared', 'add group write permissions to a repository properly']
['s', 'shared <groupname>', 'add group write permissions to a repository properly']
];

action([path, ]: [string, ], { bare }: any): Promise<{[string]: any}> {
Expand Down
6 changes: 3 additions & 3 deletions src/cli/commands/list-cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import Command from '../command';
import { list } from '../../api';

export default class List extends Command {
name = 'ls';
name = 'list';
description = 'list all box bits';
alias = '';
alias = 'ls';
opts = [
['i', 'inline', 'remove inline bit']
['i', 'inline', 'in inline bit']
];

action(args: string[], opts: any): Promise<any> {
Expand Down
6 changes: 6 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ export const DEFAULT_BIT_VERSION = '1';

export const LATEST_BIT_VERSION = 'latest';

export const OBJECTS_DIR = 'objects';

export const NULL_BYTE = '/0';

export const SPACE_DELIMITER = ' ';

export const DEFAULT_BOX_NAME = 'global';

export const VERSION_DELIMITER = '::';
Expand Down
3 changes: 1 addition & 2 deletions src/consumer/consumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ import {
BIT_HIDDEN_DIR,
} from '../constants';
import { flatten } from '../utils';
import { Scope } from '../scope';
import { Scope, BitDependencies } from '../scope';
import BitInlineId from '../bit-inline-id';
import loadPlugin from '../bit/environment/load-plugin';
import { BitDependencies } from '../scope';

const buildBit = (bit: Bit, scope: Scope): Promise<Bit> => bit.build(scope);

Expand Down
10 changes: 10 additions & 0 deletions src/objects/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/** @flow */
import BitObject from './object';
import Repository from './repository';
import Ref from './ref';

export {
BitObject,
Ref,
Repository
};
31 changes: 31 additions & 0 deletions src/objects/object.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/** @flow */
import { deflate, inflate, sha1 } from '../utils';
import { NULL_BYTE, SPACE_DELIMITER } from '../constants';

export default class BitObject {
/**
* indexing method
*/
hash(): string {
return sha1(this.id());
}

compress(): Promise<Buffer> {
return deflate(this.serialize());
}

serialize(): Buffer {
const contents = this.toBuffer();
const header = `${this.constructor.name} ${contents.toString().length}${NULL_BYTE}$`;
return Buffer.concat([new Buffer(header), contents]);
}

static parse(fileContents: Buffer, types: {[string]: Function}): Promise<BitObject> {
return inflate(fileContents)
.then((buffer) => {
const [headers, contents] = buffer.toString().split(NULL_BYTE);
const [type, ] = headers.split(SPACE_DELIMITER);
return types[type].parse(contents);
});
}
}
9 changes: 9 additions & 0 deletions src/objects/ref.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @flow */

export default class Ref {
hash: string;

constructor(hash: string) {
this.hash = hash;
}
}
56 changes: 56 additions & 0 deletions src/objects/repository.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/** @flow */
import path from 'path';
import BitObject from './object';
import Ref from './ref';
import { OBJECTS_DIR } from '../constants';
import { mkdirp, writeFile, allSettled, readFile } from '../utils';
import { Scope } from '../scope';

export default class Repository {
objects: BitObject[] = [];
scope: Scope;
types: {[string]: Function};

constructor(scope: Scope, objectTypes: Function[] = []) {
this.scope = scope;
this.types = objectTypes.reduce((map, objectType) => {
map[objectType.name] = objectType;
return map;
}, {});
}

ensureDir() {
return mkdirp(this.getPath());
}

getPath() {
return path.join(this.scope.getPath(), OBJECTS_DIR);
}

objectPath(hash: string): string {
return path.join(this.getPath(), hash.slice(0, 2), hash.slice(2));
}

load(ref: Ref): Promise<BitObject> {
return readFile(this.objectPath(ref.hash))
.then(fileContents => BitObject.parse(fileContents, this.types));
}

add(object: BitObject): Repository {
this.objects.push(object);
return this;
}

persist(): Promise<> {
// @TODO handle failures
return allSettled(this.objects.map(object => this.persistOne(object)));
}

persistOne(object: BitObject): Promise<> {
return object.compress()
.then((contents) => {
return writeFile(this.objectPath(object.hash()), contents);
});
}
}

Empty file added src/scope/models/component.js
Empty file.
22 changes: 22 additions & 0 deletions src/scope/models/source.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { BitObject } from '../../objects';

export default class Source extends BitObject {
contents: Buffer;

constructor(contents: Buffer) {
super();
this.contents = contents;
}

id() {
return this.toString();
}

toBuffer() {
return this.contents;
}

static parse(contents: string): Source {
return new Source(new Buffer(contents));
}
}
Empty file added src/scope/models/version.js
Empty file.
8 changes: 8 additions & 0 deletions src/scope/object-registrar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @flow */
import Source from './models/source';

export default function types() {
return [
Source
];
}
2 changes: 1 addition & 1 deletion src/scope/repositories/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import AbstractBitJson from '../../bit-json/abstract-bit-json';
import { BitId } from '../../bit-id';
import Bit from '../../bit';
import { BIT_ENVIRONMENT_DIRNAME } from '../../constants';
import npmInstall from '../../npm';
import npmInstall from '../../utils/npm';
import resolveBit from '../../bit-node-resolver';

const installPackageDependencies = (bit) => {
Expand Down
32 changes: 30 additions & 2 deletions src/scope/repositories/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { BIT_SOURCES_DIRNAME } from '../../constants';
import InvalidBit from '../../bit/exceptions/invalid-bit';
import Bit from '../../bit';
import PartialBit from '../../bit/partial-bit';
import { BitId } from '../../bit-id';
import { listDirectories, rmDir, empty } from '../../utils';
import { BitId, BitIds } from '../../bit-id';
import { listDirectories, rmDir, empty, glob } from '../../utils';

export default class Source extends Repository {
getPath(): string {
Expand Down Expand Up @@ -40,6 +40,34 @@ export default class Source extends Repository {
return id.getVersion().resolve(this.listVersions(id));
}

list(): BitIds {
// function listComponents(components: string[]) {
// return components.map((component) => {
// return {
// name: component,
// version: this.resolveVersion('latest')
// };
// });
// }

// return listDirectories(this.getPath())
// .map((box) => {
// return {
// box,
// components: listComponents.bind(this,
// listDirectories(this.composeBoxPath(box))
// ),
// };
// });
return glob(path.join(this.getPath(), '*', '*', '*'))
.then(matches =>
matches.map((match) => {
const bitId = path.parse(match);
return PartialBit.load(match, '', this.scope.name());
})
);
}

loadSource(id: BitId): Promise<Bit> {
try {
const version = this.resolveVersion(id);
Expand Down
Loading

0 comments on commit 2b9d1a8

Please sign in to comment.