-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat (ci): add support for code generation in repetitive efforts rela…
…ted to specs and definition (#43) * add script to generate code based in contracts
- Loading branch information
1 parent
79fd6a6
commit 14a1e98
Showing
13 changed files
with
223 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
**/*.d.ts | ||
**/*.d.ts | ||
docs | ||
examples | ||
scripts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"backgroundColor": { | ||
"type": "String?", | ||
"default": "defaultStringEmptyValue" | ||
}, | ||
"padding": { | ||
"type": "double", | ||
"default": "defaultDoubleZeroValue" | ||
}, | ||
"paddingTop": { | ||
"type": "double?", | ||
"default": "defaultDoubleEmptyValue" | ||
}, | ||
"paddingLeft": { | ||
"type": "double?", | ||
"default": "defaultDoubleEmptyValue" | ||
}, | ||
"paddingRight": { | ||
"type": "double?", | ||
"default": "defaultDoubleEmptyValue" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
{ | ||
"colors": { | ||
"primary": { | ||
"x050": "#FFE8D9", | ||
"x100": "#FFD0B5", | ||
"x200": "#FFB088", | ||
"x300": "#FF9466", | ||
"x400": "#F9703E", | ||
"x500": "#F35627", | ||
"x600": "#DE3A11", | ||
"x700": "#C52707", | ||
"x800": "#AD1D07", | ||
"x900": "#841003" | ||
}, | ||
"accent": { | ||
"x050": "#FFE3EC", | ||
"x100": "#FFB8D2", | ||
"x200": "#FF8CBA", | ||
"x300": "#F364A2", | ||
"x400": "#E8368F", | ||
"x500": "#DA127D", | ||
"x600": "#BC0A6F", | ||
"x700": "#A30664", | ||
"x800": "#870557", | ||
"x900": "#620042" | ||
}, | ||
"neutral": { | ||
"x000": "#FFFFFF", | ||
"x050": "#F7F7F7", | ||
"x100": "#E1E1E1", | ||
"x200": "#CFCFCF", | ||
"x300": "#B1B1B1", | ||
"x400": "#9E9E9E", | ||
"x500": "#7E7E7E", | ||
"x600": "#626262", | ||
"x700": "#515151", | ||
"x800": "#3B3B3B", | ||
"x900": "#222222", | ||
"x999": "#111111" | ||
}, | ||
"positive": { | ||
"x050": "#E3F9E5", | ||
"x100": "#C1F2C7", | ||
"x200": "#91E697", | ||
"x300": "#51CA58", | ||
"x400": "#31B237", | ||
"x500": "#18981D", | ||
"x600": "#0F8613", | ||
"x700": "#0E7817", | ||
"x800": "#07600E", | ||
"x900": "#014807" | ||
}, | ||
"negative": { | ||
"x050": "#FFE3E3", | ||
"x100": "#FFBDBD", | ||
"x200": "#FF9B9B", | ||
"x300": "#F86A6A", | ||
"x400": "#EF4E4E", | ||
"x500": "#E12D39", | ||
"x600": "#CF1124", | ||
"x700": "#AB091E", | ||
"x800": "#8A041A", | ||
"x900": "#610316" | ||
}, | ||
"warning": { | ||
"x050": "#FFFBEA", | ||
"x100": "#FFF3C4", | ||
"x200": "#FCE588", | ||
"x300": "#FADB5F", | ||
"x400": "#F7C948", | ||
"x500": "#F0B429", | ||
"x600": "#DE911D", | ||
"x700": "#CB6E17", | ||
"x800": "#B44D12", | ||
"x900": "#8D2B0B" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export function capitalize(str: any) { | ||
export function capitalize(str: string) { | ||
return str.charAt(0).toUpperCase() + str.slice(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
const fs = require('fs'); | ||
const pkg = require('../package.json'); | ||
|
||
console.log(`[Bump Flutter to: ${pkg.version}]`); | ||
|
||
const pubspecUpdated = fs.readFileSync('./pubspec.yaml', { encoding: 'utf-8' }) | ||
const pubspecUpdated = fs | ||
.readFileSync('./pubspec.yaml', { encoding: 'utf-8' }) | ||
.split('\n') | ||
.map((line) => { | ||
if(line.startsWith('version')) return `version: ${pkg.version}`; | ||
if (line.startsWith('version')) return `version: ${pkg.version}`; | ||
return line; | ||
}) | ||
.join('\n'); | ||
|
||
fs.writeFileSync('./pubspec.yaml', pubspecUpdated, { encoding: 'utf-8' }); | ||
fs.writeFileSync('./pubspec.yaml', pubspecUpdated, { encoding: 'utf-8' }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
/* eslint-disable no-console */ | ||
console.log('[Coder] running...'); | ||
|
||
const stylesheetFile = require('./files/stylesheet'); | ||
|
||
stylesheetFile.generators.StyleSheet_attributes(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* eslint-disable prefer-regex-literals */ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
const pathModule = require('path'); | ||
const fs = require('fs'); | ||
|
||
const demo = ` | ||
// %%[CODER_START]:StyleSheet_attributes%% | ||
final double? width; | ||
final double? width; | ||
final double? width; | ||
final double? width; | ||
final double? width; | ||
final double? width; | ||
final double? width; | ||
final double? width; | ||
final double? width; | ||
OLAAA | ||
// %%[CODER_END]:StyleSheet_attributes%% | ||
final double? width; | ||
final double? height; | ||
`; | ||
|
||
module.exports = { | ||
readFile(filePath, as = 'text') { | ||
const output = fs.readFileSync( | ||
pathModule.resolve(__dirname, '..', '..', '..', filePath), | ||
'utf8' | ||
); | ||
|
||
if (as === 'json') return JSON.parse(output); | ||
|
||
return output; | ||
}, | ||
applyContract({ name, contract }, path, callback) { | ||
const file = this.readFile(path); | ||
let fileOutput = file; | ||
const REGEX_CODER_START = new RegExp( | ||
`(%%\\[CODER_START\\]:${name}%%)`, | ||
'gi' | ||
); | ||
const REGEX_CODER_CLEAR = new RegExp( | ||
`(%%\\[CODER_START\\]:${name}%%)([\\S\\s]*?)%%\\[CODER_END\\]:${name}%%`, | ||
'gmi' | ||
); | ||
fileOutput = fileOutput.replace( | ||
REGEX_CODER_CLEAR, | ||
`$1 \n// %%[CODER_END]:StyleSheet_attributes%%` | ||
); | ||
|
||
Object.entries(contract).forEach(([key, value], index) => { | ||
const replacement = callback([key, value], index); | ||
fileOutput = fileOutput.replace(REGEX_CODER_START, `$1\n${replacement}`); | ||
fs.writeFileSync(path, fileOutput, 'utf8'); | ||
}); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
const core = require('../core/core'); | ||
|
||
const path = './lib/core/stylesheet'; | ||
|
||
const generators = { | ||
StyleSheet_attributes() { | ||
const contract = { | ||
name: 'StyleSheet_attributes', | ||
contract: core.readFile(`${path}/stylesheet.json`, 'json'), | ||
}; | ||
core.applyContract(contract, `${path}/stylesheet.dart`, ([name, value]) => { | ||
return `final Map<Breakpoints,${value.type}> ${name};`; | ||
}); | ||
|
||
core.applyContract(contract, `${path}/stylesheet.ts`, ([name, value]) => { | ||
const types = { | ||
double: 'number | string', | ||
}; | ||
const type = ( | ||
types[value.type.replace('?', '')] || value.type.replace('?', '') | ||
).toLowerCase(); | ||
return `${name}?: ResponsiveProperty<${type}> | string;`; | ||
}); | ||
}, | ||
}; | ||
|
||
module.exports = { | ||
path, | ||
generators, | ||
}; |
14a1e98
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
docs-storybook – ./
storybook.skynexui.dev
docs-storybook-git-main-skynexui.vercel.app
docs-storybook-skynexui.vercel.app
docs-storybook.vercel.app
14a1e98
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
sknui-demobase-react – ./examples/demo_base
sknui-demobase-react-git-main-skynexui.vercel.app
sknui-demobase-react-skynexui.vercel.app
sknui-demobase-react.vercel.app
14a1e98
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
docs – ./docs
docs-skynexui.vercel.app
docs-git-main-skynexui.vercel.app
skynexui.dev
www.skynexui.dev
docs-coral-nine.vercel.app