Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown template engine #4

Closed
wants to merge 92 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
e508227
#1 change markup style template
feelform Aug 30, 2021
d270be1
#1 parameter
feelform Aug 31, 2021
4d9b802
#1 add test framework
feelform Sep 1, 2021
f582336
#1 test environment
feelform Sep 1, 2021
4d44c0d
#1 test environment
feelform Sep 1, 2021
c182cba
#1 index.test.js
feelform Sep 2, 2021
cd7f05d
#1 commit action
feelform Sep 2, 2021
ec62ef5
#1 input parameter
feelform Sep 3, 2021
b9f31cf
Create applyMainMarkdownWithTemplateEngine.yml
feelform Sep 3, 2021
b272f97
Update applyMainMarkdownWithTemplateEngine.yml
feelform Sep 3, 2021
9fb5cf4
Update applyMainMarkdownWithTemplateEngine.yml
feelform Sep 3, 2021
fc845c7
#1 cache disable
feelform Sep 3, 2021
4a7f689
#1 action
feelform Sep 3, 2021
d7f5765
action test
feelform Sep 3, 2021
92db59f
#1 test action
feelform Sep 3, 2021
9bf41b8
[#1] fix use syntax
feelform Sep 6, 2021
5852baa
[#1] add node_modules and package-lock.json
feelform Sep 6, 2021
4f30b4f
#1 process.env
feelform Sep 6, 2021
58689cb
[#1] deplicated strategy matrix
feelform Sep 6, 2021
8573263
[#1] env JSON
feelform Sep 6, 2021
1630214
[#1] markdown file
feelform Sep 6, 2021
dd55e80
[#1] template markdown file
feelform Sep 6, 2021
bd9901c
#1 remove setup node
feelform Sep 6, 2021
28d9dba
[#1] result
feelform Sep 6, 2021
da958e2
[#1] aync function
feelform Sep 6, 2021
bf12cb2
[#1] add file-ext
feelform Sep 6, 2021
0a237ad
[#1] update depedency
feelform Sep 6, 2021
e70dd21
[#1] fix dependency
feelform Sep 6, 2021
e6b0ef2
[#1] read file
feelform Sep 6, 2021
514043a
[#1] read markdown content
feelform Sep 6, 2021
780846e
[#1] template md file
feelform Sep 6, 2021
d713f74
[#1] time description
feelform Sep 6, 2021
7534bb8
[#1] echo main.md
feelform Sep 7, 2021
ebeff9d
[#1] echo main.md
feelform Sep 7, 2021
6bea273
[#1] echo main.md
feelform Sep 7, 2021
76358db
[#1] markdown content
feelform Sep 7, 2021
6ca6807
[#1] markdown template engine tests
feelform Sep 7, 2021
90570ef
[#1] fix markdown async issue
feelform Sep 7, 2021
49018a2
[#1] pass index.js unit test
feelform Sep 8, 2021
3458dd3
[#1] Test multiline case
feelform Sep 8, 2021
4fc3c72
[#1] matches markdown
feelform Sep 9, 2021
52023a4
[#1] Template replace string
feelform Sep 9, 2021
eebaf2c
[#1] update package.json
feelform Sep 9, 2021
67602a8
[#1] template file writer
feelform Sep 9, 2021
a4751c5
[#1] output data
feelform Sep 9, 2021
20ee64f
[#1] output data rename
feelform Sep 9, 2021
0a243a0
[#1] remove no needs file
feelform Sep 9, 2021
15b2ab1
[#1] add simple-git dependency
feelform Sep 10, 2021
c96bbc3
[#1] simplegit intialize
feelform Sep 10, 2021
d98e413
[#1] change file logging
feelform Sep 10, 2021
d76d602
[#1] fix unit test failure
feelform Sep 10, 2021
6603df1
[#1] fix unit test failure
feelform Sep 10, 2021
c3db94f
[#1] fix unit test failure
feelform Sep 10, 2021
af6ed3b
[#1] markdown content debug
feelform Sep 10, 2021
e43c841
[#1] markdown content debug
feelform Sep 10, 2021
bffceaa
[#1] markdown content debug
feelform Sep 10, 2021
34f54ec
[#1] markdown content debug
feelform Sep 10, 2021
c8f7f97
[#1] markdown content debug
feelform Sep 10, 2021
48c8b5c
[#1] markdown content debug
feelform Sep 10, 2021
744736b
[#1] markdown content debug
feelform Sep 10, 2021
e6818b6
[#1] markdown content debug
feelform Sep 10, 2021
9a1bb4b
[#1] machine ls
feelform Sep 10, 2021
14543f2
[#1] current directory
feelform Sep 10, 2021
184535b
[#1] markdown content
feelform Sep 10, 2021
5b1e6f5
[#1] git diff
feelform Sep 13, 2021
872b5d3
[#1] git add template mark down file
feelform Sep 13, 2021
b351b99
[#1] git add template mark down file
feelform Sep 13, 2021
91f5d64
[#1] git add template mark down file
feelform Sep 13, 2021
e6e9b2f
[#1] change markdown
feelform Sep 13, 2021
262c3db
[#1] change markdown
feelform Sep 13, 2021
44ec2db
[#1] guard duplicate
feelform Sep 13, 2021
7705bd2
[#1] multiple replace string guard
feelform Sep 14, 2021
d5a7a68
[#1] multiple replace string guard
feelform Sep 14, 2021
2af3a2f
[#1] multiple replace string guard
feelform Sep 14, 2021
4870bbb
[#1] multiple replace string guard
feelform Sep 14, 2021
877c71d
[#1] author configuration
feelform Sep 14, 2021
78f9dee
[#1] author configuration
feelform Sep 14, 2021
c520d3f
[#1] author configuration
feelform Sep 14, 2021
4434c71
[#1] author configuration
feelform Sep 14, 2021
426e15b
[#1] author configuration
feelform Sep 14, 2021
feeb445
Update main.md file.
feelform Sep 14, 2021
aaefb13
[#1] fix git commit message bug
feelform Sep 14, 2021
aa224cc
[#1] request dispatch
feelform Sep 15, 2021
1f95076
[#1] repository dispatch https://github.com/peter-evans/repository-di…
feelform Sep 15, 2021
4537097
[#1] remove no needs command
feelform Sep 15, 2021
ea4ef1d
[#1] extract https://github.com/pinpoint-apm/pinpoint/issues/8243 to …
feelform Sep 16, 2021
4b04d99
[#1] trigger by updated-pinpoint-repository event
feelform Sep 24, 2021
c043e58
[#1] rename refactoring
feelform Sep 27, 2021
629ead8
[#1] rename refactoring
feelform Sep 27, 2021
25b368c
[#1] rename refactoring
feelform Sep 27, 2021
745b233
[#1] rename refactoring
feelform Sep 27, 2021
af4f40d
[#1] rename refactoring
feelform Sep 27, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
Empty file.
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Modules updater javascript action

Modules markdown updater.
[markscribe](https://github.com/basicBrogrammer/crosspost-markdown)

## Inputs

## `who-to-greet`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Pinpoint gitbook template engine
* Copyright 2021-present NAVER Corp.
* Apache License v2.0
*/

'use strict'
const process = require('process')
const cp = require('child_process')
const path = require('path')
const test = require('tape')

test('index.js', (t) => {
process.env['INPUT_TEMPLATE_MARKDOWN_FILE'] = ''
const ip = path.join(__dirname, '../', 'index.js')

t.throws(
function badPath() {
const node = cp.execSync(`node ${ip}`, { env: process.env }).toString()
},
/Error: Command failed: node .*/,
'INPUT_TEMPLATE_MARKDOWN_FILE empty string test'
)
t.end()
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* Pinpoint gitbook template engine
* Copyright 2021-present NAVER Corp.
* Apache License v2.0
*/

'use strict'

const test = require('tape')
const TemplateEngine = require('../lib/template-engine')

const actualMD = `---
title: Pinpoint 2.2.2
keywords: 'pinpoint release, 2.2.2'
permalink: main.html
sidebar: mydoc_sidebar
---

# What's New

## What's New in Pinpoint v2.0

* Support gRPC tranport
* Support for JAVA12, 13
* Maximum throughput limit feature
* renew UI

[Releases](https://github.com/pinpoint-apm/pinpoint/releases)

## Upgrade consideration

HBase compatibility table:

<!-- <compatibilityHbase.md> -->
<!-- </compatibilityHbase.md> -->

Agent compatibility to Collector table:

<!-- <compatibilityPinpoint.md> -->
<!-- </compatibilityPinpoint.md> -->

Additionally, the required Java version to run each Pinpoint component is given below:

<!-- <compatibilityJava.md> -->
<!-- </compatibilityJava.md> -->
## Supported Modules

* JDK 6+
* Supported versions of the \* indicated library may differ from the actual version.

<!-- <modules.md> -->
<!-- </modules.md> -->`

test('tempalte engine', async (t) => {
const dut = new TemplateEngine(actualMD)
const actual = await dut.markdownContent()
t.true(/<!-- <compatibilityHbase\.md> -->/.test(actual), 'compatibilityHbase.md matches')
t.end()
})
14 changes: 14 additions & 0 deletions .github/actions/markdown-template-engine-action/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: 'modules markdown file updater'
description: 'modules markdown file updater'
inputs:
template_markdown_file:
description: 'template markdown file'
required: true
outputs:
# time: # id of output
# description: 'The time we greeted you'
markdown:
description: mardown content by template engine
runs:
using: 'node12'
main: 'index.js'
51 changes: 51 additions & 0 deletions .github/actions/markdown-template-engine-action/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* Pinpoint gitbook template engine
* Copyright 2021-present NAVER Corp.
* Apache License v2.0
*/

'use strict'

const core = require('@actions/core')
const github = require('@actions/github')
const fs = require("fs-extra")
const TemplateEngine = require('./lib/template-engine')

const path = require('path')
const baseDir = process.cwd()
const simpleGit = require('simple-git')
const git = simpleGit({ baseDir })

const run = async () => {
try {
const templateMarkdownFile = core.getInput('template_markdown_file')
const template = await fs.readFile(templateMarkdownFile, 'utf8')
const engine = new TemplateEngine(template)

const markdownContent = await engine.markdownContent()
fs.outputFileSync(templateMarkdownFile, markdownContent)
core.setOutput('markdown', markdownContent)

core.info('Checking for changes')
const changedFiles = (await git.diffSummary()).files.length
if (changedFiles > 0) {
await git
.addConfig('user.email', core.getInput('author_email') || '[email protected]')
.addConfig('user.name', core.getInput('author_name') || 'Yongseok Kang')
.addConfig('author.email', core.getInput('author_email') || '[email protected]')
.addConfig('author.name', core.getInput('author_name') || 'Yongseok Kang')

core.info(`> Found ${changedFiles} changed files.`)
await git.add(templateMarkdownFile)
core.info(`> git add ${templateMarkdownFile} file.`)
await git.commit(`Update ${templateMarkdownFile} file.`)
core.info(`> git commit ${templateMarkdownFile} file.`)
await git.push()
core.info(`> git push.`)
}
} catch (error) {
core.setFailed(error.message)
}
}

run()
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Pinpoint gitbook template engine
* Copyright 2021-present NAVER Corp.
* Apache License v2.0
*/

'use strict'
const core = require('@actions/core')
const github = require('@actions/github')
const fs = require("fs-extra")
const axios = require('axios')

class TemplateEngine {
constructor(template) {
this.template = template
}

// https://regex101.com/r/Sgd2aq/1/
async markdownContent() {
let tagExpression = /<!--\s<(?<markdownfile>.*.md)>\s-->\n.*<!--\s<\/[^.]*.md>\s-->/gm
let tag
let result = this.template
while ((tag = tagExpression.exec(this.template)) !== null) {
const markdownFile = await this.getContent(tag[1])
result = result.replace(RegExp(`<!--\\s<${tag[1]}>\\s-->\\n.*<!--\\s<\\/${tag[1]}>\\s-->`, 'm'), `<!-- <${tag[1]}> -->\n${markdownFile}\n<!-- </${tag[1]}> -->`)
}
return result
}

async getContent(file) {
const { data } = await axios.get(`https://raw.githubusercontent.com/pinpoint-apm/pinpoint/master/doc/${file}`, { responseType: 'text' })
return data
}
}

module.exports = TemplateEngine

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading