1
0
Fork 0
mirror of https://github.com/subosito/flutter-action.git synced 2024-08-16 10:19:50 +02:00

remove unused files

This commit is contained in:
Alif Rachmawadi 2022-01-06 09:22:58 +00:00
parent 37e2edb15e
commit f5fec4dcb7
No known key found for this signature in database
GPG key ID: DD1F490C879BFA91
13 changed files with 0 additions and 25949 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,76 +0,0 @@
import io = require('@actions/io');
import exec = require('@actions/exec');
import fs = require('fs');
import path = require('path');
import nock = require('nock');
const toolDir = path.join(__dirname, 'runner', 'tools');
const tempDir = path.join(__dirname, 'runner', 'temp');
const dataDir = path.join(__dirname, 'data');
process.env['RUNNER_TOOL_CACHE'] = toolDir;
process.env['RUNNER_TEMP'] = tempDir;
import * as installer from '../src/installer';
import * as release from '../src/release';
describe('installer tests', () => {
beforeAll(async () => {
await io.rmRF(toolDir);
await io.rmRF(tempDir);
}, 100000);
beforeEach(() => {
const platform = release.getPlatform();
nock('https://storage.googleapis.com', {allowUnmocked: true})
.get(`/flutter_infra_release/releases/releases_${platform}.json`)
.replyWithFile(200, path.join(dataDir, `releases_${platform}.json`));
});
afterEach(async () => {
nock.cleanAll();
nock.enableNetConnect();
await io.rmRF(toolDir);
await io.rmRF(tempDir);
}, 100000);
it('Downloads flutter', async () => {
await installer.getFlutter('2.0.0', 'stable');
const sdkDir = path.join(toolDir, 'flutter', '2.0.0-stable', 'x64');
expect(fs.existsSync(`${sdkDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(sdkDir, 'bin'))).toBe(true);
}, 300000);
it('Downloads flutter from master channel', async () => {
await installer.getFlutter('', 'master');
const sdkDir = path.join(toolDir, 'flutter', 'master', 'x64');
let stdout = '';
const options = {
listeners: {
stdout: (data: Buffer) => {
stdout += data.toString();
}
}
};
expect(fs.existsSync(`${sdkDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(sdkDir, 'bin'))).toBe(true);
await exec.exec(path.join(sdkDir, 'bin', 'flutter'), ['channel'], options);
expect(stdout).toContain('* master');
}, 300000);
it('Throws if no location contains correct flutter version', async () => {
let thrown = false;
try {
await installer.getFlutter('1000.0', 'dev');
} catch {
thrown = true;
}
expect(thrown).toBe(true);
});
});

View file

@ -1,145 +0,0 @@
import fs = require('fs');
import path = require('path');
import nock = require('nock');
import * as release from '../src/release';
const platform = release.getPlatform();
describe('release tests', () => {
it('getPlatform', () => {
const platformMap: {[index: string]: string} = {
linux: 'linux',
darwin: 'macos',
win32: 'windows'
};
expect(platform).toEqual(platformMap[process.platform]);
});
describe('determineVersion', () => {
beforeEach(() => {
const dataDir = path.join(__dirname, 'data');
nock('https://storage.googleapis.com', {allowUnmocked: true})
.get(`/flutter_infra_release/releases/releases_${platform}.json`)
.replyWithFile(200, path.join(dataDir, `releases_${platform}.json`));
});
afterEach(() => {
nock.cleanAll();
nock.enableNetConnect();
});
it('channel: "stable", version: ""', async () => {
const result = await release.determineVersion('', 'stable', platform);
expect(result.version).toEqual('2.0.5');
expect(result.rawVersion).toEqual('2.0.5');
expect(result.downloadUrl).toContain('2.0.5');
});
it('channel: "beta", version: ""', async () => {
const result = await release.determineVersion('', 'beta', platform);
expect(result.version).toEqual('2.2.0-10.1.pre');
expect(result.rawVersion).toEqual('2.2.0-10.1.pre');
expect(result.downloadUrl).toContain('2.2.0-10.1.pre');
});
it('channel: "dev", version: ""', async () => {
const result = await release.determineVersion('', 'dev', platform);
expect(result.version).toEqual('2.2.0-10.1.pre');
expect(result.rawVersion).toEqual('2.2.0-10.1.pre');
expect(result.downloadUrl).toContain('2.2.0-10.1.pre');
});
it('channel: "dev", version: "1.17.x"', async () => {
const result = await release.determineVersion('1.17.x', 'dev', platform);
expect(result.version).toEqual('1.17.0-dev.5.0');
expect(result.rawVersion).toEqual('1.17.0-dev.5.0');
expect(result.downloadUrl).toContain('1.17.0-dev.5.0');
});
it('channel: "dev", version: "1.17"', async () => {
const result = await release.determineVersion('1.17', 'dev', platform);
expect(result.version).toEqual('1.17.0-dev.5.0');
expect(result.rawVersion).toEqual('1.17.0-dev.5.0');
expect(result.downloadUrl).toContain('1.17.0-dev.5.0');
});
it('channel: "dev", version: "1.7.x" (old format)', async () => {
const result = await release.determineVersion('1.7.x', 'dev', platform);
expect(result.version).toEqual('1.7.11');
expect(result.rawVersion).toEqual('v1.7.11');
expect(result.downloadUrl).toContain('v1.7.11');
});
it('channel: "dev", version: "1.7" (old format)', async () => {
const result = await release.determineVersion('1.7', 'dev', platform);
expect(result.version).toEqual('1.7.11');
expect(result.rawVersion).toEqual('v1.7.11');
expect(result.downloadUrl).toContain('v1.7.11');
});
it('channel: "dev", version: "0.12.x" (unknown)', async () => {
try {
await release.determineVersion('0.12.x', 'dev', platform);
} catch (e) {
expect(e.message).toEqual('unable to find release for 0.12.x');
}
});
it('channel: "dev", version: "0.12" (unknown)', async () => {
try {
await release.determineVersion('0.12', 'dev', platform);
} catch (e) {
expect(e.message).toEqual('unable to find release for 0.12');
}
});
it('channel: "dev", version: "1.17.0-dev.5.0"', async () => {
const result = await release.determineVersion(
'1.17.0-dev.5.0',
'dev',
platform
);
expect(result.version).toEqual('1.17.0-dev.5.0');
expect(result.rawVersion).toEqual('1.17.0-dev.5.0');
expect(result.downloadUrl).toContain('1.17.0-dev.5.0');
});
it('channel: "any", version: "1.17.x"', async () => {
const result = await release.determineVersion('1.17.x', 'any', platform);
expect(result.version).toEqual('1.17.5');
expect(result.rawVersion).toEqual('1.17.5');
expect(result.downloadUrl).toContain('1.17.5');
});
it('channel: "any", version: "1.19.x"', async () => {
const result = await release.determineVersion('1.19.x', 'any', platform);
expect(result.version).toEqual('1.19.0-5.0.pre');
expect(result.rawVersion).toEqual('1.19.0-5.0.pre');
expect(result.downloadUrl).toContain('1.19.0-5.0.pre');
});
it('channel: "any", version: "1.19.0-4.x"', async () => {
const result = await release.determineVersion(
'1.19.0-4.x',
'any',
platform
);
expect(result.version).toEqual('1.19.0-4.3.pre');
expect(result.rawVersion).toEqual('1.19.0-4.3.pre');
expect(result.downloadUrl).toContain('1.19.0-4.3.pre');
});
});
});

8797
dist/index.js vendored

File diff suppressed because it is too large Load diff

View file

@ -1,11 +0,0 @@
module.exports = {
clearMocks: true,
moduleFileExtensions: ['js', 'ts'],
testEnvironment: 'node',
testMatch: ['**/*.test.ts'],
testRunner: 'jest-circus/runner',
transform: {
'^.+\\.ts$': 'ts-jest'
},
verbose: true
}

6500
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,53 +0,0 @@
{
"name": "flutter-action",
"version": "1.3.2",
"private": true,
"description": "Flutter environment for use in actions",
"main": "lib/index.js",
"scripts": {
"build-tsc": "tsc",
"build-ncc": "ncc build",
"build": "run-s build-tsc build-ncc",
"format": "prettier --write **/*.ts",
"format-check": "prettier --check **/*.ts",
"test": "jest"
},
"repository": {
"type": "git",
"url": "git+https://github.com/subosito/flutter-action.git"
},
"keywords": [
"actions",
"node",
"flutter",
"setup"
],
"author": "Alif Rachmawadi <arch@subosito.com>",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.4.0",
"@actions/exec": "^1.1.0",
"@actions/http-client": "^1.0.11",
"@actions/io": "^1.1.1",
"@actions/tool-cache": "^1.7.1",
"semver": "^7.3.5",
"uuid": "^8.3.2"
},
"devDependencies": {
"@types/jest": "^26.0.23",
"@types/node": "^14.17.3",
"@types/semver": "^7.3.6",
"@types/uuid": "^8.3.0",
"@vercel/ncc": "^0.28.6",
"jest": "^26.6.3",
"jest-circus": "^26.6.3",
"nock": "^13.1.0",
"npm-run-all": "^4.1.5",
"prettier": "1.19.1",
"ts-jest": "^26.5.6",
"typescript": "^4.3.2"
},
"resolutions": {
"minimist": "^1.2.2"
}
}

