Skip to content

Commit

Permalink
chore(dist): simplify release process
Browse files Browse the repository at this point in the history
  • Loading branch information
bigopon committed Jul 8, 2021
1 parent c358658 commit 8f930fa
Show file tree
Hide file tree
Showing 22 changed files with 259 additions and 71 deletions.
85 changes: 42 additions & 43 deletions .circleci/config.yml
Expand Up @@ -281,7 +281,6 @@ jobs:
steps:
- run: git checkout << parameters.branch >>
- run: git pull
- run: sudo npm i -g ts-node @types/node
- run:
name: "Authenticate with registry"
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
Expand Down Expand Up @@ -404,20 +403,20 @@ workflows:
# Triggered by push to master or topic branches
build_test:
jobs:
# - unit_test_esm:
# <<: *filter_ignore_develop_release
# name: unit_test_esm_chrome
# npm_command: "test-chrome"
# - unit_test_esm:
# <<: *filter_ignore_develop_release
# name: unit_test_esm_firefox
# npm_command: "test-firefox"
# coverage: false
# - unit_test_esm:
# <<: *filter_ignore_develop_release
# name: unit_test_esm_node
# npm_command: "test-node"
# coverage: false
- unit_test_esm:
<<: *filter_ignore_develop_release
name: unit_test_esm_chrome
npm_command: "test-chrome"
- unit_test_esm:
<<: *filter_ignore_develop_release
name: unit_test_esm_firefox
npm_command: "test-firefox"
coverage: false
- unit_test_esm:
<<: *filter_ignore_develop_release
name: unit_test_esm_node
npm_command: "test-node"
coverage: false
- unit_test_cjs:
<<: *filter_ignore_develop_release
npm_command: "test-node"
Expand All @@ -427,34 +426,34 @@ workflows:
# npm_command: "test-262"
# coverage: false
# submodules: true
# - lint_packages:
# <<: *filter_ignore_develop_release
# - benchmark_playwright:
# <<: *filter_ignore_develop_release
# - e2e_playwright:
# <<: *filter_ignore_develop_release
# name: jit-webpack-conventions-ts
# path: "examples/jit-webpack-conventions-ts"
# requires:
# - lint_packages # not a real requirement but forces long-running jobs to go first
# - e2e_playwright:
# <<: *filter_ignore_develop_release
# name: jit-webpack-vanilla-ts
# path: "examples/jit-webpack-vanilla-ts"
# requires:
# - lint_packages # not a real requirement but forces long-running jobs to go first
- lint_packages:
<<: *filter_ignore_develop_release
- benchmark_playwright:
<<: *filter_ignore_develop_release
- e2e_playwright:
<<: *filter_ignore_develop_release
name: jit-webpack-conventions-ts
path: "examples/jit-webpack-conventions-ts"
requires:
- lint_packages # not a real requirement but forces long-running jobs to go first
- e2e_playwright:
<<: *filter_ignore_develop_release
name: jit-webpack-vanilla-ts
path: "examples/jit-webpack-vanilla-ts"
requires:
- lint_packages # not a real requirement but forces long-running jobs to go first
- merge_and_dist:
<<: *filter_only_master
name: merge_and_dist_master
requires:
# - unit_test_esm_chrome
# - unit_test_esm_firefox
# - unit_test_esm_node
- unit_test_esm_chrome
- unit_test_esm_firefox
- unit_test_esm_node
- unit_test_cjs
#- test_test262
# - lint_packages
# - jit-webpack-conventions-ts
# - jit-webpack-vanilla-ts
- lint_packages
- jit-webpack-conventions-ts
- jit-webpack-vanilla-ts
from: master
to: develop
channel: dev
Expand All @@ -464,13 +463,13 @@ workflows:
<<: *filter_only_topic
name: merge_and_dist_topic
requires:
# - unit_test_esm_chrome
# - unit_test_esm_firefox
# - unit_test_esm_node
- unit_test_esm_chrome
- unit_test_esm_firefox
- unit_test_esm_node
- unit_test_cjs
# - lint_packages
# - jit-webpack-conventions-ts
# - jit-webpack-vanilla-ts
- lint_packages
- jit-webpack-conventions-ts
- jit-webpack-vanilla-ts
from: master
to: develop
channel: dev
Expand Down
2 changes: 1 addition & 1 deletion examples/1kcomponents/package.json
Expand Up @@ -9,7 +9,7 @@
"version": "0.8.0",
"scripts": {
"build": "webpack --config webpack.config.js",
"serve": "node ../../node_modules/@aurelia/http-server/dist/bundle/cli.js au.conf.js"
"serve": "node ../../node_modules/@aurelia/http-server/dist/esm/cli.js au.conf.js"
},
"dependencies": {
"@aurelia/kernel": "2.0.0-alpha.10",
Expand Down
4 changes: 2 additions & 2 deletions examples/doc-example/package.json
Expand Up @@ -35,8 +35,8 @@
"start": "webpack-dev-server",
"build": "rimraf dist && webpack --mode=production",
"watch": "webpack-dev-server",
"serve": "node ./node_modules/@aurelia/http-server/dist/bundle/cli.js au.conf.js",
"build-serve": "rimraf dist && webpack --mode=production && node ./node_modules/@aurelia/http-server/dist/bundle/cli.js au.conf.js",
"serve": "node ./node_modules/@aurelia/http-server/dist/esm/cli.js au.conf.js",
"build-serve": "rimraf dist && webpack --mode=production && node ./node_modules/@aurelia/http-server/dist/esm/cli.js au.conf.js",
"now": "rimraf dist && webpack --config webpack.config.js && cd dist && now && cd .."
},
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion examples/fractals-tree/package.json
Expand Up @@ -9,7 +9,7 @@
"version": "0.8.0",
"scripts": {
"build": "webpack --config webpack.config.js",
"serve": "node ../../node_modules/@aurelia/http-server/dist/bundle/cli.js au.conf.js"
"serve": "node ../../node_modules/@aurelia/http-server/dist/esm/cli.js au.conf.js"
},
"dependencies": {
"@aurelia/kernel": "2.0.0-alpha.10",
Expand Down
4 changes: 2 additions & 2 deletions examples/navigation-skeleton/package.json
Expand Up @@ -5,8 +5,8 @@
"scripts": {
"watch": "webpack-dev-server",
"build": "rimraf dist && webpack --config webpack.config.js",
"serve": "node ./node_modules/@aurelia/http-server/dist/bundle/cli.js au.conf.js",
"build-serve": "rimraf dist && webpack --config webpack.config.js && node ./node_modules/@aurelia/http-server/dist/bundle/cli.js au.conf.js",
"serve": "node ./node_modules/@aurelia/http-server/dist/esm/cli.js au.conf.js",
"build-serve": "rimraf dist && webpack --config webpack.config.js && node ./node_modules/@aurelia/http-server/dist/esm/cli.js au.conf.js",
"now": "rimraf dist && webpack --config webpack.config.js && cd dist && now && cd .."
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/rainbow-spiral/package.json
Expand Up @@ -9,7 +9,7 @@
"version": "0.8.0",
"scripts": {
"build": "webpack --config webpack.config.js",
"serve": "node ../../node_modules/@aurelia/http-server/dist/bundle/cli.js au.conf.js"
"serve": "node ../../node_modules/@aurelia/http-server/dist/esm/cli.js au.conf.js"
},
"dependencies": {
"@aurelia/kernel": "2.0.0-alpha.10",
Expand Down
2 changes: 1 addition & 1 deletion examples/sierpinski-triangle/package.json
Expand Up @@ -9,7 +9,7 @@
"version": "0.8.0",
"scripts": {
"build": "webpack --config webpack.config.js",
"serve": "node ../../node_modules/@aurelia/http-server/dist/bundle/cli.js au.conf.js"
"serve": "node ../../node_modules/@aurelia/http-server/dist/esm/cli.js au.conf.js"
},
"dependencies": {
"@aurelia/kernel": "2.0.0-alpha.10",
Expand Down
5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -61,6 +61,7 @@
"build:release": "lage run build --scope aurelia --scope au --scope @aurelia/a* --scope @aurelia/b* --scope @aurelia/f* --scope @aurelia/h* --scope @aurelia/i* --scope @aurelia/k* --scope @aurelia/m* --scope @aurelia/p* --scope @aurelia/r* --scope @aurelia/s* --scope @aurelia/t* --scope @aurelia/v* --scope @aurelia/w* --no-cache --verbose --no-deps",
"postbuild:release": "npm run clean:tsconfig-build-cache",
"build:release:full": "npm run build:release && npm run change-tsconfigs:invert && npm run build:release && npm run change-tsconfigs:restore",
"build:release-script": "tsc --project scripts/tsconfig.release-script.json",
"change-package-refs:dev": "ts-node -P tsconfig.json scripts/change-package-refs.ts dev",
"change-package-refs:release": "ts-node -P tsconfig.json scripts/change-package-refs.ts release",
"clean": "rimraf dist packages/*/dist packages-cjs/*/dist test/*/dist test/benchmarking-apps/*/dist examples/*/dist",
Expand All @@ -76,8 +77,8 @@
"change-tsconfigs:restore": "ts-node -P tsconfig.json scripts/change-tsconfigs.ts restore",
"prepare-release": "ts-node -P tsconfig.json scripts/prepare-release.ts",
"generate-native-modules": "ts-node -P tsconfig.json scripts/generate-native-modules.ts",
"publish:dev": "ts-node -P tsconfig.json scripts/publish.ts dev --transpile-only",
"publish:latest": "ts-node -P tsconfig.json scripts/publish.ts latest --transpile-only",
"publish:dev": "node scripts/publish.js dev",
"publish:latest": "node scripts/publish.js latest",
"bump-version:dev": "ts-node -P tsconfig.json scripts/bump-version.ts dev",
"bump-version:latest": "ts-node -P tsconfig.json scripts/bump-version.ts latest",
"check-dependencies": "ts-node -P tsconfig.json scripts/check-dependencies.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/http-server/bin/cli.js
@@ -1,4 +1,4 @@
#!/usr/bin/env node
/* eslint-disable import/extensions */

import '../dist/bundle/cli.js';
import '../dist/esm/cli.js';
2 changes: 1 addition & 1 deletion packages/http-server/rollup.config.js
Expand Up @@ -29,7 +29,7 @@ export default [
external: Object.keys(pkg.dependencies).concat('os', 'path', 'fs', 'http', 'https', 'http2', 'url', 'stream'),
output: [
{
file: 'dist/bundle/cli.js',
file: 'dist/esm/cli.js',
format: 'es',
sourcemap: true
},
Expand Down
6 changes: 2 additions & 4 deletions scripts/generate-native-modules.ts
Expand Up @@ -3,12 +3,12 @@
// example:
// import {} from '@aurelia/kernel'
// ->
// import {} from '../../kernel/dist/bundle/index.js'
// import {} from '../../kernel/dist/esm/index.js'
// this works with CDN well, though it wouldn't have the proper sourcemap
// todo: consider make this step part of the rollup build
// ------------------------
import * as ts from 'typescript';
import { File, getFiles } from './files';
import { getFiles } from './files';
import { createLogger } from './logger';
import project from './project';
import * as path from 'path';
Expand All @@ -21,9 +21,7 @@ const log = createLogger('generate-native-modules');

for (const pkg of packages) {
const distPath = path.join(pkg.path, 'dist');
// old bundling code:
const esmPath = path.join(distPath, 'esm');
// const bundlePath = path.join(distPath, 'bundle');
const nativeModulesPath = path.join(distPath, 'native-modules');

log.info(`Processing '${esmPath}'`);
Expand Down
51 changes: 51 additions & 0 deletions scripts/package.json.js
@@ -0,0 +1,51 @@
/* eslint-disable */
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.savePackageJson = exports.loadPackageJson = void 0;
const fs_1 = require("fs");
const path_1 = require("path");
const project_1 = __importDefault(require("./project"));
/**
* Reads and parses the content of a package.json file
*
* @param pathSegments - The path segments of the folder where the package.json is located, relative to the root of the project
*/
async function loadPackageJson(...pathSegments) {
const path = path_1.join(project_1.default.path, ...pathSegments, 'package.json');
return new Promise((resolve, reject) => {
fs_1.readFile(path, (err, data) => {
if (err) {
reject(err);
}
if (!data) {
throw new Error(`Empty file: ${path}`);
}
const str = data.toString('utf8');
const json = JSON.parse(str);
resolve(json);
});
});
}
exports.loadPackageJson = loadPackageJson;
/**
* Stringifies and writes out the content of a package.json file
*
* @param pkg - The package.json as an object
* @param pathSegments - The path segments of the folder where the package.json is located, relative to the root of the project
*/
async function savePackageJson(pkg, ...pathSegments) {
const path = path_1.join(project_1.default.path, ...pathSegments, 'package.json');
return new Promise((resolve, reject) => {
const str = JSON.stringify(pkg, null, 2);
fs_1.writeFile(path, str, { encoding: 'utf8' }, (err) => {
if (err) {
reject(err);
}
resolve();
});
});
}
exports.savePackageJson = savePackageJson;
1 change: 0 additions & 1 deletion scripts/package.json.ts
@@ -1,4 +1,3 @@
// @ts-nocheck
import { readFile, writeFile } from 'fs';
import { join } from 'path';
import project from './project';
Expand Down
101 changes: 101 additions & 0 deletions scripts/project.js
@@ -0,0 +1,101 @@
/* eslint-disable */
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = require("path");
const packageJson = __importStar(require("../package.json"));
// TODO: generate this file automatically
const rootPath = process.cwd();
const testApps = [
'jit-webpack-conventions-ts',
'jit-webpack-vanilla-ts'
];
function camelCase(input) {
const parts = input.split('-');
return `${parts[0]}${parts.slice(1).map(x => `${x[0].toUpperCase()}${x.slice(1)}`).join('')}`;
}
exports.default = {
'path': rootPath,
'pkg': packageJson,
'.circleci': {
'path': path_1.join(rootPath, '.circleci')
},
'.vscode': {
'path': path_1.join(rootPath, '.vscode')
},
'changelog': {
'path': path_1.join(rootPath, 'docs', 'CHANGELOG.md')
},
'coverage': {
'path': path_1.join(rootPath, 'coverage')
},
'dist': {
'path': path_1.join(rootPath, 'dist')
},
'docs': {
'path': path_1.join(rootPath, 'docs')
},
'examples': testApps.reduce((acc, app) => {
acc[app] = {
'path': path_1.join(rootPath, 'examples', app)
};
return acc;
}, {}),
'node_modules': {
'path': path_1.join(rootPath, 'node_modules')
},
'packages': packageJson.workspaces.map(p => {
const parts = p.split('/');
const kebabName = parts[parts.length - 1];
const camelName = camelCase(kebabName);
const folder = parts.slice(0, -1).join('/');
const path = path_1.join(rootPath, p);
const nodeModules = path_1.join(path, 'node_modules');
const coverage = path_1.join(rootPath, 'coverage', kebabName);
const tsconfig = path_1.join(path, 'tsconfig.json');
const changelog = path_1.join(path, 'CHANGELOG.md');
const srcPath = path_1.join(path, 'src');
const src = {
path: srcPath,
entry: path_1.join(srcPath, 'index.ts'),
};
const name = {
kebab: kebabName,
camel: camelName,
npm: kebabName === 'aurelia'
? 'aurelia'
: kebabName === 'au'
? 'au'
: `@aurelia/${kebabName}`
};
return { path, folder, nodeModules, coverage, tsconfig, changelog, src, name };
}),
'scripts': {
'path': path_1.join(rootPath, 'scripts'),
'tsconfig.test': path_1.join(rootPath, 'scripts', 'tsconfig.test.json')
},
'test': {
'path': path_1.join(rootPath, 'test'),
},
'package.json': {
'path': path_1.join(rootPath, 'package.json')
},
};

0 comments on commit 8f930fa

Please sign in to comment.