Skip to content

Commit

Permalink
deps: update rollup to version 0.41.1 (#616)
Browse files Browse the repository at this point in the history
* chore(package): update rollup to version 0.41.1

https://greenkeeper.io/

* fix: external module resolution bugs

* fix: handle windows file paths in is-external util

* fix: handle windows paths on lux build as well

* fix: use four back slashes for windows path matching

* fix: handle absolute paths on windows

* fix: pass dir to is external call

* fix: rely on path.resolve for absolute path testing

* fix: use regexp to determine external modules

* fix: ensure modules in the dist folder are not external

* fix: go back to strings for external module resolution

* fix: use absolute path regexp in is-external compiler util

* testf: properly invoke external function in tests

* test: add unit tests for compiler module

* fix: remove volume from alias paths on windows
  • Loading branch information
greenkeeperio-bot authored and zacharygolba committed Jan 13, 2017
1 parent 1626cd8 commit e7d069f
Show file tree
Hide file tree
Showing 26 changed files with 397 additions and 228 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"inflection": "1.10.0",
"knex": "0.12.6",
"ora": "0.4.1",
"rollup": "0.37.0",
"rollup": "0.41.1",
"rollup-plugin-alias": "1.2.0",
"rollup-plugin-babel": "2.7.1",
"rollup-plugin-eslint": "3.0.0",
Expand Down
33 changes: 19 additions & 14 deletions scripts/build/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

require('../../../lib/babel-hook');

const fs = require('fs');
const path = require('path');

// Plugins
const json = require('rollup-plugin-json');
const babel = require('rollup-plugin-babel');
const nodeResolve = require('rollup-plugin-node-resolve');
const resolve = require('rollup-plugin-node-resolve');

const template = require('../../../src/packages/template').default;
const { onwarn } = require('../../../src/packages/compiler');
const { default: template } = require('../../../src/packages/template');

const BANNER = template`
'use strict';
Expand All @@ -22,20 +21,26 @@ const BANNER = template`

module.exports = {
rollup: {
external: [
'knex',
'bundle',
path.join(__dirname, '..', '..', '..', 'lib', 'fs', 'index.js'),
...fs.readdirSync(path.join(__dirname, '..', '..', '..', 'node_modules'))
],

onwarn,
plugins: [
json(),
babel(),
nodeResolve({ preferBuiltins: true })
]
resolve({
preferBuiltins: true
})
],
external(id) {
return !(
id.startsWith('.')
|| id.startsWith('/') // Absolute path on Unix
|| /^[A-Z]:[\\/]/.test(id) // Absolute path on Windows
|| id.startsWith('src')
|| id.startsWith(path.join('..', '..', '..', 'src'))
|| id === 'babelHelpers'
|| id === '\u0000babelHelpers'
);
},
},

bundle: {
banner: BANNER,
format: 'cjs',
Expand Down
1 change: 0 additions & 1 deletion src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,5 @@ export const NODE_ENV = ENV.NODE_ENV || 'development';
export const DATABASE_URL = ENV.DATABASE_URL;
export const LUX_CONSOLE = ENV.LUX_CONSOLE || false;
export const PLATFORM = platform();
export const BACKSLASH = /\\/g;
export const CIRCLECI = ENV.CIRCLECI;
export const APPVEYOR = ENV.APPVEYOR;
12 changes: 5 additions & 7 deletions src/packages/application/utils/create-controller.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// @flow
import { posix } from 'path';

import { deepFreezeProps } from '../../freezeable';
import {
getNamespaceKey,
stripNamespaces,
closestAncestor
} from '../../loader';
import { closestAncestor } from '../../loader';
import { tryCatchSync } from '../../../utils/try-catch';
import type Database from '../../database';
import type Controller from '../../controller';
Expand All @@ -21,9 +19,9 @@ export default function createController<T: Controller>(
}
): T {
const { key, store, serializers } = opts;
const namespace = getNamespaceKey(key).replace('root', '');
const namespace = posix.dirname(key).replace('.', '');
let { parent } = opts;
let model = tryCatchSync(() => store.modelFor(stripNamespaces(key)));
let model = tryCatchSync(() => store.modelFor(posix.basename(key)));
let serializer = serializers.get(key);

if (!model) {
Expand Down
7 changes: 4 additions & 3 deletions src/packages/application/utils/create-serializer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @flow
import { posix } from 'path';

import { deepFreezeProps } from '../../freezeable';
import { getNamespaceKey, stripNamespaces } from '../../loader';
import { tryCatchSync } from '../../../utils/try-catch';
import type Serializer from '../../serializer'; // eslint-disable-line max-len, no-unused-vars
import type { Application$factoryOpts } from '../index';
Expand All @@ -10,9 +11,9 @@ export default function createSerializer<T: Serializer<*>>(
opts: Application$factoryOpts<T>
): T {
const { key, store } = opts;
const namespace = getNamespaceKey(key).replace('root', '');
const namespace = posix.dirname(key).replace('.', '');
let { parent } = opts;
let model = tryCatchSync(() => store.modelFor(stripNamespaces(key)));
let model = tryCatchSync(() => store.modelFor(posix.basename(key)));

if (!model) {
model = null;
Expand Down
122 changes: 63 additions & 59 deletions src/packages/cli/generator/utils/generate-type.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// @flow
import { join as joinPath } from 'path';
import { posix, join as joinPath } from 'path';

import { green } from 'chalk';
import { pluralize, singularize } from 'inflection';

import { NAMESPACED_RESOURCE_MESSAGE } from '../constants';
import { stripNamespaces, getNamespaceKey } from '../../../loader';
import { generateTimestamp } from '../../../database';
import { exists, readFile, writeFile } from '../../../fs';
import modelTemplate from '../../templates/model';
Expand Down Expand Up @@ -45,21 +44,23 @@ export async function controller(opts: Generator$opts): Promise<void> {
name
});

const namespace = getNamespaceKey(name);

if (namespace !== 'root') {
const hasParent = await exists(
joinPath(cwd, dir, ...[...namespace.split('/'), 'application.js'])
);

if (!hasParent) {
await controller({
...opts,
cwd,
name: `${namespace}/application`,
attrs: []
});
}
const namespace = posix.dirname(name);

if (namespace === '.') {
return;
}

const hasParent = await exists(
joinPath(cwd, dir, namespace.split('/'), 'application.js')
);

if (!hasParent) {
await controller({
...opts,
cwd,
name: `${namespace}/application`,
attrs: []
});
}
}

Expand All @@ -86,21 +87,23 @@ export async function serializer(opts: Generator$opts): Promise<void> {
name
});

const namespace = getNamespaceKey(name);

if (namespace !== 'root') {
const hasParent = await exists(
joinPath(cwd, dir, ...[...namespace.split('/'), 'application.js'])
);

if (!hasParent) {
await serializer({
...opts,
cwd,
name: `${namespace}/application`,
attrs: []
});
}
const namespace = posix.dirname(name);

if (namespace === '.') {
return;
}

const hasParent = await exists(
joinPath(cwd, dir, ...[...namespace.split('/'), 'application.js'])
);

if (!hasParent) {
await serializer({
...opts,
cwd,
name: `${namespace}/application`,
attrs: []
});
}
}

Expand All @@ -119,7 +122,7 @@ export function migration(opts: Generator$opts) {
});

name = chain(name)
.pipe(stripNamespaces)
.pipe(posix.basename)
.pipe(str => `${generateTimestamp()}-${str}`)
.value();

Expand Down Expand Up @@ -149,7 +152,7 @@ export function modelMigration(opts: Generator$opts) {
});

name = chain(name)
.pipe(stripNamespaces)
.pipe(posix.basename)
.pipe(pluralize)
.pipe(str => `${generateTimestamp()}-create-${str}`)
.value();
Expand Down Expand Up @@ -178,7 +181,7 @@ export async function model(opts: Generator$opts): Promise<void> {
await modelMigration({ name, ...opts });

name = chain(name)
.pipe(stripNamespaces)
.pipe(posix.basename)
.pipe(singularize)
.value();

Expand Down Expand Up @@ -236,30 +239,31 @@ export async function resource(opts: Generator$opts) {
await controller(opts);
await serializer(opts);

if (getNamespaceKey(opts.name) !== 'root') {
if (posix.dirname(opts.name) === '.') {
log(NAMESPACED_RESOURCE_MESSAGE);
} else {
const path = joinPath(opts.cwd, 'app', 'routes.js');
const routes = chain(await readFile(path))
.pipe(buf => buf.toString('utf8'))
.pipe(str => str.split('\n'))
.pipe(lines => lines.reduce((result, line, index, arr) => {
const closeIndex = arr.lastIndexOf('}');
let str = result;

if (line && index <= closeIndex) {
str += `${line}\n`;
}

if (index + 1 === closeIndex) {
str += ` this.resource('${pluralize(opts.name)}');\n`;
}

return str;
}, ''))
.value();

await writeFile(path, routes);
log(`${green('update')} app/routes.js`);
return;
}

const path = joinPath(opts.cwd, 'app', 'routes.js');
const routes = chain(await readFile(path))
.pipe(buf => buf.toString('utf8'))
.pipe(str => str.split('\n'))
.pipe(lines => lines.reduce((result, line, index, arr) => {
const closeIndex = arr.lastIndexOf('}');
let str = result;

if (line && index <= closeIndex) {
str += `${line}\n`;
}

if (index + 1 === closeIndex) {
str += ` this.resource('${pluralize(opts.name)}');\n`;
}

return str;
}, ''))
.value();

await writeFile(path, routes);
log(`${green('update')} app/routes.js`);
}
Loading

0 comments on commit e7d069f

Please sign in to comment.