Skip to content

Commit

Permalink
feat(lyl): add style-compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
Enlcxx committed Dec 12, 2019
1 parent fcbb963 commit ca6b1ce
Show file tree
Hide file tree
Showing 12 changed files with 145 additions and 40 deletions.
9 changes: 5 additions & 4 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
displayName: "Install Yarn"
- bash: |
set -e
echo $(curl https://api.github.com/repos/${BUILD_REPOSITORY_NAME}/commits/${SYSTEM_PULLREQUEST_SOURCECOMMITID} | node -pe 'JSON.parse(fs.readFileSync(0)).commit.message') > ./ci/scripts/msg
echo ${SYSTEM_PULLREQUEST_SOURCECOMMITID} > ./ci/scripts/sha
source ./ci/setup.sh
echo $(ts-node tools/src/commit-msg) > ./ci/scripts/MSG
echo $(node -pe 'const {env}=process;env.SYSTEM_PULLREQUEST_SOURCECOMMITID || env.BUILD_SOURCEVERSION') > ./ci/scripts/SHA
echo ${BUILD_SOURCEBRANCHNAME} > ./ci/scripts/BUILD_SOURCEBRANCHNAME
echo $(git show -s --format=%s)
displayName: "Write data"
- task: CacheBeta@1
inputs:
Expand All @@ -35,9 +35,10 @@ jobs:
yarn global add serve
yarn tools:prepare-lib
./ci/scripts/build-style-compiler.sh
node dist/@alyle/style-compiler/main src
node dist/@alyle/ui/style-compiler/main src
# yarn ng build alyle-ui --aot --output-path dist/alyle-ui-aot
yarn build
displayName: 'Build App'
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: 'dist/alyle-ui'
Expand Down
6 changes: 2 additions & 4 deletions ci/scripts/build-docs-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ set -u -e -o pipefail
yarn
yarn tools:prepare-lib
./ci/scripts/build-style-compiler.sh
node dist/@alyle/style-compiler/main dist/lib
node dist/@alyle/ui/style-compiler/main dist/lib
yarn build:@alyle/ui
export CI_COMMIT_MESSAGE=$(git show -s --format=%s)
export CI_COMMIT_SHA=$(git rev-parse HEAD)
export CI_BRANCH=$(git rev-parse --abbrev-ref HEAD)
./ci/scripts/build-style-compiler.sh
ls dist -lh
3 changes: 2 additions & 1 deletion ci/scripts/build-style-compiler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

set -u -e -o pipefail

readonly pkg_dir=dist/@alyle/style-compiler
readonly pkg_dir=dist/@alyle/ui/style-compiler
readonly lib_dir=dist/lib/style-compiler

rm -rf ${pkg_dir}
mkdir -p ${pkg_dir}
yarn tsc -p ${lib_dir}/tsconfig-build.json

mv ${pkg_dir}/src/* ${pkg_dir}
Expand Down
3 changes: 2 additions & 1 deletion ci/setup.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
export TS_NODE_COMPILER_OPTIONS='{"module": "commonjs"}'
export TS_NODE_COMPILER_OPTIONS='{"module": "commonjs"}'
export PATH="$PATH:$(pwd)/node_modules/.bin"
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,15 @@
"@angular/cli": "^8.3.20",
"@angular/compiler-cli": "^8.2.14",
"@angularclass/hmr": "^2.1.3",
"@octokit/request": "^5.3.1",
"@types/chroma-js": "^1.4.1",
"@types/google.analytics": "^0.0.38",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@types/js-yaml": "^3.12.1",
"@types/node": "~12.12",
"@types/prismjs": "^1.16.0",
"@types/semver": "^6.2.0",
"@types/showdown": "^1.9.2",
"@types/yargs": "^13.0.0",
"ava": "^2.4.0",
Expand Down
3 changes: 3 additions & 0 deletions src/lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"type": "git",
"url": "git+https://github.com/A-l-y-l-e/Alyle-UI.git"
},
"bin": {
"lyl": "./style-compiler/main.js"
},
"keywords": [
"angular",
"components",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/style-compiler/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if (directory) {
} else {
console.log(chalk.bold.redBright(`Require directory`));
console.log(`Examples: lyl dist/lib`);
process.exit(0);
process.exit(1);
}

walk(directory).then(async (res) => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/style-compiler/tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"baseUrl": ".",
"rootDir": "..",
"outDir": "../../../dist/@alyle/style-compiler/",
"outDir": "../../../dist/@alyle/ui/style-compiler/",
"lib": [
"es2015"
],
Expand Down
48 changes: 21 additions & 27 deletions tools/src/bump-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { readFileSync, writeFileSync } from 'fs';
import * as jsyaml from 'js-yaml';
import * as moment from 'moment';
import { argv } from 'yargs';
import * as semver from 'semver';

const packageConf = `${process.cwd()}/.package.conf.yml`;
const config = jsyaml.load(readFileSync(packageConf, 'utf8').toString());
Expand All @@ -11,6 +12,14 @@ const pkgLib = JSON.parse(readFileSync(`${process.cwd()}/src/lib/package.json`,
const styleCompilerLib = JSON.parse(readFileSync(`${process.cwd()}/src/lib/style-compiler/package.json`, 'utf8').toString());

const isNightly = process.argv.some(_ => _ === '--nightly');
const {
NEW_RELEASE
} = process.env;

if (!NEW_RELEASE) {
console.log('Bump Version: skiped.');
process.exit(0);
}

function updateVersion() {
const newVersion = createVersion(config.version);
Expand All @@ -29,38 +38,23 @@ function updateVersion() {
writeFileSync(`${process.cwd()}/src/lib/style-compiler/package.json`, JSON.stringify(pkgLib, undefined, 2), 'utf8');
}

const NEW_VERSION = process.env.NEW_VERSION || (argv.newVersion as string) || null;

function createVersion(currentVersion: string) {
const newDate = new Date();
const now = newDate.getTime();
const date = `${moment().format('YYYYMMDD')}-${Date.now().toString(36)}`;
let versionArray = currentVersion.split('.');
const nightlyVersion = `-nightly.${date}`;
let version;

if (NEW_VERSION) {

// Bump custom new version
const lastUpdate = new Date(now).toJSON();
const date = `${moment(now).format('YYMMDD')}${moment().format('HHmm')}`;
let version = '';

// Clean
versionArray = [...NEW_VERSION.split('.')];
} else if (isNightly) {
if (versionArray.length > 3) {
versionArray[versionArray.length - 1] = date;
} else {
versionArray[2] = `${parseFloat(versionArray[2]) + 1}` + nightlyVersion;
}
} else {
if (versionArray.length > 3) {
versionArray.splice(3);
versionArray[2] = versionArray[2].replace('-nightly', '');
} else {
versionArray[2] = `${parseFloat(versionArray[2]) + 1}`;
}
if (/patch/i.test(NEW_RELEASE!)) {
version = semver.inc(currentVersion, 'patch')!;
} else if (/nightly/i.test(NEW_RELEASE!)) {
version = semver.inc(currentVersion, 'prerelease', 'nightly')!.replace('ly.0', `ly.${date}`);
} else if (/minor/i.test(NEW_RELEASE!)) {
version = semver.inc(currentVersion, 'minor')!;
} else if (/major/i.test(NEW_RELEASE!)) {
version = semver.inc(currentVersion, 'major')!;
}
version = versionArray.join('.');
const lastUpdate = new Date(now).toJSON();

return {
version,
lastUpdate
Expand Down
21 changes: 21 additions & 0 deletions tools/src/commit-msg.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { request } from '@octokit/request';
import { env, REPO_OWNER, REPO_NAME } from './env';

const msg = async () => {
const { data: { commit: { message } } } = await request('GET /repos/:owner/:repo/commits/:ref', {
owner: REPO_OWNER,
repo: REPO_NAME,
ref: env.SYSTEM_PULLREQUEST_SOURCECOMMITID || env.BUILD_SOURCEVERSION || 'fcbb963bf9d62ff1c401615cbea153640e1bf983'
});
process.stdout.write((message as string).toLowerCase());
};

try {
msg().catch((err) => {
console.error(err);
process.exit(1);
});
} catch (err) {
console.error(err);
process.exit(1);
}
3 changes: 3 additions & 0 deletions tools/src/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const REPO_OWNER = 'A-l-y-l-e';
export const REPO_NAME = 'Alyle-UI';
export const env = process.env;
83 changes: 82 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,45 @@
"@nodelib/fs.scandir" "2.1.3"
fastq "^1.6.0"

"@octokit/endpoint@^5.5.0":
version "5.5.1"
resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-5.5.1.tgz#2eea81e110ca754ff2de11c79154ccab4ae16b3f"
integrity sha512-nBFhRUb5YzVTCX/iAK1MgQ4uWo89Gu0TH00qQHoYRCsE12dWcG1OiLd7v2EIo2+tpUKPMOQ62QFy9hy9Vg2ULg==
dependencies:
"@octokit/types" "^2.0.0"
is-plain-object "^3.0.0"
universal-user-agent "^4.0.0"

"@octokit/request-error@^1.0.1":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-1.2.0.tgz#a64d2a9d7a13555570cd79722de4a4d76371baaa"
integrity sha512-DNBhROBYjjV/I9n7A8kVkmQNkqFAMem90dSxqvPq57e2hBr7mNTX98y3R2zDpqMQHVRpBDjsvsfIGgBzy+4PAg==
dependencies:
"@octokit/types" "^2.0.0"
deprecation "^2.0.0"
once "^1.4.0"

"@octokit/request@^5.3.1":
version "5.3.1"
resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.3.1.tgz#3a1ace45e6f88b1be4749c5da963b3a3b4a2f120"
integrity sha512-5/X0AL1ZgoU32fAepTfEoggFinO3rxsMLtzhlUX+RctLrusn/CApJuGFCd0v7GMFhF+8UiCsTTfsu7Fh1HnEJg==
dependencies:
"@octokit/endpoint" "^5.5.0"
"@octokit/request-error" "^1.0.1"
"@octokit/types" "^2.0.0"
deprecation "^2.0.0"
is-plain-object "^3.0.0"
node-fetch "^2.3.0"
once "^1.4.0"
universal-user-agent "^4.0.0"

"@octokit/types@^2.0.0":
version "2.0.2"
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-2.0.2.tgz#0888497f5a664e28b0449731d5e88e19b2a74f90"
integrity sha512-StASIL2lgT3TRjxv17z9pAqbnI7HGu9DrJlg3sEBFfCLaMEqp+O3IQPUF6EZtQ4xkAu2ml6kMBBCtGxjvmtmuQ==
dependencies:
"@types/node" ">= 8"

"@schematics/angular@8.3.20":
version "8.3.20"
resolved "https://registry.yarnpkg.com/@schematics/angular/-/angular-8.3.20.tgz#737d0a73e891446899a2267c4cc348b6c5a78ca8"
Expand Down Expand Up @@ -1244,6 +1283,11 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.6.2.tgz#a5ccec6abb6060d5f20d256fb03ed743e9774999"
integrity sha512-gojym4tX0FWeV2gsW4Xmzo5wxGjXGm550oVUII7f7G5o4BV6c7DBdiG1RRQd+y1bvqRyYtPfMK85UM95vsapqQ==

"@types/node@>= 8":
version "12.12.17"
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.12.17.tgz#191b71e7f4c325ee0fb23bc4a996477d92b8c39b"
integrity sha512-Is+l3mcHvs47sKy+afn2O1rV4ldZFU7W8101cNlOd+MRbjM4Onida8jSZnJdTe/0Pcf25g9BNIUsuugmE6puHA==

"@types/node@~12.12":
version "12.12.14"
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.12.14.tgz#1c1d6e3c75dba466e0326948d56e8bd72a1903d2"
Expand Down Expand Up @@ -1276,6 +1320,11 @@
resolved "https://registry.yarnpkg.com/@types/selenium-webdriver/-/selenium-webdriver-3.0.16.tgz#50a4755f8e33edacd9c406729e9b930d2451902a"
integrity sha512-lMC2G0ItF2xv4UCiwbJGbnJlIuUixHrioOhNGHSCsYCJ8l4t9hMCUimCytvFv7qy6AfSzRxhRHoGa+UqaqwyeA==

"@types/semver@^6.2.0":
version "6.2.0"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-6.2.0.tgz#d688d574400d96c5b0114968705366f431831e1a"
integrity sha512-1OzrNb4RuAzIT7wHSsgZRlMBlNsJl+do6UblR7JMW4oB7bbR+uBEYtUh7gEc/jM84GGilh68lSOokyM/zNUlBA==

"@types/showdown@^1.9.2":
version "1.9.3"
resolved "https://registry.yarnpkg.com/@types/showdown/-/showdown-1.9.3.tgz#eaa881b03a32d3720184731754d3025fc450b970"
Expand Down Expand Up @@ -4144,6 +4193,11 @@ dependency-graph@^0.7.2:
resolved "https://registry.yarnpkg.com/dependency-graph/-/dependency-graph-0.7.2.tgz#91db9de6eb72699209d88aea4c1fd5221cac1c49"
integrity sha512-KqtH4/EZdtdfWX0p6MGP9jljvxSY6msy/pRUD4jgNwVpv3v1QmNLlsB3LDSSUg79BRVSn7jI1QPRtArGABovAQ==

deprecation@^2.0.0:
version "2.3.1"
resolved "https://registry.yarnpkg.com/deprecation/-/deprecation-2.3.1.tgz#6368cbdb40abf3373b525ac87e4a260c3a700919"
integrity sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==

des.js@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/des.js/-/des.js-1.0.0.tgz#c074d2e2aa6a8a9a07dbd61f9a15c2cd83ec8ecc"
Expand Down Expand Up @@ -7504,6 +7558,11 @@ lunr@^2.3.6:
resolved "https://registry.yarnpkg.com/lunr/-/lunr-2.3.8.tgz#a8b89c31f30b5a044b97d2d28e2da191b6ba2072"
integrity sha512-oxMeX/Y35PNFuZoHp+jUj5OSEmLCaIH4KTFJh7a93cHBoFmpw2IoPs22VIz7vyO2YUnx2Tn9dzIwO2P/4quIRg==

macos-release@^2.2.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/macos-release/-/macos-release-2.3.0.tgz#eb1930b036c0800adebccd5f17bc4c12de8bb71f"
integrity sha512-OHhSbtcviqMPt7yfw5ef5aghS2jzFVKEFyCJndQt2YpSQ9qRVSEv2axSJI1paVThEu+FFGs584h/1YhxjVqajA==

magic-string@0.25.3, magic-string@^0.25.0, magic-string@^0.25.2:
version "0.25.3"
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.3.tgz#34b8d2a2c7fec9d9bdf9929a3fd81d271ef35be9"
Expand Down Expand Up @@ -8118,7 +8177,7 @@ node-fetch-npm@^2.0.2:
json-parse-better-errors "^1.0.0"
safe-buffer "^5.1.1"

node-fetch@^2.1.1:
node-fetch@^2.1.1, node-fetch@^2.3.0:
version "2.6.0"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd"
integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==
Expand Down Expand Up @@ -8521,6 +8580,14 @@ os-locale@^3.0.0, os-locale@^3.1.0:
lcid "^2.0.0"
mem "^4.0.0"

os-name@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/os-name/-/os-name-3.1.0.tgz#dec19d966296e1cd62d701a5a66ee1ddeae70801"
integrity sha512-h8L+8aNjNcMpo/mAIBPn5PXCM16iyPGjHNWo6U1YO8sJTMHtEtyczI6QJnLoplswm6goopQkqc7OAnjhWcugVg==
dependencies:
macos-release "^2.2.0"
windows-release "^3.1.0"

os-tmpdir@^1.0.0, os-tmpdir@^1.0.1, os-tmpdir@~1.0.1, os-tmpdir@~1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274"
Expand Down Expand Up @@ -11517,6 +11584,13 @@ universal-analytics@^0.4.16, universal-analytics@^0.4.20:
request "^2.88.0"
uuid "^3.0.0"

universal-user-agent@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-4.0.0.tgz#27da2ec87e32769619f68a14996465ea1cb9df16"
integrity sha512-eM8knLpev67iBDizr/YtqkJsF3GK8gzDc6st/WKzrTuPtcsOKW/0IdL4cnMBsU69pOx0otavLWBDGTwg+dB0aA==
dependencies:
os-name "^3.1.0"

universalify@^0.1.0:
version "0.1.2"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66"
Expand Down Expand Up @@ -11957,6 +12031,13 @@ widest-line@^2.0.0:
dependencies:
string-width "^2.1.1"

windows-release@^3.1.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/windows-release/-/windows-release-3.2.0.tgz#8122dad5afc303d833422380680a79cdfa91785f"
integrity sha512-QTlz2hKLrdqukrsapKsINzqMgOUpQW268eJ0OaOpJN32h272waxR9fkB9VoWRtK7uKHG5EHJcTXQBD8XZVJkFA==
dependencies:
execa "^1.0.0"

winston@^1.0.1:
version "1.1.2"
resolved "https://registry.yarnpkg.com/winston/-/winston-1.1.2.tgz#68edd769ff79d4f9528cf0e5d80021aade67480c"
Expand Down

0 comments on commit ca6b1ce

Please sign in to comment.