View file

@ -1,23 +0,0 @@
import * as core from '@actions/core';
import * as installer from './installer';
async function run() {
try {
const version = core.getInput('flutter-version') || '';
const channel = core.getInput('channel') || 'stable';
if (channel == 'master' && version != '') {
core.setFailed(
'using `flutter-version` with master channel is not supported.'
);
return;
}
await installer.getFlutter(version, channel);
} catch (error) {
core.setFailed(error.message);
}
}
run();

View file

@ -1,128 +0,0 @@
import * as core from '@actions/core';
import * as io from '@actions/io';
import * as exec from '@actions/exec';
import * as tc from '@actions/tool-cache';
import * as fs from 'fs';
import * as path from 'path';
import * as release from './release';
export async function getFlutter(
version: string,
channel: string
): Promise<void> {
const platform = release.getPlatform();
const useMaster = channel == 'master';
const {
version: selected,
downloadUrl,
channel: validatedChannel
} = await release.determineVersion(
version,
useMaster ? 'dev' : channel,
platform
);
if (!useMaster && channel !== validatedChannel) {
core.debug(`Channel was identified as ${validatedChannel}`);
}
let cleanver = useMaster
? channel
: `${selected.replace('+', '-')}-${validatedChannel}`;
let toolPath = tc.find('flutter', cleanver);
if (toolPath) {
core.debug(`Tool found in cache ${toolPath}`);
} else {
core.debug(`Downloading Flutter from Google storage ${downloadUrl}`);
const sdkFile = await tc.downloadTool(downloadUrl);
const sdkCache = await tmpDir(platform);
const sdkDir = await extract(sdkFile, sdkCache, path.basename(downloadUrl));
toolPath = await tc.cacheDir(sdkDir, 'flutter', cleanver);
}
core.exportVariable('FLUTTER_ROOT', toolPath);
let pubCachePath = process.env['PUB_CACHE'] || '';
if (!pubCachePath) {
pubCachePath = path.join(toolPath, '.pub-cache');
core.exportVariable('PUB_CACHE', pubCachePath);
}
core.addPath(path.join(toolPath, 'bin'));
core.addPath(path.join(toolPath, 'bin', 'cache', 'dart-sdk', 'bin'));
core.addPath(path.join(pubCachePath, 'bin'));
if (useMaster) {
await exec.exec('flutter', ['channel', 'master']);
await exec.exec('flutter', ['upgrade']);
}
}
function tmpBaseDir(platform: string): string {
let tempDirectory = process.env['RUNNER_TEMP'] || '';
if (tempDirectory) {
return tempDirectory;
}
let baseLocation;
switch (platform) {
case 'windows':
baseLocation = process.env['USERPROFILE'] || 'C:\\';
break;
case 'macos':
baseLocation = '/Users';
break;
default:
baseLocation = '/home';
break;
}
return path.join(baseLocation, 'actions', 'temp');
}
async function tmpDir(platform: string): Promise<string> {
const baseDir = tmpBaseDir(platform);
const tempDir = path.join(
baseDir,
'temp_' + Math.floor(Math.random() * 2000000000)
);
await io.mkdirP(tempDir);
return tempDir;
}
async function extract(
sdkFile: string,
sdkCache: string,
originalFilename: string
): Promise<string> {
const fileStats = fs.statSync(path.normalize(sdkFile));
if (fileStats.isFile()) {
const stats = fs.statSync(sdkFile);
if (!stats) {
throw new Error(`Failed to extract ${sdkFile} - it doesn't exist`);
} else if (stats.isDirectory()) {
throw new Error(`Failed to extract ${sdkFile} - it is a directory`);
}
if (originalFilename.endsWith('tar.xz')) {
await tc.extractTar(sdkFile, sdkCache, 'x');
} else {
await tc.extractZip(sdkFile, sdkCache);
}
return path.join(sdkCache, fs.readdirSync(sdkCache)[0]);
} else {
throw new Error(`Flutter sdk argument ${sdkFile} is not a file`);
}
}

View file

@ -1,199 +0,0 @@
import * as core from '@actions/core';
import * as httpm from '@actions/http-client';
import * as semver from 'semver';
export const storageUrl =
'https://storage.googleapis.com/flutter_infra_release/releases';
interface IFlutterData {
channel: string;
version: string;
rawVersion: string;
downloadUrl: string;
}
interface IFlutterChannel {
[key: string]: string;
beta: string;
dev: string;
stable: string;
}
interface IFlutterRelease {
hash: string;
channel: string;
version: string;
archive: string;
}
interface IFlutterStorage {
current_release: IFlutterChannel;
releases: IFlutterRelease[];
}
export function getPlatform(): string {
const platform = process.platform;
if (platform == 'win32') {
return 'windows';
}
if (platform == 'darwin') {
return 'macos';
}
return platform;
}
export async function determineVersion(
version: string,
channel: string,
platform: string
): Promise<IFlutterData> {
const storage = await getReleases(platform);
if (version === '') {
return getLatestVersion(storage, channel);
}
if (version.endsWith('.x')) {
return getWildcardVersion(storage, channel, version);
}
return getVersion(storage, channel, version);
}
async function getReleases(platform: string): Promise<IFlutterStorage> {
const releasesUrl: string = `${storageUrl}/releases_${platform}.json`;
const http: httpm.HttpClient = new httpm.HttpClient('flutter-action');
const storage: IFlutterStorage | null = (
await http.getJson<IFlutterStorage | null>(releasesUrl)
).result;
if (!storage) {
throw new Error('unable to get flutter releases');
}
return storage;
}
async function getLatestVersion(
storage: IFlutterStorage,
channel: string
): Promise<IFlutterData> {
const channelVersion = storage.releases.find(release => {
return (
release.hash === storage.current_release[channel] &&
validateChannel(release.channel, channel)
);
});
if (!channelVersion) {
throw new Error(`unable to get latest version from channel ${channel}`);
}
let rver = channelVersion.version;
let cver = rver.startsWith('v') ? rver.slice(1, rver.length) : rver;
core.debug(`latest version from channel ${channel} is ${rver}`);
const flutterData: IFlutterData = {
channel: channelVersion.channel,
version: cver,
rawVersion: rver,
downloadUrl: `${storageUrl}/${channelVersion.archive}`
};
return flutterData;
}
function validateChannel(releaseChannel: string, channel: string) {
return releaseChannel === channel || channel === 'any';
}
async function getWildcardVersion(
storage: IFlutterStorage,
channel: string,
version: string
): Promise<IFlutterData> {
let sver = version.endsWith('.x')
? version.slice(0, version.length - 2)
: version;
const releases = storage.releases.filter(release => {
return (
validateChannel(release.channel, channel) &&
prefixCompare(sver, release.version)
);
});
const versions = releases
.map(release => release.version)
.map(version =>
version.startsWith('v') ? version.slice(1, version.length) : version
);
const sortedVersions = versions.sort(semver.rcompare);
let cver = sortedVersions[0];
let release = releases.find(release => compare(cver, release.version));
if (!release) {
throw new Error(`unable to find release for ${version}`);
}
core.debug(
`latest version of ${version} from channel ${channel} is ${release.version}`
);
const flutterData = {
channel: release.channel,
version: cver,
rawVersion: release.version,
downloadUrl: `${storageUrl}/${release.archive}`
};
return flutterData;
}
async function getVersion(
storage: IFlutterStorage,
channel: string,
version: string
): Promise<IFlutterData> {
const release = storage.releases.find(release => {
return (
validateChannel(release.channel, channel) &&
compare(version, release.version)
);
});
if (!release) {
return getWildcardVersion(storage, channel, version);
}
const flutterData = {
channel: release.channel,
version,
rawVersion: release.version,
downloadUrl: `${storageUrl}/${release.archive}`
};
return flutterData;
}
function compare(version: string, releaseVersion: string): boolean {
if (releaseVersion.startsWith('v')) {
return releaseVersion === `v${version}`;
}
return releaseVersion === version;
}
function prefixCompare(version: string, releaseVersion: string): boolean {
if (releaseVersion.startsWith('v')) {
return releaseVersion.startsWith(`v${version}`);
}
return releaseVersion.startsWith(version);
}

View file

@ -1,11 +0,0 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"outDir": "./lib",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true
},
"exclude": ["node_modules", "**/*.test.ts"]
}