Skip to content

Commit

Permalink
Update deps and affected tests
Browse files Browse the repository at this point in the history
Notable changes:
- Lerna 2 → 3
- TypeScript 2 → 3
- babel-* 6 → 7
  • Loading branch information
meyer committed Sep 20, 2018
1 parent 17177fd commit 28698ab
Show file tree
Hide file tree
Showing 16 changed files with 121 additions and 123 deletions.
8 changes: 4 additions & 4 deletions examples/jsxstyle-preact-cli-example/package.json
Expand Up @@ -8,11 +8,11 @@
"start": "preact watch"
},
"devDependencies": {
"preact-cli": "^2.1.1"
"preact-cli": "^2.2.1"
},
"dependencies": {
"preact": "^8.2.7",
"preact-compat": "^3.17.0",
"preact-router": "^2.6.0"
"preact": "^8.3.1",
"preact-compat": "^3.18.4",
"preact-router": "^2.6.1"
}
}
6 changes: 3 additions & 3 deletions examples/jsxstyle-preact-cli-typescript-example/package.json
Expand Up @@ -8,8 +8,8 @@
"start": "preact watch"
},
"devDependencies": {
"preact-cli": "^2.1.1",
"ts-loader": "^4.4.1",
"typescript": "^2.9.2"
"preact-cli": "^2.2.1",
"ts-loader": "^3.5.0",
"typescript": "^3.0.3"
}
}
23 changes: 11 additions & 12 deletions examples/jsxstyle-react-example/package.json
Expand Up @@ -6,20 +6,19 @@
"start": "webpack-serve"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.4",
"babel-plugin-transform-object-assign": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.0",
"css-loader": "^0.28.11",
"@babel/core": "^7.1.0",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/plugin-transform-object-assign": "^7.0.0",
"babel-loader": "^8.0.2",
"css-loader": "^1.0.0",
"rimraf": "^2.6.2",
"style-loader": "^0.21.0",
"webpack": "^4.12.0",
"webpack-cli": "^3.0.8"
"style-loader": "^0.23.0",
"webpack": "^4.19.1",
"webpack-cli": "^3.1.0"
},
"dependencies": {
"react": "^16.0.0",
"react-dom": "^16.0.0",
"webpack-serve": "^1.0.4"
"react": "^16.5.2",
"react-dom": "^16.5.2",
"webpack-serve": "^2.0.2"
}
}
8 changes: 4 additions & 4 deletions examples/jsxstyle-react-example/webpack.config.js
Expand Up @@ -23,19 +23,19 @@ module.exports = {
babelrc: false,
presets: [
[
'env',
'@babel/preset-env',
{
targets: {
browsers: ['last 2 versions'],
},
modules: false,
},
],
'react',
'@babel/preset-react',
],
plugins: [
require.resolve('babel-plugin-transform-object-rest-spread'),
require.resolve('babel-plugin-transform-object-assign'),
require.resolve('@babel/plugin-proposal-object-rest-spread'),
require.resolve('@babel/plugin-transform-object-assign'),
],
},
},
Expand Down
27 changes: 14 additions & 13 deletions examples/jsxstyle-typescript-example/package.json
Expand Up @@ -5,23 +5,24 @@
"start": "ts-node ./node_modules/.bin/webpack-serve --config=webpack.config.ts"
},
"dependencies": {
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.0",
"css-loader": "^0.28.7",
"file-loader": "^1.1.5",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"style-loader": "^0.21.0",
"ts-loader": "^4.2.0",
"typescript": "^2.9.2",
"url-loader": "^1.0.1",
"webpack": "^4.5.0",
"webpack-serve": "^1.0.4"
"@babel/core": "^7.1.0",
"@babel/preset-env": "^7.1.0",
"babel-loader": "^8.0.2",
"css-loader": "^1.0.0",
"file-loader": "^2.0.0",
"react": "^16.5.2",
"react-dom": "^16.5.2",
"style-loader": "^0.23.0",
"ts-loader": "^5.1.1",
"typescript": "^3.0.3",
"url-loader": "^1.1.1",
"webpack": "^4.19.1",
"webpack-serve": "^2.0.2"
},
"devDependencies": {
"@types/node": "^10.3.4",
"@types/react": "^16.3.10",
"@types/react-dom": "^16.0.5",
"@types/react-dom": "^16.0.7",
"@types/webpack-env": "^1.13.6"
}
}
4 changes: 2 additions & 2 deletions examples/jsxstyle-typescript-example/webpack.config.ts
Expand Up @@ -35,8 +35,8 @@ const config: webpack.Configuration = {
options: {
babelrc: false,
presets: [
[require.resolve('babel-preset-env'), { modules: false }],
require.resolve('babel-preset-react'),
[require.resolve('@babel/preset-env'), { modules: false }],
require.resolve('@babel/preset-react'),
],
},
},
Expand Down
46 changes: 24 additions & 22 deletions examples/run.ts
@@ -1,8 +1,20 @@
import { getPackages } from '@lerna/project';
import { spawn } from 'child_process';
import * as fs from 'fs-extra';
import * as inquirer from 'inquirer';
import * as path from 'path';

