Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

create-github-actions-setup-for-ember-addon

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-github-actions-setup-for-ember-addon - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

dist/parser/defaults.d.ts

11

CHANGELOG.md
# Changelog
## v0.5.0 (2021-01-07)
#### :rocket: Enhancement
* [#34](https://github.com/jelhan/create-github-actions-setup-for-ember-addon/pull/34) Use reasonable defaults based on the project ([@jelhan](https://github.com/jelhan))
#### :house: Internal
* [#33](https://github.com/jelhan/create-github-actions-setup-for-ember-addon/pull/33) Reorganize file structure for fixtures ([@jelhan](https://github.com/jelhan))
#### Committers: 1
- Jeldrik Hanschke ([@jelhan](https://github.com/jelhan))
## v0.4.0 (2020-12-21)

@@ -4,0 +15,0 @@

32

dist/index.js

@@ -12,16 +12,18 @@ "use strict";

const js_yaml_1 = __importDefault(require("js-yaml"));
const gitHubActionsWorkflowFile = path_1.default.join(process_1.default.cwd(), '.github', 'workflows', 'ci.yml');
const templateFile = path_1.default.join(__dirname, '..', 'templates', '.github', 'workflows', 'ci.yml');
const configuration = utils_1.determineConfiguration();
const data = Object.assign({ configurationDump: js_yaml_1.default.safeDump(configuration) }, configuration);
const options = {
// debug: true,
};
ejs_1.default.renderFile(templateFile, data, options, function (err, str) {
if (err) {
throw err;
}
utils_1.debug(`Writing GitHub Actions workflow to ${gitHubActionsWorkflowFile}`);
fs_1.default.mkdirSync(path_1.default.dirname(gitHubActionsWorkflowFile), { recursive: true });
fs_1.default.writeFileSync(gitHubActionsWorkflowFile, str);
});
(async function main() {
const gitHubActionsWorkflowFile = path_1.default.join(process_1.default.cwd(), '.github', 'workflows', 'ci.yml');
const templateFile = path_1.default.join(__dirname, '..', 'templates', '.github', 'workflows', 'ci.yml');
const configuration = await utils_1.determineConfiguration();
const data = Object.assign({ configurationDump: js_yaml_1.default.safeDump(configuration) }, configuration);
const options = {
// debug: true,
};
ejs_1.default.renderFile(templateFile, data, options, function (err, str) {
if (err) {
throw err;
}
utils_1.debug(`Writing GitHub Actions workflow to ${gitHubActionsWorkflowFile}`);
fs_1.default.mkdirSync(path_1.default.dirname(gitHubActionsWorkflowFile), { recursive: true });
fs_1.default.writeFileSync(gitHubActionsWorkflowFile, str);
});
})();
import { ConfigurationInterface } from '../index';
export default function parsePreviousRunConfig(): ConfigurationInterface | null;
export default function parsePreviousRunConfig(): Promise<ConfigurationInterface | null>;

@@ -10,3 +10,3 @@ "use strict";

const js_yaml_1 = __importDefault(require("js-yaml"));
function parsePreviousRunConfig() {
async function parsePreviousRunConfig() {
const gitHubActionFile = path_1.default.join(process.cwd(), '.github/workflows/ci.yml');

@@ -13,0 +13,0 @@ debug_1.default(`Looking for configuration in an existing GitHub Actions workflow at ${gitHubActionFile}`);

import { ConfigurationInterface } from '../index';
export default function parseTravisCiConfig(): ConfigurationInterface | null;
export default function parseTravisCiConfig(): Promise<ConfigurationInterface | null>;

@@ -26,3 +26,3 @@ "use strict";

}
function parseTravisCiConfig() {
async function parseTravisCiConfig() {
var _a;

@@ -29,0 +29,0 @@ const configFile = path_1.default.join(process_1.default.cwd(), '.travis.yml');

import { ConfigurationInterface } from '../index';
export default function determineConfiguration(): ConfigurationInterface;
export default function determineConfiguration(): Promise<ConfigurationInterface>;

@@ -9,2 +9,3 @@ "use strict";

const previous_run_1 = __importDefault(require("../parser/previous-run"));
const defaults_1 = __importDefault(require("../parser/defaults"));
const parsers = [

@@ -19,8 +20,12 @@ {

},
{
name: 'Defaults',
parse: defaults_1.default,
},
];
function determineConfiguration() {
async function determineConfiguration() {
for (const parser of parsers) {
const { name, parse } = parser;
debug_1.default(`Trying parser ${name}`);
const config = parse();
const config = await parse();
if (config === null) {

@@ -32,43 +37,4 @@ continue;

}
console.log('Using default configuration');
return {
browsers: ['chrome', 'firefox'],
emberTryScenarios: [
{
scenario: 'ember-lts-3.16',
allowedToFail: false,
},
{
scenario: 'ember-lts-3.20',
allowedToFail: false,
},
{
scenario: 'ember-release',
allowedToFail: false,
},
{
scenario: 'ember-beta',
allowedToFail: false,
},
{
scenario: 'ember-default-with-jquery',
allowedToFail: false,
},
{
scenario: 'ember-classic',
allowedToFail: false,
},
{
scenario: 'ember-canary',
allowedToFail: true,
},
{
scenario: 'embroider-tests',
allowedToFail: true,
},
],
nodeVersion: '10.x',
packageManager: 'yarn',
};
throw new Error('Unable to determine any configuration. Defaults should have been used as a last fallback. Please report this bug.');
}
exports.default = determineConfiguration;
{
"name": "create-github-actions-setup-for-ember-addon",
"version": "0.4.0",
"version": "0.5.0",
"description": "Setup GitHub Actions for an Ember Addon",

@@ -21,3 +21,4 @@ "repository": "https://github.com/jelhan/create-github-actions-setup-for-ember-addon.git",

"ejs": "^3.1.5",
"js-yaml": "^3.14.0"
"js-yaml": "^3.14.0",
"semver": "^7.3.4"
},

@@ -28,4 +29,6 @@ "devDependencies": {

"@types/ejs": "^3.0.5",
"@types/fs-extra": "^9.0.6",
"@types/jest": "^26.0.15",
"@types/node": "^14.14.9",
"@types/semver": "^7.3.4",
"@typescript-eslint/eslint-plugin": "^4.8.1",

@@ -37,2 +40,3 @@ "@typescript-eslint/parser": "^4.8.1",

"eslint-plugin-prettier": "^3.1.4",
"fs-extra": "^9.0.1",
"jest": "^26.6.3",

@@ -39,0 +43,0 @@ "jest-plugin-fs": "^2.9.0",

@@ -28,2 +28,12 @@ # Create GitHub Actions setup for Ember Addon

## Defaults
The script tries to calculate sensitive defaults if no configuration from a previous run nor an existing `.travis.yml` is found.
The defaults are calculated based on the actual project:
- Determines node version based on minimum allowed version on `engines.node` key of project's `package.json`.
- Picks up package manager used by your project based on existence of either `package-lock.json` or `yarn.lock`.
- Includes all Ember Try scenarios defined in `config/ember-try.js` in generated test matrix.
- Configures CI to run test against all browsers configured in Testem's `launch_in_ci` configuration.
## Limitations of Travis CI parser

@@ -30,0 +40,0 @@

@@ -20,36 +20,38 @@ import { debug, determineConfiguration } from './utils';

const gitHubActionsWorkflowFile = path.join(
process.cwd(),
'.github',
'workflows',
'ci.yml'
);
(async function main() {
const gitHubActionsWorkflowFile = path.join(
process.cwd(),
'.github',
'workflows',
'ci.yml'
);
const templateFile = path.join(
__dirname,
'..',
'templates',
'.github',
'workflows',
'ci.yml'
);
const configuration: ConfigurationInterface = determineConfiguration();
const data = Object.assign(
{ configurationDump: yaml.safeDump(configuration) },
configuration
);
const options = {
// debug: true,
};
const templateFile = path.join(
__dirname,
'..',
'templates',
'.github',
'workflows',
'ci.yml'
);
const configuration: ConfigurationInterface = await determineConfiguration();
const data = Object.assign(
{ configurationDump: yaml.safeDump(configuration) },
configuration
);
const options = {
// debug: true,
};
ejs.renderFile(templateFile, data, options, function (err, str) {
if (err) {
throw err;
}
ejs.renderFile(templateFile, data, options, function (err, str) {
if (err) {
throw err;
}
debug(`Writing GitHub Actions workflow to ${gitHubActionsWorkflowFile}`);
fs.mkdirSync(path.dirname(gitHubActionsWorkflowFile), { recursive: true });
fs.writeFileSync(gitHubActionsWorkflowFile, str);
});
debug(`Writing GitHub Actions workflow to ${gitHubActionsWorkflowFile}`);
fs.mkdirSync(path.dirname(gitHubActionsWorkflowFile), { recursive: true });
fs.writeFileSync(gitHubActionsWorkflowFile, str);
});
})();
export { ConfigurationInterface, EmberTryScenario };

@@ -7,3 +7,3 @@ import { ConfigurationInterface } from '../index';

export default function parsePreviousRunConfig(): ConfigurationInterface | null {
export default async function parsePreviousRunConfig(): Promise<ConfigurationInterface | null> {
const gitHubActionFile = path.join(process.cwd(), '.github/workflows/ci.yml');

@@ -10,0 +10,0 @@

@@ -34,3 +34,3 @@ import { ConfigurationInterface, EmberTryScenario } from '../index';

export default function parseTravisCiConfig(): ConfigurationInterface | null {
export default async function parseTravisCiConfig(): Promise<ConfigurationInterface | null> {
const configFile = path.join(process.cwd(), '.travis.yml');

@@ -37,0 +37,0 @@

@@ -5,6 +5,7 @@ import { ConfigurationInterface } from '../index';

import parsePreviosRunConfig from '../parser/previous-run';
import calculateDefaults from '../parser/defaults';
interface Parser {
name: string;
parse: { (): ConfigurationInterface | null };
parse: { (): Promise<ConfigurationInterface | null> };
}

@@ -21,5 +22,9 @@

},
{
name: 'Defaults',
parse: calculateDefaults,
},
];
export default function determineConfiguration(): ConfigurationInterface {
export default async function determineConfiguration(): Promise<ConfigurationInterface> {
for (const parser of parsers) {

@@ -29,3 +34,3 @@ const { name, parse } = parser;

debug(`Trying parser ${name}`);
const config = parse();
const config = await parse();

@@ -40,43 +45,5 @@ if (config === null) {

console.log('Using default configuration');
return {
browsers: ['chrome', 'firefox'],
emberTryScenarios: [
{
scenario: 'ember-lts-3.16',
allowedToFail: false,
},
{
scenario: 'ember-lts-3.20',
allowedToFail: false,
},
{
scenario: 'ember-release',
allowedToFail: false,
},
{
scenario: 'ember-beta',
allowedToFail: false,
},
{
scenario: 'ember-default-with-jquery',
allowedToFail: false,
},
{
scenario: 'ember-classic',
allowedToFail: false,
},
{
scenario: 'ember-canary',
allowedToFail: true,
},
{
scenario: 'embroider-tests',
allowedToFail: true,
},
],
nodeVersion: '10.x',
packageManager: 'yarn',
};
throw new Error(
'Unable to determine any configuration. Defaults should have been used as a last fallback. Please report this bug.'
);
}
import execa from 'execa';
import fs from 'fs';
import fsPromises from 'fs/promises';
import { mkdtemp, readFile, rmdir } from 'fs/promises';
import os from 'os';
import path from 'path';
import { prepareFixtures } from '../utils/fixtures';

@@ -18,3 +19,3 @@ const executable = path.join(

beforeEach(async () => {
tmpDirForTesting = await fsPromises.mkdtemp(
tmpDirForTesting = await mkdtemp(
path.join(os.tmpdir(), 'create-github-actions-setup-for-ember-addon-tests-')

@@ -24,17 +25,29 @@ );

afterEach(async () => {
await fsPromises.rmdir(tmpDirForTesting, { recursive: true });
await rmdir(tmpDirForTesting, { recursive: true });
});
describe('creates GitHub Actions setup', () => {
it('uses default values if no TravisCI configuration exists', async () => {
await execa(executable, [], {
cwd: tmpDirForTesting,
describe('uses default values if no other parser matches', () => {
const fixturesPath = path.join(__dirname, '..', 'fixtures', 'defaults');
const scenarios = fs.readdirSync(fixturesPath);
scenarios.forEach((scenario) => {
it(`supports scenario: ${scenario}`, async () => {
await prepareFixtures(
path.join('defaults', scenario),
tmpDirForTesting
);
await execa(executable, [], {
cwd: tmpDirForTesting,
});
expect(
await readFile(
path.join(tmpDirForTesting, '.github', 'workflows', 'ci.yml'),
{ encoding: 'utf-8' }
)
).toMatchSnapshot();
});
});
expect(
await fsPromises.readFile(
path.join(tmpDirForTesting, '.github', 'workflows', 'ci.yml'),
{ encoding: 'utf-8' }
)
).toMatchSnapshot();
});

@@ -47,4 +60,3 @@

'fixtures',
'.github',
'workflows'
'github-actions'
);

@@ -54,15 +66,8 @@ const scenarios = fs.readdirSync(fixturesPath);

scenarios.forEach((scenario) => {
it(`supports scenario ${scenario}`, async () => {
const workflowsPath = path.join(
tmpDirForTesting,
'.github',
'workflows'
it(`supports scenario ci.yml.${scenario}`, async () => {
await prepareFixtures(
path.join('github-actions', scenario),
tmpDirForTesting
);
await fsPromises.mkdir(workflowsPath, { recursive: true });
await fsPromises.copyFile(
path.join(fixturesPath, scenario),
path.join(workflowsPath, 'ci.yml')
);
await execa(executable, [], {

@@ -73,3 +78,3 @@ cwd: tmpDirForTesting,

expect(
await fsPromises.readFile(
await readFile(
path.join(tmpDirForTesting, '.github', 'workflows', 'ci.yml'),

@@ -84,12 +89,10 @@ { encoding: 'utf-8' }

describe('migrates existing TravisCI configration', () => {
const fixturesPath = path.join(__dirname, '..', 'fixtures');
const scenarios = fs
.readdirSync(fixturesPath)
.filter((_) => _.startsWith('.travis.yml'));
const fixturesPath = path.join(__dirname, '..', 'fixtures', 'travis-ci');
const scenarios = fs.readdirSync(fixturesPath);
scenarios.forEach((scenario) => {
it(`supports scenario ${scenario}`, async () => {
await fsPromises.copyFile(
path.join(fixturesPath, scenario),
path.join(tmpDirForTesting, '.travis.yml')
it(`supports scenario .travis.yml.${scenario}`, async () => {
await prepareFixtures(
path.join('travis-ci', scenario),
tmpDirForTesting
);

@@ -102,3 +105,3 @@

expect(
await fsPromises.readFile(
await readFile(
path.join(tmpDirForTesting, '.github', 'workflows', 'ci.yml'),

@@ -105,0 +108,0 @@ { encoding: 'utf-8' }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc