Skip to content

Commit

Permalink
Add prettifyReleaseFromFile method. Change to babel-preset-env
Browse files Browse the repository at this point in the history
  • Loading branch information
ahanriat committed Dec 2, 2018
1 parent 7a4a3b4 commit f0d69a2
Show file tree
Hide file tree
Showing 15 changed files with 343 additions and 237 deletions.
9 changes: 8 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ module.exports = function(api) {
api.cache(false);
return {
presets: [
'module:metro-react-native-babel-preset',
[
'@babel/preset-env',
{
targets: {
node: '10',
},
},
],
],
plugins: [
[
Expand Down
7 changes: 6 additions & 1 deletion dist/__tests__/lib.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ugglyReleaseNote, prettyReleaseNote } from './blob/release-note-1';
import { parseRelease, prettifyRelease, categorizeMessage } from '~/lib';
import { parseRelease, prettifyRelease, categorizeMessage, prettifyReleaseFromFile } from '~/lib';
describe('pretty release', () => {
describe('parseRelease', () => {
test('Parse the title', () => {
Expand Down Expand Up @@ -69,4 +69,9 @@ describe('pretty release', () => {
expect(prettifyRelease(prettifyRelease(ugglyReleaseNote))).toEqual(prettyReleaseNote);
});
});
describe('Prettify files', () => {
test('prettify the file correctly', () => {
prettifyReleaseFromFile('./src/__tests__/blob/release-note.md', './src/__tests__/blob/release-note-pretty.md');
});
});
});
2 changes: 1 addition & 1 deletion dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { prettifyRelease } from './lib';
export { prettifyRelease, prettifyReleaseFromFile } from './lib';
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { prettifyRelease } from './lib';
export { prettifyRelease, prettifyReleaseFromFile } from './lib';
1 change: 1 addition & 0 deletions dist/lib.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare type Category = 'feature' | 'enhancement' | 'analytics' | 'fix' | 'upgrade' | 'doc' | 'unknown';
export declare function prettifyReleaseFromFile(releaseNotePath: string, outputFilePath: string): void;
export declare function prettifyRelease(release: string): string;
interface ParsedReleaseNote {
title: string;
Expand Down
5 changes: 5 additions & 0 deletions dist/lib.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { groupBy } from 'lodash';
import fs from 'fs';
const categoryOrder = [
{ type: 'feature', label: '### Features 🧬:' },
{ type: 'enhancement', label: '### Enhancements ⚡️:' },
Expand All @@ -8,6 +9,10 @@ const categoryOrder = [
{ type: 'doc', label: '### Doc 📖:' },
{ type: 'unknown', label: '### To be sorted 👈' },
];
export function prettifyReleaseFromFile(releaseNotePath, outputFilePath) {
const rawReleaseNote = fs.readFileSync(releaseNotePath).toString();
fs.writeFileSync(outputFilePath, prettifyRelease(rawReleaseNote));
}
export function prettifyRelease(release) {
const { title, messages } = parseRelease(release);
const groupedMessages = groupBy(messages, categorizeMessage);
Expand Down
3 changes: 2 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
module.exports = {
verbose: true,
testRegex: '((\\.|/)(test|spec))\\.(jsx?|tsx?)$',
testRegex: '((\\.|/)(test|spec))\\.(tsx?)$',
transform: {
'^.+\\.[jt]sx?$': '<rootDir>/node_modules/babel-jest',
},
testPathIgnorePatterns: ['/node_modules/', '/dist/'],
moduleFileExtensions: [
"ts",
"tsx",
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@
"license": "MIT",
"private": false,
"scripts": {
"test": "jest",
"test": "tsc && jest",
"tdd": "jest --watch"
},
"devDependencies": {
"@babel/core": "^7.1.6",
"@babel/preset-env": "^7.1.6",
"@babel/runtime": "^7.1.5",
"@types/jest": "^23.3.10",
"@types/lodash": "^4.14.118",
"@types/node": "^10.12.11",
"babel-core": "^7.0.0-bridge",
"babel-jest": "^23.6.0",
"babel-plugin-module-resolver": "^3.1.1",
"jest": "^23.6.0",
"metro-react-native-babel-preset": "0.49.0",
"prettier": "^1.15.3",
"ts-node": "^7.0.1",
"tslint": "5.11.0",
Expand All @@ -30,6 +31,7 @@
"typescript": "^3.2.1"
},
"dependencies": {
"fs": "^0.0.1-security",
"lodash": "^4.17.11"
}
}
54 changes: 54 additions & 0 deletions src/__tests__/blob/release-note-pretty.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
**In this release:**

### Features 🧬:
- 📊Experiment: Hard conclude 1803-currency-symbols (#1887)
- 🚛 Exercise store [Feature branch] (#1898)


### Enhancements ⚡️:
- DS-56 💄Improvement/segmented slider (#1722)
- Enhancement/add screen context snowplow (#1913)
- 💄Center text on ChnageStartsHereScene (#1906)


### Analytics 📊:
- Add Snowplow events (#1882)


### Bug fixes 🐛:
- BUG-165 Profile | Weight difference value is reset to 0 after login (#1902)
- Few words on the hotfix branches in wiki (#1878)
- Fix Readme links to react/ -> src/
- Fix static libs 3rd try [TI-79] 😅 (#1900)
- Fix/BUG 144 Email address display (#1828)
- Fixed overlapping text on Rest Screen during Cooldown (#1872)
- 🐛 Fix crash when using SVG component (#1907)
- 🐛Fix cropped accents (#1894)
- 🐛Fix date format for workout schedule screen (#1895)
- 🐛Fix floatingBottomDecorator pointer events to allow access elements behind such as checkbox on GDPR screen (#1890)
- 🐛Fix missing translation on WorkoutPlanReadyScreen (#1891)
- 🐛Fix newsletter enrolment (#1888)


### Library upgrade ⬆️:
- ⬆Upgrade appboy-sdk (Braze) (#1950)
- ⬆️Upgrade React-native to 57.5 and React to 16.6 (#1819)
- 🌈Upgrade and fix Storybook (#1916)


### Doc 📖:
- Wiki update for Detox (#1920)


### To be sorted 👈
- Automated releases for GitHub (#1901)
- Chore/loading states (#1919)
- Detox - enable settings and today tab test suites for iOS (#1868)
- DownloadError component for migration (#1893)
- MT-585 Update new Snapshot screen to display approximations (#1827)
- Remove deprecated PlansScreen (#1918)
- Save body fat value onScroll (#1899)
- Update post-workout kcal estimation (#1932)
- Use legacy build system for testing builds (#1912)
- [WKT-499][TI-74] WorkoutTemplate API migration (#1816)

33 changes: 33 additions & 0 deletions src/__tests__/blob/release-note.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
**In this release:**
- 🐛Fix missing translation on WorkoutPlanReadyScreen (#1891)
- 📊Experiment: Hard conclude 1803-currency-symbols (#1887)
- 🐛Fix floatingBottomDecorator pointer events to allow access elements behind such as checkbox on GDPR screen (#1890)
- 🐛Fix date format for workout schedule screen (#1895)
- 🐛Fix cropped accents (#1894)
- DownloadError component for migration (#1893)
- 🚛 Exercise store [Feature branch] (#1898)
- Few words on the hotfix branches in wiki (#1878)
- Save body fat value onScroll (#1899)
- Fixed overlapping text on Rest Screen during Cooldown (#1872)
- Fix static libs 3rd try [TI-79] 😅 (#1900)
- BUG-165 Profile | Weight difference value is reset to 0 after login (#1902)
- Add Snowplow events (#1882)
- 💄Center text on ChnageStartsHereScene (#1906)
- Automated releases for GitHub (#1901)
- 🐛 Fix crash when using SVG component (#1907)
- 🐛Fix newsletter enrolment (#1888)
- Use legacy build system for testing builds (#1912)
- ⬆️Upgrade React-native to 57.5 and React to 16.6 (#1819)
- DS-56 💄Improvement/segmented slider (#1722)
- Remove deprecated PlansScreen (#1918)
- Fix/BUG 144 Email address display (#1828)
- Wiki update for Detox (#1920)
- MT-585 Update new Snapshot screen to display approximations (#1827)
- Chore/loading states (#1919)
- 🌈Upgrade and fix Storybook (#1916)
- [WKT-499][TI-74] WorkoutTemplate API migration (#1816)
- Update post-workout kcal estimation (#1932)
- Enhancement/add screen context snowplow (#1913)
- Detox - enable settings and today tab test suites for iOS (#1868)
- Fix Readme links to react/ -> src/
- ⬆Upgrade appboy-sdk (Braze) (#1950)
11 changes: 10 additions & 1 deletion src/__tests__/lib.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ugglyReleaseNote, prettyReleaseNote } from './blob/release-note-1';
import { parseRelease, prettifyRelease, categorizeMessage } from '~/lib';
import { parseRelease, prettifyRelease, categorizeMessage, prettifyReleaseFromFile } from '~/lib';

describe('pretty release', () => {
describe('parseRelease', () => {
Expand Down Expand Up @@ -79,4 +79,13 @@ describe('pretty release', () => {
expect(prettifyRelease(prettifyRelease(ugglyReleaseNote))).toEqual(prettyReleaseNote);
});
});

describe('Prettify files', () => {
test('prettify the file correctly', () => {
prettifyReleaseFromFile(
'./src/__tests__/blob/release-note.md',
'./src/__tests__/blob/release-note-pretty.md',
);
});
});
});
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { prettifyRelease } from './lib';
export { prettifyRelease, prettifyReleaseFromFile } from './lib';
6 changes: 6 additions & 0 deletions src/lib.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { groupBy } from 'lodash';
import fs from 'fs';

type Category = 'feature' | 'enhancement' | 'analytics' | 'fix' | 'upgrade' | 'doc' | 'unknown';

Expand All @@ -15,6 +16,11 @@ const categoryOrder: Array<{
{ type: 'unknown', label: '### To be sorted 👈' },
];

export function prettifyReleaseFromFile(releaseNotePath: string, outputFilePath: string) {
const rawReleaseNote = fs.readFileSync(releaseNotePath).toString();
fs.writeFileSync(outputFilePath, prettifyRelease(rawReleaseNote));
}

export function prettifyRelease(release: string): string {
const { title, messages } = parseRelease(release);

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"noUnusedParameters": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"esModuleInterop": false,
"baseUrl": "./",
"paths": {
"~/*": ["src/*"]
Expand Down
Loading

0 comments on commit f0d69a2

Please # to comment.