Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist
node_modules
!.eslintrc.js
!.prettierrc.js
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
node_modules
package.json
package-lock.json
coverage
dist
1 change: 1 addition & 0 deletions prettier.config.js → .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = {
arrowParens: 'always',
endOfLine: 'lf',
printWidth: 80,
proseWrap: 'always',
semi: true,
Expand Down
53 changes: 10 additions & 43 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
## 1.0.0 - 2019-12-03

- Graduate v1.0.0

## 1.0.0-canary.4 - 2019-12-03

#### 🚀 Updates
Expand All @@ -12,53 +10,22 @@

#### 🛠 Internals

- Add github actions for test & pull request
([a772503](https://github.com/email-types/msotype/commit/a772503))
- Enable more strict ts options
([480f362](https://github.com/email-types/msotype/commit/480f362))
- Initial commit, separating from [@email-types](https://github.com/email-types)
mono ([92d30f8](https://github.com/email-types/msotype/commit/92d30f8))
- Migrate to @postmates/eslint-config (#2)
([261797f](https://github.com/email-types/msotype/commit/261797f)), closes
[#2](https://github.com/email-types/msotype/issues/2)

### 1.0.0-canary.3 - 2019-11-18

#### 🐞 Fixes

- rename type to be consistent (#8)
([2d50cd2](https://github.com/email-types/email-types/commit/2d50cd2)), closes
[#8](https://github.com/email-types/email-types/issues/8)

**Note:** Version bump only for package msotype

## 1.0.0-canary.2 - 2019-11-17

#### 🚀 Updates
## 1.0.0-canary.3 - 2019-12-01

- **[msotype]** add conditional operators and versions (#5)
([e62a2e6](https://github.com/email-types/email-types/commit/e62a2e6)), closes
[#5](https://github.com/email-types/email-types/issues/5)
- **[msotype]** add ms vendor patches (#4)
([3813790](https://github.com/email-types/email-types/commit/3813790)), closes
[#4](https://github.com/email-types/email-types/issues/4)

#### 🐞 Fixes

- build latest msotype (#7)
([d101828](https://github.com/email-types/email-types/commit/d101828)), closes
[#7](https://github.com/email-types/email-types/issues/7)

**Note:** Version bump only for package msotype
#### 🛠 Internals

## 1.0.0-canary.1 - 2019-11-10
- Add github actions for test & pull request
([a772503](https://github.com/email-types/msotype/commit/a772503))
- Enable more strict ts options
([480f362](https://github.com/email-types/msotype/commit/480f362))

#### 🚀 Updates
## 1.0.0-canary.2 - 2019-12-01

- **[stylis-plugin-mso]** Stylis plugin that adds support for the mso- css
vendor prefix (#1)
([399ef59](https://github.com/email-types/email-types/tree/master/packages/msotype/commit/399ef59)),
closes
[#1](https://github.com/email-types/email-types/tree/master/packages/msotype/issues/1)
#### 🛠 Internals

**Note:** Version bump only for package msotype
- Initial commit, separating from [@email-types](https://github.com/email-types)
mono ([92d30f8](https://github.com/email-types/msotype/commit/92d30f8))
36 changes: 21 additions & 15 deletions generate/comment.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { EOL } from 'os';
import { MSO, groups } from '@email-types/data';
import { Property as MSOProperty } from '@email-types/data/mso';
import { groupLinks } from '../patches/links';
import { log } from '../utils';

export const createComment = (
key: string,
property: MSO.Property,
property: MSOProperty,
): string | null => {
const rows: string[] = [];

Expand All @@ -17,7 +18,7 @@ export const createComment = (

const tableRow: string[] = [];

if (property.inherited) {
if (typeof property.inherited === 'boolean') {
tableRow.push(`\`${property.inherited}\` | | |`);
} else {
tableRow.push('`unknown` | | |');
Expand All @@ -32,18 +33,23 @@ export const createComment = (
rows.push(tableRow.join(''), '');

if (property.groups && property.groups.length > 0) {
const links = property.groups
.map((group) => {
const name = group.toLowerCase().replace(/\s+/g, '-');
const data = groups[(name as unknown) as keyof typeof groups];

if (data) {
return `[\`${data.title}\`](${data.url})`;
}
log.warn(`Could not find '${group}' group for ${key}`);
return undefined;
})
.filter(Boolean);
const links: string[] = [];
property.groups.forEach((group) => {
const name = group.toLowerCase().replace(/\s+/g, '-');
const data = groupLinks[name];

if (data) {
Object.keys(data).forEach((title) => {
links.push(`[\`${title}\`](${data[title]})`);
});
return;
}

log.warn(`Could not find '${group}' group for ${key}`);
return undefined;
});

links.filter(Boolean);

if (links.length > 0) {
rows.push(`@see ${links.join(', ')}`);
Expand Down
2 changes: 1 addition & 1 deletion generate/conditionals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import {
operators as rawOperators,
versions as rawVersions,
} from '@email-types/data';
} from '@email-types/data/mso';
import { AnyDataType, DataType } from './constants';

export let getOperators = (): AnyDataType[] => {
Expand Down
50 changes: 27 additions & 23 deletions generate/css-types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cssDataTypes as cssData } from '@email-types/data';
import { dataTypes as rawDataTypes } from '@email-types/data/css';
import {
globalsString,
globalsNumber,
Expand All @@ -8,29 +8,33 @@ import {
} from './constants';

export const getCssDataTypes = () => {
const cssDataTypes = Object.keys(cssData).reduce<Record<string, AnyDataType>>(
(results, name) => {
if (name === 'number' || name === 'integer') {
results[name] = {
type: DataType.Number,
value: globalsNumber.name,
};
} else if (name === 'length') {
results[name] = {
type: DataType.Length,
value: genericLength.name,
};
} else {
results[name] = {
type: DataType.String,
value: globalsString.name,
};
}

const cssDataTypes = Object.keys(rawDataTypes).reduce<
Record<string, AnyDataType>
>((results, name) => {
// skip color and so its populated using syntaxes data
if (name === 'color') {
return results;
},
{},
);
}

if (name === 'number' || name === 'integer') {
results[name] = {
type: DataType.Number,
value: globalsNumber.name,
};
} else if (name === 'length') {
results[name] = {
type: DataType.Length,
value: genericLength.name,
};
} else {
results[name] = {
type: DataType.String,
value: globalsString.name,
};
}

return results;
}, {});

return cssDataTypes;
};
10 changes: 5 additions & 5 deletions generate/parser.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { syntaxes } from '@email-types/data';
import { syntaxes } from '@email-types/data/mso';
import { getCssDataTypes } from './css-types';
import { AnyDataType, DataType } from './constants';
import { toPascalCase, log } from '../utils';

const REGEX_DATA_TYPE = /^(<[^>]+>)/g;
const REGEX_KEYWORD = /^([\w-|\w.]+)/g;
const dataTypePattern = /^(<[^>]+>)/g;
const keywordPattern = /^([\w-|\w.]+)/g;

export const parse = (syntax: string): AnyDataType[] => {
const rawdata = syntax
Expand All @@ -13,7 +13,7 @@ export const parse = (syntax: string): AnyDataType[] => {
.sort();

const parsed = rawdata.reduce<AnyDataType[]>((result, next) => {
if (next.match(REGEX_DATA_TYPE) !== null) {
if (next.match(dataTypePattern) !== null) {
const value = next.slice(1, -1);
const cssDataTypes = getCssDataTypes();

Expand All @@ -28,7 +28,7 @@ export const parse = (syntax: string): AnyDataType[] => {
value: toPascalCase(value),
});
}
} else if (next.match(REGEX_KEYWORD) !== null) {
} else if (next.match(keywordPattern) !== null) {
const literal = Number(next);
if (String(literal) === next) {
result.push({
Expand Down
17 changes: 11 additions & 6 deletions generate/properties.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable import/no-mutable-exports */
import { properties as rawProperties } from '@email-types/data';
import { properties as rawProperties } from '@email-types/data/mso';
import { createComment } from './comment';
import { AnyDataType, Category, DataType } from './constants';
import { parse } from './parser';
Expand All @@ -16,14 +16,19 @@ export interface Property {
comment?: string | null;
}

export let getProperties = (): Property[] => {
const entries = Object.entries({
...rawProperties,
...msPatches,
}).sort();
const entries = Object.entries({
...rawProperties,
...msPatches,
}).sort();

export let getProperties = (): Property[] => {
const properties = entries.map(([key, value]) => {
const types = parse(value.syntax);

if (value.inherited) {
types.push({ type: DataType.StringLiteral, value: 'inherit' });
}

const property: Property = {
key,
types,
Expand Down
2 changes: 1 addition & 1 deletion generate/syntaxes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable import/no-mutable-exports */
import { syntaxes as rawSyntaxes } from '@email-types/data';
import { syntaxes as rawSyntaxes } from '@email-types/data/mso';
import { toPascalCase } from '../utils';
import { parse } from './parser';
import { DataType } from './constants';
Expand Down
Loading