// NOTE: this interface is incomplete
// See: @lerna/package
interface Package {
name: string;
location: string;
private: boolean;
toJSON: () => string;
}

const JSXSTYLE_ROOT = path.resolve(__dirname, '..');

// TODO: use @lerna/run
const npmCommand = (example: string, ...args: string[]) =>
new Promise<void>((resolve, reject) => {
const childProcess = spawn('npm', args, {
Expand All @@ -27,37 +39,27 @@ const npmCommand = (example: string, ...args: string[]) =>
});
});

(async (command, ...args) => {
const filenames = await fs.readdir(__dirname);
const exampleDirs = filenames.filter(f => {
if (f === 'node_modules') {
return false;
}
return fs.lstatSync(path.join(__dirname, f)).isDirectory();
});
(async searchString => {
const packages: Package[] = await getPackages(JSXSTYLE_ROOT);
const examplePkgs = packages.filter(f => f.name.endsWith('-example'));
const choices = examplePkgs.map(pkg => ({ name: pkg.name, value: pkg.name }));

if (command === 'init') {
for (const dir of exampleDirs) {
await npmCommand(dir, '--silent', 'install');
console.info('installed dependencies for %s', dir);
}
} else if (command === 'reset') {
for (const dir of exampleDirs) {
await fs.remove(path.join(__dirname, dir, 'node_modules'));
console.info('deleted node_modules for %s', dir);
}
} else if (!command) {
if (!searchString) {
const { example } = await inquirer.prompt([
{
choices: exampleDirs.map(name => ({ name, value: name })),
choices,
message: 'Pick an example',
name: 'example',
type: 'list',
},
]);
return npmCommand(example, 'start');
} else {
throw new Error('Unsupported command: ' + command);
const examplePkg = examplePkgs.find(pkg => pkg.name.includes(searchString));
if (!examplePkg) {
throw new Error('Could not find example matching "' + searchString + '"');
}
return npmCommand(examplePkg.name, 'start');
}
})
.apply(null, process.argv.slice(2))
Expand Down
4 changes: 2 additions & 2 deletions lerna.json
Expand Up @@ -4,12 +4,12 @@
"packages/*"
],
"version": "independent",
"commands": {
"command": {
"boostrap": {
"hoist": true
},
"publish": {
"ignore": [
"ignoreChanges": [
"**/*.md",
"**/package.json"
],
Expand Down
34 changes: 17 additions & 17 deletions package.json
Expand Up @@ -21,33 +21,33 @@
"update-readme": "echo \"$(<./misc/monorepo-preamble.md)\\n\\n---\\n\\n$(<./packages/jsxstyle/README.md)\" > README.md"
},
"dependencies": {
"@babel/core": "^7.1.0",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/plugin-transform-object-assign": "^7.0.0",
"@babel/preset-env": "^7.1.0",
"@babel/preset-react": "^7.0.0",
"@types/fs-extra": "^5.0.2",
"@types/invariant": "^2.2.29",
"@types/lodash": "^4.14.109",
"@types/node": "^10.3.4",
"@types/react": "^16.3.14",
"@types/webpack": "^4.4.0",
"@types/lodash": "^4.14.116",
"@types/node": "^10.10.1",
"@types/react": "^16.4.14",
"@types/webpack": "^4.4.12",
"@types/webpack-env": "^1.13.6",
"babel-core": "^6.26.0",
"babel-plugin-transform-object-assign": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"fs-extra": "^6.0.1",
"fs-extra": "^7.0.0",
"inquirer": "^6.0.0",
"lerna": "^2.11.0",
"lerna": "^3.4.0",
"preact": "^8.2.6",
"prettier": "^1.12.0",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"rimraf": "^2.6.2",
"rollup": "^0.61.0",
"rollup-plugin-typescript2": "^0.15.0",
"ts-node": "^7.0.0",
"tslint": "^5.9.1",
"tslint-config-prettier": "^1.12.0",
"rollup": "^0.66.1",
"rollup-plugin-typescript2": "^0.17.0",
"ts-node": "^7.0.1",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0",
"tslint-react": "^3.6.0",
"typescript": "^2.9.2"
"typescript": "^3.0.3"
},
"prettier": {
"singleQuote": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/jsxstyle-utils/package.json
Expand Up @@ -12,6 +12,6 @@
"jsxstyle"
],
"dependencies": {
"csstype": "^2.2.0"
"csstype": "^2.5.7"
}
}
8 changes: 4 additions & 4 deletions packages/jsxstyle-webpack-plugin/package.json
Expand Up @@ -15,16 +15,16 @@
"@babel/traverse": "^7.1.0",
"@babel/types": "^7.0.0",
"@types/loader-utils": "^1.1.3",
"@types/node": "^10.3.4",
"@types/webpack": "^4.4.0",
"ajv": "^6.5.0",
"@types/node": "^10.10.1",
"@types/webpack": "^4.4.12",
"ajv": "^6.5.3",
"invariant": "^2.2.1",
"jsxstyle": "^2.1.3",
"jsxstyle-utils": "^2.1.3",
"loader-utils": "^1.1.0"
},
"devDependencies": {
"webpack": ">=2 <5"
"webpack": "^4.19.1"
},
"peerDependencies": {
"webpack": ">=2 <5"
Expand Down
4 changes: 2 additions & 2 deletions tests/jsxstyle-webpack-plugin/webpack/webpack.config.ts
Expand Up @@ -40,8 +40,8 @@ config.module = {
options: {
babelrc: false,
presets: [
[require.resolve('babel-preset-env'), { modules: false }],
require.resolve('babel-preset-react'),
[require.resolve('@babel/preset-env'), { modules: false }],
require.resolve('@babel/preset-react'),
],
},
},
Expand Down
8 changes: 4 additions & 4 deletions tests/karma.conf.ts
Expand Up @@ -79,17 +79,17 @@ export default (config: KarmaConfig) => {
babelrc: false,
presets: [
[
'env',
'@babel/preset-env',
{
modules: false,
targets: { browsers: ['last 2 versions'] },
},
],
'react',
'@babel/preset-react',
],
plugins: [
'transform-object-rest-spread',
'transform-object-assign',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-transform-object-assign',
],
},
},
Expand Down
53 changes: 23 additions & 30 deletions tests/meta.spec.ts
@@ -1,43 +1,36 @@
import * as PackageUtilities from 'lerna/lib/PackageUtilities';
import * as Repository from 'lerna/lib/Repository';
import * as packlist from 'npm-packlist';
import { getPackages } from '@lerna/project';
import packlist from 'npm-packlist';
import * as path from 'path';
import { Dict } from '../packages/jsxstyle-utils';

// NOTE: this interface is incomplete
// See: @lerna/package
interface Package {
/** parsed contents of the package's package.json file */
_package: {
name: string;
private?: true;
version?: string;
main?: string;
scripts?: Dict<string>;
devDependencies?: Dict<string>;
dependencies?: Dict<string>;
};
/** absolute path to the package */
_location: string;
name: string;
location: string;
private: boolean;
toJSON: () => string;
}

// get all packages from Lerna
const JSXSTYLE_ROOT = path.resolve(__dirname, '..');
const repo = new Repository(JSXSTYLE_ROOT);
const packages: Package[] = PackageUtilities.getPackages(repo);
packages.sort((a, b) => a._package.name.localeCompare(b._package.name));

describe('npm publish', () => {
it('only publishes the intended files', async () => {
const pkgPromises = Promise.all(
packages.map(async pkg => {
const fileList = await packlist({ path: pkg._location });
return `
${pkg._package.name}
${pkg._package.name.replace(/./g, '=')}
const packages: Package[] = await getPackages(JSXSTYLE_ROOT);
const packagePromises = packages
// exclude private packages
.filter(pkg => !pkg.private)
.sort((a, b) => a.name.localeCompare(b.name))
.map(pkg =>
// fetch file list and format it into something
packlist({ path: pkg.location }).then(
fileList => `
${pkg.name}
${pkg.name.replace(/./g, '=')}
${fileList.map(f => `- ${f}`).join('\n')}
`;
})
);
`
)
);

await expect(pkgPromises).resolves.toMatchSnapshot();
await expect(Promise.all(packagePromises)).resolves.toMatchSnapshot();
});
});

0 comments on commit 28698ab

Please sign in to comment.