I cannot find the way to declare an array in an array with jsonnet. Here is the syntax I would like to render:
git/push/myrules:
rules:
- changes:
- package.json
- yarn.lock
I do succeed to setup changes as the first element of rules array
local git_push_instance() =
{
['rules']: [
'changes'
]
};
{
['git/push/myrules']: git_push_instance()
}
Here is the output of command line jsonnet rules.jsonnet
{
"git/push/myrules": {
"rules": [
"changes"
]
}
}
But how to setup changes as an array with 2 entries : package.json and yarn.lock ?
I try this but got an error:
local git_push_instance() =
{
['rules']: [
changes: ['package.json', 'yarn.lock']
]
};
{
['git/push/myrules']: git_push_instance()
}
STATIC ERROR: rules.jsonnet:4:16: expected a comma before next array
element.
The issue is that below construct has a key (changes:) while supposedly being an array entry:
['rules']: [
changes: ['package.json', 'yarn.lock'] // incorrect
]
You need to change the above to emit an array of (mini)objects instead:
['rules']: [
{ changes: ['package.json', 'yarn.lock'] },
]
Just for completeness, pasting below the src and its output:
rules.jsonnet
local git_push_instance() =
{
rules: [
{ changes: ['package.json', 'yarn.lock'] },
],
};
{
'git/push/myrules': git_push_instance(),
}
output
NB: piping it thru yq -PI2 for a cleaner YAML output:
$ jsonnet rules.jsonnet | yq -PI2
git/push/myrules:
rules:
- changes:
- package.json
- yarn.lock
Related
I am trying with following rollup.config.js file
import typescript from "rollup-plugin-typescript2";
import pkg from "./package.json";
import copy from 'rollup-plugin-copy'
import clean from 'rollup-plugin-clean';
export default [
{
input: "src/index.ts",
external: Object.keys(pkg.peerDependencies || {}),
watch: {
skipWrite: false,
clearScreen: false,
include: 'src/**/*',
//exclude: 'node_modules/**',
// chokidar: {
// paths: 'src/**/*',
// usePolling: false
// }
},
plugins: [
clean(),
copy({
targets: [
{ src: 'src/*', dest: 'dist' }
]
}),
typescript({
typescript: require("typescript"),
include: [ "*.ts+(|x)", "**/*.ts+(|x)", "*.d.ts", "**/*.d.ts" ]
}),
],
output: [
{ file: pkg.main, format: "cjs" },
{ file: pkg.module, format: "esm" },
{
file: "example/src/reactComponentLib/index.js",
format: "es",
banner: "/* eslint-disable */"
}
]
}
];
I want to rebuild when anything in src changes. I have couple of files which are not imported in .js and .ts files but I want them to copy in dist folder. copy is working fine but the watch is not picking up changes in those other files. Tried alot of variations on chokidar options but no luck yet.
Anyone have any idea how to resolve this?
watch.include only works on files pertaining to the module graph so if they are not imported they won't be included (https://rollupjs.org/guide/en/#watchinclude).
You can solve this by creating a small plugin that calls this.addWatchFile on those external files when the build starts. Here is an example:
plugins: [
{
name: 'watch-external',
buildStart(){
this.addWatchFile(path.resolve(__dirname, 'foo.js'))
}
}
]
Combine it with some globbing utility such as fast-glob and just call this.addWatchFile for every file you want to copy:
import fg from 'fast-glob';
export default {
// ...
plugins: [
{
name: 'watch-external',
async buildStart(){
const files = await fg('src/**/*');
for(let file of files){
this.addWatchFile(file);
}
}
}
]
}
My requirement is to generate a line number for every new line generated in the json message. The input message is having array inside array, i.e, parent and child array.
Input message
[
{
id:"1",
Details:[
{
Name:"RAM",
LastName:"Manohar",
DOB:"20-10-1990",
Report:[
{
DateOfJoin:"03-03-2019",
Dept:"HR",
BillCode:"acx-12s",
EffectiveDate:"03-03-2019"
},
{
DateOfJoin:"03-04-2019",
Dept:"HR",
BillCode:"abc-12s",
EffectiveDate:"03-04-2019"
},
{
Name:"Alex",
LastName:"Ham",
DOB:"20-11-1980",
Report:[
{
DateOfJoin:"03-03-2019",
Dept:"HR",
BillCode:"acx-12s",
EffectiveDate:"03-03-2019"
},
{
DateOfJoin:"03-04-2019",
Dept:"HR",
BillCode:"abc-12s",
EffectiveDate:"03-04-2019"
}
]
}
]
},
{
id:"2",
Details:[
{
Name:"Kiran",
LastName:"Kurella",
DOB:"20-10-1980",
Report:[
{
DateOfJoin:"03-03-2019",
Dept:"DC",
BillCode:"acx-12s",
EffectiveDate:"03-03-2019"
},
{
DateOfJoin:"03-04-2019",
Dept:"DC",
BillCode:"abc-12s",
EffectiveDate:"03-04-2019"
},
{
Name:"Sunil",
LastName:"Kumar",
DOB:"20-11-1980",
Report:[
{
DateOfJoin:"03-01-2019",
Dept:"DC",
BillCode:"acx-12s",
EffectiveDate:"03-03-2019"
},
{
DateOfJoin:"03-04-2019",
Dept:"DC",
BillCode:"abc-12s",
EffectiveDate:"03-04-2019"
}
]
}
]
}
]
}
]
}
]
expected output:
[{LineNumber:1,
Dept:"HR",
Name: "Ram"},
{LineNumber:2,
Dept:"HR",
Name: "Alex"},
{LineNumber:3,
Dept:"HR",
Name: "Kiran"},
{LineNumber:4,
Dept:"HR",
Name: "Sunil"}]
Linenumber needs to be generated sequentially and irrespective of parent array or sub array. any help on this will be very appreciated. I have the logic in which i can generate the number using java function but in that case i need to set the variable value (flow variable) inside data weave which can be used in the java function to call recursively.
Use:
payload map {
count: $$
}
When I run 'npm run build' I get the following error
ERROR in build.js from UglifyJs Unexpected token: punc (()
[build.js:11307,24]
The code that seems to be causing the issue is somewhere in the below code.
Note: When I remove methods: {} and created(){} the error is resolved.
I have also tried removing one function at a time from these two code blocks and nothing works until I completely remove both full sets of code blocks.
I can empty the "methods" code block and completely remove the "created" code block and it builds fine as well.
Also I do not have any issue running 'npm run dev'.
export default {
data: function() {
return {
currentSlide: 1,
slides: [
'slideshow-slide-1.png',
'slideshow-slide-2.png',
'slideshow-slide-3.png'
],
slideInfo: [
{ title: 'Commercial Truck Parts Wholesaler', description: 'All makes trucks parts, components and acillary products' },
{ title: 'Quality and Name-Brand Products', description: 'Direct ship program with mix and match capabilities' },
{ title: 'Fleet, Part Distributor or Service Facility?', description: 'Contact us to improve your parts procurement processa and reduce your inventory' }
],
myTimer: 0
}
},
methods: {
autoRotateImages() {
this.myTimer = setInterval(function() {
if (this.currentSlide < 3) {
this.currentSlide += 1;
} else {
this.currentSlide = 1;
}
}.bind(this), 5000);
},
changeSlide(index) {
this.currentSlide = index;
clearInterval(this.myTimer);
this.autoRotateImages();
},
getImageUrl(slide) {
return '/dist/'+slide;
}
},
created() {
this.autoRotateImages();
}
}
EDIT:
Using this in my webpack.config.js file
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['es2015']
}
I think this
created() {
this.autoRotateImages();
}
should be
created: function() {
this.autoRotateImages();
}.bind(this)
Are you transpiling your production code?
Try
npm cache clear -f
And than
npm install
May be it will solve issue
I have multiple s3 manifest files each corresponding to a date for a given date range. I am looking to merge all of the manifest files to generate a single manifest file, thus allowing me to perform a single Redshift copy.
manifest file 1:
{
"entries": [
{
"url": "DFA/20161001/394007-OMD-Coles/dcm_account394007_activity_20160930_20161001_050403_294198927.csv.gz"
}
]
}
manifest file 2:
{
"entries": [
{
"url": "DFA/20161002/394007-OMD-Coles/dcm_account394007_activity_20161001_20161002_054043_294865863.csv.gz"
}
]
}
I am looking for an output like:-
{
"entries": [
{
"url": "DFA/20161001/394007-OMD-Coles/dcm_account394007_activity_20160930_20161001_050403_294198927.csv.gz"
},
{
"url": "DFA/20161002/394007-OMD-Coles/dcm_account394007_activity_20161001_20161002_054043_294865863.csv.gz"
}
]
}
I did try
jq -s '.[]' "manifest_file1.json" "manifest_file2.json"
and other suggestions posted in Stackoverflow but couldn't make it work.
Or, without resorting to reduce:
$ jq -n '{entries: [inputs.entries[]]}' manifest_file_{1,2}.json
{
"entries": [
{
"url": "DFA/20161001/394007-OMD-Coles/dcm_account394007_activity_20160930_20161001_050403_294198927.csv.gz"
},
{
"url": "DFA/20161002/394007-OMD-Coles/dcm_account394007_activity_20161001_20161002_054043_294865863.csv.gz"
}
]
}
Note that inputs was introduced in jq version 1.5. If your jq does not have inputs, you can use jq -s as follows:
$ jq -s '{entries: [.[].entries[]]}' manifest_file_{1,2}.json
So if by "merge" you mean to combine the "entries" arrays into a single array by concatenating them, you could do this:
$ jq 'reduce inputs as $i (.; .entries += $i.entries)' manifest_file{1,2}.json
Which yields:
{
"entries": [
{
"url": "DFA/20161001/394007-OMD-Coles/dcm_account394007_activity_20160930_20161001_050403_294198927.csv.gz"
},
{
"url": "DFA/20161002/394007-OMD-Coles/dcm_account394007_activity_20161001_20161002_054043_294865863.csv.gz"
}
]
}
I'm using good plugin for my app, and I have copied the config parameters straight from the sample in the page, console and file are working , but good-http is not working!
here is my configuration:
myHTTPReporter: [
{
module: 'good-squeeze',
name: 'Squeeze',
args: [{error: '*', log: 'error', request: 'error'}]
},
{
module: 'good-http',
args: [
'http://localhost/log-request/index.php?test=23424', // <- test file I created to see if data is being sent or not
{
wreck: {
headers: {'x-api-key': 12345}
}
}
]
}
]
the only argument that is actually working is the ops: * and none of the error: *, ... is working
Am I missing something in my config parameters?
Maybe you should change the threshold parameter of the plugin, is set by default to 20 so it only send data after 20 events. If you want immediate results yo have to change it to 0.
myHTTPReporter: [
{
module: 'good-squeeze',
name: 'Squeeze',
args: [{error: '*', log: 'error', request: 'error'}]
},
{
module: 'good-http',
args: [
'http://localhost/log-request/index.php?test=23424', // <- test file I created to see if data is being sent or not
{
threshold: 0,
wreck: {
headers: {'x-api-key': 12345}
}
}
]
}
]