I've come across this error when building grammar for a parser, using nearley.js. I have three files: grammar.ne, grammar.js, and parser.js. The full error is below:
$ ./.config/build.sh
> error: Two output files share the same path but have different contents: .build/grammar.js.map
> error: Two output files share the same path but have different contents: .build/grammar.js
exit status 1
Here are the contents of each of the files:
grammar.ne:
main -> (statement "\n"):+
statement -> "foo" | "bar"
grammar.js:
// Generated automatically by nearley, version 2.20.1
// http://github.com/Hardmath123/nearley
import Lexer from './lexer';
(function() {
function id(x) { return x[0]; }
var grammar = {
Lexer: Lexer,
ParserRules: [
{ "name": "main$ebnf$1$subexpression$1", "symbols": ["statement", { "literal": "\n" }] },
{ "name": "main$ebnf$1", "symbols": ["main$ebnf$1$subexpression$1"] },
{ "name": "main$ebnf$1$subexpression$2", "symbols": ["statement", { "literal": "\n" }] },
{ "name": "main$ebnf$1", "symbols": ["main$ebnf$1", "main$ebnf$1$subexpression$2"], "postprocess": function arrpush(d) { return d[0].concat([d[1]]); } },
{ "name": "main", "symbols": ["main$ebnf$1"] },
{ "name": "statement$string$1", "symbols": [{ "literal": "f" }, { "literal": "o" }, { "literal": "o" }], "postprocess": function joiner(d) { return d.join(''); } },
{ "name": "statement", "symbols": ["statement$string$1"] },
{ "name": "statement$string$2", "symbols": [{ "literal": "b" }, { "literal": "a" }, { "literal": "r" }], "postprocess": function joiner(d) { return d.join(''); } },
{ "name": "statement", "symbols": ["statement$string$2"] }
]
, ParserStart: "main"
}
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
module.exports = grammar;
} else {
grammar = grammar;
}
})();
const nearley = require("nearley");
const grammar = require("./grammar.js");
const parser = new nearley.Parser(nearley.Grammar.fromCompiled(grammar));
parser.feed("foo\n");
console.log(JSON.stringify(parser.results));
Nothing that I have found online has helped at all. This is built in a TypeScript repl, and I have a lexer written in TypeScript, if that helps any.
I figured out the issue. In my package.json, I had used the module "es2015" when I should have been using "commonjs". I then changed the file extension of grammar.js to .cjs, and that got rid of all of the automatically-generated code errors. I also added a script to the package json npx nearleyc grammar.ne -o grammar.cjs && node parser.cjs, which allows me to execute compiling the grammar file faster, and uses the new .cjs extension to compile it to a CommonJS module; this also allows me to run the test file at the same time.
Related
When using the graphql-tools JsonFileLoader with the follow schema.json:
{
"UserObjectType": {
"id": "Int",
"username": "String",
"firstName": "String",
"lastName": "String",
"avatar": "AvatarObjectType",
"dateCreated": "DateTime",
"notificationPreferences": "GenericScalar"
},
"AvatarObjectType": { "id": "Int", "avatarUrl": "String" },
"scalar": ["DateTime", "GenericScalar"],
"Query": {
"GetCurrentUser": "UserObjectType"
}
}
I get the following error:
Unable to find any GraphQL type definitions for the following pointers:
- UserObjectType
,
- AvatarObjectType
,
- scalar
,
- Query
at prepareResult (dist/load/src/load-typedefs.js:70:15)
at loadTypedefs (dist/load/src/load-typedefs.js:35:12)
Here's my code:
const JSONSchema = await loadSchema(schema, {
loaders: [new JsonFileLoader()],
});
const mocks = {
String: () => "abc",
Int: () => 56,
UserObjectType: () => ({
firstName: "John",
lastName: "Smith",
}),
};
// Create a new schema with mocks
const schemaWithMocks = addMocksToSchema({
schema: JSONSchema,
mocks,
});
Reproduction repo is here and more specifically, the test where I use JSONFileLoader is here.
EDIT: I used #graphql-codegen/cli's introspection plugin to generate a new JSON which you can find here.
When loading this into my test, I get a similar error:
graphql-tools › Runs mocked Schema with JsonFileLoader
Unable to find any GraphQL type definitions for the following pointers:
- __schema
at prepareResult (dist/load/src/load-typedefs.js:70:15)
at loadTypedefs (dist/load/src/load-typedefs.js:35:12)
I tried omnibox with the following code from MDN. When I trying, I temporarily loaded manifest.json from about:debugging. This worked in a normal browser, and typing cs a show a some suggestion.
However, this suggestion feature is not working in private mode. This did not change even if I allowed it to run in a private window.
How can I get the omnibox suggestion feature to work in private mode?
browser.omnibox.setDefaultSuggestion({
description: "Type the name of a CSS property"
});
/*
Very short list of a few CSS properties.
*/
const props = [
"animation",
"background",
"border",
"box-shadow",
"color",
"display",
"flex",
"flex",
"float",
"font",
"grid",
"margin",
"opacity",
"overflow",
"padding",
"position",
"transform",
"transition"
];
const baseURL = "https://developer.mozilla.org/en-US/docs/Web/CSS/";
/*
Return an array of SuggestResult objects,
one for each CSS property that matches the user's input.
*/
function getMatchingProperties(input) {
var result = [];
for (prop of props) {
if (prop.indexOf(input) === 0) {
console.log(prop);
let suggestion = {
content: baseURL + prop,
description: prop
}
result.push(suggestion);
} else {
if (result.length != 0) {
return result;
}
}
}
return result;
}
browser.omnibox.onInputChanged.addListener((input, suggest) => {
suggest(getMatchingProperties(input));
});
browser.omnibox.onInputEntered.addListener((url, disposition) => {
switch (disposition) {
case "currentTab":
browser.tabs.update({url});
break;
case "newForegroundTab":
browser.tabs.create({url});
break;
case "newBackgroundTab":
browser.tabs.create({url, active: false});
break;
}
});
My manifest.json follows below:
{
"manifest_version": 2,
"name": "text",
"version": "1.0",
"description": "text",
"background": {
"scripts": [
"background.js"
]
},
"omnibox": {
"keyword": "cs"
},
"permissions": [
"bookmarks",
"tabs"
]
}
Windows 10
Firefox 84.0.1 (64 bit)
my Test config file is not able to find the spec file. i already have spec files created. previously i ran those scripts also.. but for more framework update i updated the paths of the files.. that makes spec files error and even i gave the full path also it is not able to find the spec file.
Spec File
var utilityInit,page2//browser2;
page1=new facebook(firstBrowser);
module.exports=function(){
this.Given(/^Open the browser and Load the URL$/,async function(){
await firstBrowser.get(properties.get("url1"));
browser.logger.info("Title of the window is :"+await browser.getTitle());
//screenshots.takesScreenshot("filename");
});
this.When(/^User entered the text in the search box$/,async function(){
firstBrowser.sleep(3000);
await page1.email().sendKeys(testData.Login.CM[0].Username);
browser.sleep(3000);
await page1.password().sendKeys(testData.Login.CM[0].Password);
});
this.Then(/^click on login button$/,async function(){
browser.sleep(3000);
await facebook.submit().click();
});
this.Then(/^User tried to open in new browser instance$/,async function(){
browser2=await openNewBrowser.newBrowserInit(firstBrowser);
utilityInit=new utility(browser2);
utilityInit.ignoreSync(properties.get("url2"));
browser2.manage().window().maximize();
console.log(await utilityInit.title()+" title");
browser2.sleep(5000);
});
this.When(/^User entered the text in the email field$/,async function(){
page2=new facebook(browser2);
console.log(await page2.title()+" browser2");
await page2.search().sendKeys("testing");
browser2.sleep(3000);
page1=new facebook(firstBrowser);
console.log(await page1.title()+" browser1")
await page1.email().sendKeys(testData.Login.CM[0].Username);
screenshots.takeScreenshot("newScreenshot");
firstBrowser.sleep(5000);
})
}
Config file
const log4js = require('log4js');
var fs=require('fs');
global.screenshots = require('protractor-take-screenshots-on-demand');
global.browser2;
var propertiesReader=require('properties-reader');
exports.config = {
//seleniumAddress: 'http://localhost:4444/wd/hub',
directConnect:true,
framework: 'custom',
// path relative to the current config file
frameworkPath: require.resolve('protractor-cucumber-framework'),
capabilities: {
'browserName': 'chrome',
metadata: {
browser: {
name: 'chrome',
version: '79'
},
device: 'MacBook Pro 15',
platform: {
name: 'OSX',
version: '10.12.6'
},
disableLog:true,
durationInMS:true,
openReportInBrowser:true
}
},
ignoreUncaughtExceptions:false,
// Spec patterns are relative to this directory.
specs: [
'../Proc/src/test/java/com/proc/features/test.feature'
],
beforeLaunch:function(){
if (fs.existsSync('./logs/ExecutionLog.log')) {
fs.unlink('./logs/ExecutionLog.log')
}
log4js.configure({
appenders: {
out: { type: 'console' },
info:{ type: 'dateFile', filename: '../Reports/logs/info', "pattern":"-dd.log",alwaysIncludePattern:false},
"console" : {
"type": "console",
"category": "console"
},
"file" : {
"category": "test-file-appender",
"type": "file",
"filename": "../Reports/logs/log_file.log",
"maxLogSize": 10240,
// "backups": 3,
// "pattern": "%d{dd/MM hh:mm} %-5p %m"
}
},
categories: {
"info" :{"appenders": ["console"], "level": "info"},
"default" :{"appenders": ["console", "file"], "level": "DEBUG"},
//"file" : {"appenders": ["file"], "level": "DEBUG"}
}
});
},
cucumberOpts: {
require:['../src/test/resources/com.proc.utility/timeOutConfig.js','../src/test/java/com/proc/TestCases/spec.js'],
tags: false,
profile: false,
format:'json:../Reports/jsonResult/results.json',
'no-source': true
},
onPrepare: function () {
const logDefault = log4js.getLogger('default');
const logInfo=log4js.getLogger('info');
screenshots.browserNameJoiner = ' - '; //this is the default
//folder of screenshot
screenshots.screenShotDirectory = '../Screenshots';
global.openNewBrowser=require("../src/test/resources/com.proc.utility/newBrowserinstance.js")
global.testData=require("../TestData/testData.json");
browser.logger = log4js.getLogger('protractorLog4js');
global.firstBrowser=browser;
global.properties=propertiesReader("../TestData/propertyConfig.properties");
browser.waitForAngularEnabled(false);
browser.manage().window().maximize();
global.facebook=require("../src/test/java/com/proc/pages/fbPageObjects.js");
global.utility=require("../src/test/resources/com.proc.utility/testFile.js");
},
plugins: [{
package: '../Proc/node_modules/protractor-multiple-cucumber-html-reporter-plugin',
options:{
// read the options part for more options
automaticallyGenerateReport: true,
removeExistingJsonReportFile: true,
reportPath:"../Reports/HtmlReports",
reportName:"test.html"
},
customData: {
title: 'Run info',
data: [
{label: 'Project', value: 'Framework Setup'},
{label: 'Release', value: '1.2.3'},
{label: 'Cycle', value: 'Test Cycle'}
]
},
}]
};
Log
H:\workspace\Proc\Configuration>protractor testConfig.js
[23:38:00] I/launcher - Running 1 instances of WebDriver
[23:38:00] I/direct - Using ChromeDriver directly...
DevTools listening on ws://127.0.0.1:51680/devtools/browser/e9688f83-2047-4535-91ba-bf2100fe6016
0 scenarios
0 steps
0m00.000s
can some one please help me to clear this issue.. this is related to my project framework POC..
To clarify some other comments I have seen being made by others here, you do not have to give the exact file path. You can do
specs: [
'../Proc/src/test/java/com/proc/features/']
This path does not look correct to me ^ are you sure that is the correct path? also you have a javascript project but your file structure is a java structure src/test/java why?
it's a simple thing that makes my framework works..
npm install cucumber#1.3.3 --save-dev
This because of the Spec path
specs: [
'../Proc/src/test/java/com/proc/features/test.feature' //Provide a complete path to your test file along with file extension(.ts)
],
Hope it helps you
Here's the link to the api: https://developers.google.com/sheets/api/reference/rest/
I'm trying to figure out how to save this spreadsheet to a folder in google drive. The only thing I've found is this: (https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.sheets/copyTo)
The problem is, I get errors when I do "destinationSpreadsheetId": folder id inside the properties. So I'm not sure if that is the right way to do it or if there even is a way to create a new spreadsheet into a folder using sheets api v4.
Sheets.Spreadsheets.create({
"sheets": [
{
"properties": {
"gridProperties": {
"rowCount": 1,
"columnCount": 3
}
},
"data": [
{
"rowData": [
{
"values": [
{
"userEnteredValue": {"stringValue": "one"}
},
{
"userEnteredValue": {"stringValue": "two"}
},
{
"userEnteredValue": {"stringValue": "three"}
}
]
}
]
}
]
}
],
"properties": {
"title": name
}
});
Also, how would I get a spreadsheets id by a name being passed into a function?
function getSpreadsheetId(name)
{
//get file 'name' id from folder
}
I'm following the official documentation page about the topic but I cannot configure it to ignore .txt files.
I have a all.profile.js on the root of my project:
var profile = (function(){
return {
basePath: "./",
releaseDir: "../web",
action: "release",
layerOptimize: "closure",
optimize: "closure",
cssOptimize: "comments",
mini: true,
stripConsole: "all",
packages: [
{ name: "myapp", location: "myapp" }
]
};
})();
And this is the package.json inside the folder myapp:
{
"dojoBuild": "myapp.profile.js",
"name": "my-app",
"description": "This is My App",
"version": "1.0",
"main": "src"
}
And this is the myapp.profile.js also inside the folder myapp:
var profile = (function(){
return {
// don't need to do anything on the 'test' folder so don't define it on the trees.
trees: [
["libs","libs",/txt$/], // ignore .txt files -> DOESN'T WORK!
["src","src",/txt$/] // ignore .txt files -> DOESN'T WORK!
],
resourceTags: {
test: function(filename, mid){
console.log("[test] filename: ",filename);
return filename.indexOf("test/") !== -1;
},
copyOnly: function(filename, mid){
//console.log("[copyOnly] mid: ",mid);
return false;
},
miniExclude: function (filename, mid) {
console.log("[miniExclude] filename: ",filename);
return mid in {
'myapp/myapp.profile': 1,
'myapp/package.json': 2
} || mid.indexOf(".txt") !== -1; // .txt are not ignored so exclude them...
},
amd: function(filename, mid) {
//console.log("[amd] mid: ",mid);
// myapp is not AMD but this will 'convert' it
return false;
}
}
};
})();
Finally, this is the folder structure:
web_dev/
-- myapp/
---- libs/
---- src/
---- test/
---- myapp.profile.js
---- package.json
-- all.profile.js
The build tool runs fine, it reads and process all files but the .txt files are still on the release dir.
Please let me know if you spot any mistakes on my logic or how I'm configuring the build system. I'm using Dojo 1.9.1.
Thanks in advance.
I'm not sure what is wrong with my initial scenario but here are the changes that I made to have the desired result:
Move the trees declaration from the myapp.profile.js to
all.profile.js inside the 'myapp' package definition.
Instead of specifying the root of the trees, check
everything and exclude accordingly: [".", ".",
/(\/\.)|(~$)|(test|txt)/]
The final all.profile.js:
var profile = {
basePath: "./",
releaseDir: "../web",
releaseName: "built",
action: "release",
layerOptimize: "closure",
optimize: "closure",
cssOptimize: "comments",
mini: true,
stripConsole: "all",
packages: [
{
name: "myapp",
location: "myapp",
trees: [
// don't bother with .hidden, tests and txt.
[".", ".", /(\/\.)|(~$)|(test|txt)/]
]
}
]
};
If anyone can pin point exactly what I was doing wrong, please share.