-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ts_library problem bazelbuild/rules_typescript#263
- Loading branch information
Oleg Smetanin
committed
Oct 26, 2018
1 parent
754dc17
commit 952c322
Showing
8 changed files
with
205 additions
and
4 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
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,58 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary") | ||
|
||
# nodejs_binary( | ||
# name = "web", | ||
# visibility = ["//visibility:public"], | ||
# entry_point = "gobazel/build/copy.js", | ||
# data = [ | ||
# ":copy.js", | ||
# "//web:copy" | ||
# ] | ||
# ) | ||
|
||
nodejs_binary( | ||
name = "copy", | ||
visibility = ["//visibility:public"], | ||
# entry_point = "gobazel/node_modules/ts-node/dist/bin.js", | ||
entry_point = "gobazel/build/copy.js", | ||
install_source_map_support = False, | ||
# node_modules = "//:node_modules", | ||
|
||
# node_modules = "@npm//:node_modules" | ||
data = [ | ||
":copy.js" | ||
# "//:tsconfig.build.json", | ||
], | ||
) | ||
|
||
|
||
genrule( | ||
name = "build", | ||
srcs = [ | ||
# "//web:copy", | ||
":copy.js", | ||
"//web:lib", | ||
"//backend/cmd/service:service" | ||
# "//publicapi:publicapi" | ||
|
||
], | ||
outs = ["service", "frontend"], | ||
cmd = "node dist/copy.js $(location //backend/cmd/service:service) $(location //web:lib) $(@D)", | ||
# cmd = "echo \"hello\"; pwd; echo $(location tsnode); $(location tsnode) $(location copy.ts)", | ||
# cmd = "$(location tsnode) $(location copy.ts) $(location web)", | ||
# cmd = "$(location babel) src --out-dir $@", | ||
tools = [":copy"], | ||
) | ||
|
||
|
||
genrule( | ||
name = "ls", | ||
srcs = [ | ||
"//web:lib", | ||
], | ||
outs = ['qwe'], | ||
|
||
cmd = "ls `dirname $(locations //web:lib)`; ls `dirname $(location //web:lib)`; echo qwe > $(location qwe)", | ||
) |
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,64 @@ | ||
|
||
// console.log(process.env) | ||
console.log(process.argv) | ||
|
||
|
||
|
||
const path = require('path'); | ||
const fs = require('fs'); | ||
const shell = require('shelljs'); | ||
|
||
// function readFile(srcPath) { | ||
// return new Promise(function (resolve, reject) { | ||
// fs.readFile(srcPath, 'utf8', function (err, data) { | ||
// if (err) { | ||
// reject(err) | ||
// } else { | ||
// resolve(data); | ||
// } | ||
// }); | ||
// }) | ||
// } | ||
|
||
// function writeFile(savPath, data) { | ||
// return new Promise(function (resolve, reject) { | ||
// fs.writeFile(savPath, data, function (err) { | ||
// if (err) { | ||
// reject(err) | ||
// } else { | ||
// resolve(); | ||
// } | ||
// }); | ||
// }) | ||
// } | ||
|
||
// const wsDir = process.env.BUILD_WORKSPACE_DIRECTORY; | ||
|
||
|
||
|
||
// const in_file = process.argv[2] | ||
// const out_file = process.argv[3] | ||
const dest = process.argv[process.argv.length-1] | ||
|
||
// console.log('Read ', in_file) | ||
console.log('pwd:', process.cwd()) | ||
console.log(shell.ls(process.cwd())) | ||
|
||
console.log('Write ', dest) | ||
|
||
shell.mkdir('-p', path.join(dest, 'frontend')) | ||
shell.cp(process.argv[2], dest) | ||
console.log('front path', path.dirname(process.argv[3])) | ||
console.log(shell.ls('-R', path.resolve(path.dirname(process.argv[3]), '../' ))) | ||
shell.cp(path.dirname(process.argv[3]), path.join(dest, 'frontend')) | ||
// shell.cp(process.argv[3], path.join(dest, 'frontend')) | ||
|
||
|
||
|
||
// readFile(in_file) | ||
// .then(function(results){ | ||
// results+=" test manipulation"; | ||
// return writeFile(path.join(out_file, 'qwe.txt'), results); | ||
// }).then(function(){ | ||
// //done writing file, can do other things | ||
// }) |
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,3 @@ | ||
|
||
console.log('TS!!!!') | ||
console.log(process.argv) |
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,42 @@ | ||
|
||
// console.log(process.env) | ||
// console.log(process.argv) | ||
|
||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
function readFile(srcPath) { | ||
return new Promise(function (resolve, reject) { | ||
fs.readFile(srcPath, 'utf8', function (err, data) { | ||
if (err) { | ||
reject(err) | ||
} else { | ||
resolve(data); | ||
} | ||
}); | ||
}) | ||
} | ||
|
||
function writeFile(savPath, data) { | ||
return new Promise(function (resolve, reject) { | ||
fs.writeFile(savPath, data, function (err) { | ||
if (err) { | ||
reject(err) | ||
} else { | ||
resolve(); | ||
} | ||
}); | ||
}) | ||
} | ||
|
||
// const wsDir = process.env.BUILD_WORKSPACE_DIRECTORY; | ||
|
||
console.log('Copy ', path.join(__dirname, 'index.html')) | ||
|
||
readFile(path.join(__dirname, 'index.html')) | ||
.then(function(results){ | ||
results+=" test manipulation"; | ||
return writeFile(path.join(__dirname, 'index1.html'),results); | ||
}).then(function(){ | ||
//done writing file, can do other things | ||
}) |
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