Skip to content

Commit

Permalink
Iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
Bnaya committed Jul 7, 2019
1 parent c288177 commit 9797a1d
Show file tree
Hide file tree
Showing 13 changed files with 346 additions and 545 deletions.
99 changes: 53 additions & 46 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,63 @@
# 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
sanity_check:
working_directory: ~/project
docker:
- image: circleci/node:10
steps:
- checkout
- restore_cache:
name: Restore Yarn Package Cache
keys:
- yarn-packages-{{ checksum "yarn.lock" }}
- run:
name: Install Dependencies
command: yarn install --frozen-lockfile
- save_cache:
name: Save Yarn Package Cache
key: yarn-packages-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn
- run:
name: Run Tests
command: yarn test

publish_if_needed:
working_directory: ~/project
docker:
- image: circleci/node:10
steps:
- checkout
- restore_cache:
name: Restore Yarn Package Cache
keys:
- yarn-packages-{{ checksum "yarn.lock" }}
- run:
name: Nodejs Version
command: node --version
- *restore_yarn_cache
- *run_yarn
name: Install Dependencies
command: yarn install --frozen-lockfile
- save_cache:
name: Save node_modules cache
key: v1-node-{{ arch }}-{{ .Branch }}-{{ checksum "yarn.lock" }}
name: Save Yarn Package Cache
key: yarn-packages-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn
- run:
name: Run Tests
command: node auto-publish/index.js

workflows:
version: 2

for_every_push:
jobs:
- sanity_check

# workflows:
# version: 2
# nightly:
# triggers:
# - schedule:
# # every 10 minutes
# cron: "*/10 * * * *"
# filters:
# branches:
# only:
# - master
# jobs:
# - should-publish
publish_if_needed:
triggers:
- schedule:
cron: "0,30 * * * *"
filters:
branches:
only:
- publishing-automation
jobs:
- publish_if_needed
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
1 change: 1 addition & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry "https://registry.npmjs.org"
61 changes: 0 additions & 61 deletions auto-publish/__snapshots__/utils.spec.js.snap

This file was deleted.

6 changes: 3 additions & 3 deletions auto-publish/build.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const path = require("path");
const fs = require("fs-extra");
const { getAndPatchGivenReactDOMVersion } = require("./utils");
const { getAndPatchGivenReactDOMVersionWithGivenRHLVersion } = require("./utils");

(async () => {
const targetDir = await getAndPatchGivenReactDOMVersion(path.resolve(__dirname, "staging-area"), "16.8.6");
const targetDir = await getAndPatchGivenReactDOMVersionWithGivenRHLVersion(path.resolve(__dirname, "staging-area"), "16.8.6", "4.12.3", "@hot-loader/react-dom");
await fs.copy(targetDir, path.resolve(__dirname, "../target"))

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

// test with https://github.com/verdaccio/verdaccio ???

(async () => {
const ourDistTag = "latest";

// TODO: cover more dist tags
const answer = await doesReactDOMOrHotLoaderHasNewerVersionThanUs(
"latest",
"latest",
"test-org-bnaya-2",
"_rc"
);

if (answer) {
console.info("Going to publish!", answer)
if (
answer.reactDOMVersion === null ||
answer.reactHotLoaderVersion === null
) {
throw new Error("Versions to publish by can't be null");
}

const patchedPackageDir = await getAndPatchGivenReactDOMVersionWithGivenRHLVersion(
path.resolve(__dirname, "staging-area"),
answer.reactDOMVersion,
answer.reactHotLoaderVersion,
"test-org-bnaya-2"
);

console.info("don't really publish yet", { patchedPackageDir });

// const publishStdOut = await execFile(
// "yarn",
// [
// "publish",
// "--tag",
// ourDistTag + "_rc",
// "-y",
// "--access",
// "public",
// "--json"
// ],
// patchedPackageDir,
// 10000
// );

// console.info("Done publishing!", { publishStdOut });
} else {
console.info("Nothing to publish");
}
})();
Loading

0 comments on commit 9797a1d

Please sign in to comment.