Skip to content

Commit

Permalink
Publishing automation start
Browse files Browse the repository at this point in the history
* Code is still plain js, but fully covered by typescript via jsdocs
* Refactor code to be more programatic
* Added utils function that can check if we need to build & publish new
version
* Added dummy circleci file
* Some vscode configs
  • Loading branch information
Bnaya committed Jun 16, 2019
1 parent 1818f5b commit c288177
Showing 17 changed files with 4,144 additions and 136 deletions.
56 changes: 56 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# this file still do nothing
version: 2

aliases:
- &docker
- image: circleci/node:dubnium

- &environment
TZ: /usr/share/zoneinfo/America/Los_Angeles

- &restore_yarn_cache
restore_cache:
name: Restore node_modules cache
keys:
- v1-node-{{ arch }}-{{ .Branch }}-{{ checksum "yarn.lock" }}
- v1-node-{{ arch }}-{{ .Branch }}-
- v1-node-{{ arch }}-
- &run_yarn
run:
name: Install Packages
command: yarn --frozen-lockfile

orbs:
node: circleci/node@1.0.1

jobs:
setup:
docker: *docker
environment: *environment

steps:
- checkout
- run:
name: Nodejs Version
command: node --version
- *restore_yarn_cache
- *run_yarn
- save_cache:
name: Save node_modules cache
key: v1-node-{{ arch }}-{{ .Branch }}-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn

# workflows:
# version: 2
# nightly:
# triggers:
# - schedule:
# # every 10 minutes
# cron: "*/10 * * * *"
# filters:
# branches:
# only:
# - master
# jobs:
# - should-publish
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
node_modules
target
yarn-error.log
yarn-error.log
auto-publish/staging-area
auto-publish/staging-area-for-test
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/Dubnium
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["orta.vscode-jest", "editorconfig.editorconfig", "orta.vscode-jest"]
}
10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"typescript.tsdk": "node_modules/typescript/lib",
"debug.node.autoAttach": "on",
"jest.debugMode": false,
"jest.autoEnable": false,
"jest.enableCodeLens": true,
"jest.enableInlineErrorMessages": true,
"jest.runAllTestsFirst": true,
"jest.debugCodeLens.showWhenTestStateIn": ["fail", "unknown", "pass", "skip"],
}
61 changes: 61 additions & 0 deletions auto-publish/__snapshots__/utils.spec.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Auto publish utils doesReactDOMHasNewerVersionThanUs - no! RC is ready: Correct params passed to execFile 1`] = `
[MockFunction] {
"calls": Array [
Array [
"yarn",
Array [
"info",
"@hot-loader/react-dom",
"--json",
],
Object {
"cwd": undefined,
"timeout": 2000,
},
[Function],
],
Array [
"yarn",
Array [
"info",
"@hot-loader/react-dom",
"--json",
],
Object {
"cwd": undefined,
"timeout": 2000,
},
[Function],
],
Array [
"yarn",
Array [
"info",
"react-dom",
"--json",
],
Object {
"cwd": undefined,
"timeout": 2000,
},
[Function],
],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
Object {
"type": "return",
"value": undefined,
},
Object {
"type": "return",
"value": undefined,
},
],
}
`;
10 changes: 10 additions & 0 deletions auto-publish/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const path = require("path");
const fs = require("fs-extra");
const { getAndPatchGivenReactDOMVersion } = require("./utils");

(async () => {
const targetDir = await getAndPatchGivenReactDOMVersion(path.resolve(__dirname, "staging-area"), "16.8.6");
await fs.copy(targetDir, path.resolve(__dirname, "../target"))

console.log("Done!");
})();
3 changes: 3 additions & 0 deletions auto-publish/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const fs = require("fs-extra");


82 changes: 82 additions & 0 deletions auto-publish/interfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
export interface yarnInfoJsonResponse {
type: "inspect";
data: {
name: string;
"dist-tags": Partial<{
[k: string]: string
}>;
versions: string[];
time: { [key: string]: string };
maintainers: Array<{
name: string;
email: string;
}>;
description: string;
homepage: string;
repository: {
type: string;
url: string;
};
bugs: {
url: string;
};
license: string;
readmeFilename: string;
keywords: string[];
version: string;
};
/*
example data:
{
"type": "inspect",
"data": {
"name": "@hot-loader/react-dom",
"dist-tags": { "latest": "16.8.6" },
"versions": [
"16.7.0-alpha.2",
"16.7.0-alpha.2.1",
"16.7.0-alpha.2.2",
"16.7.0-alpha.2.3",
"16.7.0-alpha.2.4",
"16.7.0",
"16.8.0-alpha.0",
"16.8.1",
"16.8.2",
"16.8.3",
"16.8.4",
"16.8.5",
"16.8.6"
],
"time": {
"created": "2018-11-21T10:47:51.342Z",
"16.7.0-alpha.2": "2018-11-21T10:47:51.742Z",
"modified": "2019-03-28T09:32:10.123Z",
"16.7.0-alpha.2.1": "2018-11-21T21:35:44.318Z",
"16.7.0-alpha.2.2": "2018-12-07T12:21:53.582Z",
"16.7.0-alpha.2.3": "2018-12-17T06:55:29.788Z",
"16.7.0-alpha.2.4": "2018-12-19T09:23:40.548Z",
"16.7.0": "2018-12-20T09:22:04.981Z",
"16.8.0-alpha.0": "2019-01-10T04:39:04.893Z",
"16.8.1": "2019-02-07T00:17:32.764Z",
"16.8.2": "2019-02-18T21:58:30.554Z",
"16.8.3": "2019-02-25T21:15:23.701Z",
"16.8.4": "2019-03-07T09:04:23.315Z",
"16.8.5": "2019-03-25T11:19:27.329Z",
"16.8.6": "2019-03-28T09:32:06.816Z"
},
"maintainers": [{ "name": "kashey", "email": "thekashey@gmail.com" }],
"description": "The Hot version of React-DOM",
"homepage": "https://github.com/hot-loader/react-dom#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/hot-loader/react-dom.git"
},
"bugs": { "url": "https://github.com/hot-loader/react-dom/issues" },
"license": "MIT",
"readmeFilename": "README.md",
"keywords": ["HMR", "react", "hot-loader"],
"version": "latest"
}
}
*/
}
Loading

0 comments on commit c288177

Please sign in to comment.