Skip to content

Commit 98b1bea

Browse files
committed
feat: add new expo action cli install concept
1 parent e72ddd8 commit 98b1bea

2,531 files changed

Lines changed: 1124450 additions & 3 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

action.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
---
22
name: Expo GitHub Action
33
author: Cedric van Putten <me@bycedric.com>
4-
description: Use Expo CLI in your GitHub Actions workflow.
4+
description: Expo CLI in your GitHub Actions workflow.
55
branding:
66
icon: terminal
77
color: gray-dark
88
runs:
9-
using: docker
10-
image: Dockerfile
9+
using: node12
10+
main: build/index.js
11+
input:
12+
expo-version:
13+
description: The Expo CLI version to install. (use any semver/dist-tag available)
14+
default: latest
15+
expo-username:
16+
description: Your Expo username, for authentication.
17+
expo-password:
18+
description: Your Expo password, for authentication. (use with secrets)
19+
expo-packager:
20+
description: The package manager used to install the Expo CLI. (can be yarn or npm)
21+
default: npm

build/expo.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"use strict";
2+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4+
return new (P || (P = Promise))(function (resolve, reject) {
5+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8+
step((generator = generator.apply(thisArg, _arguments || [])).next());
9+
});
10+
};
11+
var __importStar = (this && this.__importStar) || function (mod) {
12+
if (mod && mod.__esModule) return mod;
13+
var result = {};
14+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
15+
result["default"] = mod;
16+
return result;
17+
};
18+
Object.defineProperty(exports, "__esModule", { value: true });
19+
const core = __importStar(require("@actions/core"));
20+
const cli = __importStar(require("@actions/exec"));
21+
/**
22+
* Authenticate at Expo using `expo login`.
23+
* This step is required for publishing and building new apps.
24+
* It uses the `EXPO_CLI_PASSWORD` environment variable for improved security.
25+
*/
26+
function authenticate(username, password) {
27+
return __awaiter(this, void 0, void 0, function* () {
28+
if (!username || !password) {
29+
return core.debug('Skipping authentication, `expo-username` and/or `expo-password` not set...');
30+
}
31+
yield cli.exec('expo', ['login', `--username=${username}`], {
32+
env: Object.assign(Object.assign({}, process.env), { EXPO_CLI_PASSWORD: password }),
33+
});
34+
});
35+
}
36+
exports.authenticate = authenticate;

build/index.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"use strict";
2+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4+
return new (P || (P = Promise))(function (resolve, reject) {
5+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8+
step((generator = generator.apply(thisArg, _arguments || [])).next());
9+
});
10+
};
11+
var __importStar = (this && this.__importStar) || function (mod) {
12+
if (mod && mod.__esModule) return mod;
13+
var result = {};
14+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
15+
result["default"] = mod;
16+
return result;
17+
};
18+
Object.defineProperty(exports, "__esModule", { value: true });
19+
const core = __importStar(require("@actions/core"));
20+
const expo_1 = require("./expo");
21+
const install_1 = require("./install");
22+
function run() {
23+
return __awaiter(this, void 0, void 0, function* () {
24+
const path = yield install_1.install(core.getInput('expo-version') || 'latest', core.getInput('expo-packager') || 'npm');
25+
core.addPath(path);
26+
yield expo_1.authenticate(core.getInput('expo-username'), core.getInput('expo-password'));
27+
});
28+
}
29+
run();

build/install.js

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
"use strict";
2+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4+
return new (P || (P = Promise))(function (resolve, reject) {
5+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8+
step((generator = generator.apply(thisArg, _arguments || [])).next());
9+
});
10+
};
11+
var __importStar = (this && this.__importStar) || function (mod) {
12+
if (mod && mod.__esModule) return mod;
13+
var result = {};
14+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
15+
result["default"] = mod;
16+
return result;
17+
};
18+
Object.defineProperty(exports, "__esModule", { value: true });
19+
const cli = __importStar(require("@actions/exec"));
20+
const io = __importStar(require("@actions/io"));
21+
const cache = __importStar(require("@actions/tool-cache"));
22+
const path = __importStar(require("path"));
23+
const registry = require('libnpm');
24+
/**
25+
* Resolve the provided semver to exact version of `expo-cli`.
26+
* This uses the npm registry and accepts latest, dist-tags or version ranges.
27+
* It's used to determine the cached version of `expo-cli`.
28+
*/
29+
function resolve(version) {
30+
return __awaiter(this, void 0, void 0, function* () {
31+
return (yield registry.manifest(`expo-cli@${version}`)).version;
32+
});
33+
}
34+
exports.resolve = resolve;
35+
/**
36+
* Install `expo-cli`, by version, using the packager.
37+
* Here you can provide any semver range or dist tag used in the registry.
38+
* It returns the path where Expo is installed.
39+
*/
40+
function install(version, packager) {
41+
return __awaiter(this, void 0, void 0, function* () {
42+
const exact = yield resolve(version);
43+
let root = yield fromCache(exact);
44+
if (!root) {
45+
root = yield fromPackager(exact, packager);
46+
yield toCache(exact, root);
47+
}
48+
return path.join(root, 'node_modules', '.bin');
49+
});
50+
}
51+
exports.install = install;
52+
/**
53+
* Install `expo-cli`, by version, using npm or yarn.
54+
* It creates a temporary directory to store all required files.
55+
*/
56+
function fromPackager(version, packager) {
57+
return __awaiter(this, void 0, void 0, function* () {
58+
const root = process.env['RUNNER_TEMP'] || '';
59+
const tool = yield io.which(packager);
60+
yield io.mkdirP(root);
61+
yield cli.exec(tool, ['add', `expo-cli@${version}`], { cwd: root });
62+
return root;
63+
});
64+
}
65+
exports.fromPackager = fromPackager;
66+
/**
67+
* Get the path to the `expo-cli` from cache, if any.
68+
* Note, this cache is **NOT** shared between jobs.
69+
*
70+
* @see https://github.com/actions/toolkit/issues/47
71+
*/
72+
function fromCache(version) {
73+
return __awaiter(this, void 0, void 0, function* () {
74+
return cache.find('expo-cli', version);
75+
});
76+
}
77+
exports.fromCache = fromCache;
78+
/**
79+
* Store the root of `expo-cli` in the cache, for future reuse.
80+
* Note, this cache is **NOT** shared between jobs.
81+
*
82+
* @see https://github.com/actions/toolkit/issues/47
83+
*/
84+
function toCache(version, root) {
85+
return __awaiter(this, void 0, void 0, function* () {
86+
return cache.cacheDir(root, 'expo-cli', version);
87+
});
88+
}
89+
exports.toCache = toCache;

node_modules/.bin/JSONStream

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/mkdirp

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/node-gyp

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/nopt

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/rimraf

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/semver

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)