How to select which file is previewed in codesandbox - codesandbox

I have a imported project in which I have files with following structure:
dir1
index1.html
dir2
index2.html
prewiew is showing me index1.html How would I change it to show index2.html in prewiew? I tried to change package.json file main attribute to "/dir2/index2.html" but it does not work

Codesandbox does not open the "main" file on opening a sandbox - it executes the "build" and "start" scripts in package.json (and other related scripts, such as pre-builds, etc), since that's what it needs to do to prep a package for running in their preview browser and/or node instance.

Related

VSCode: how to structure a simple python package with few modules and tests, debugging and linting?

I'm having more trouble than I'd like to admit to structure a simple project in Python to develop using Visual Studio Code.
How should I structure in my file system a project that is a simple Python package with a few modules? Just a bunch of *.py files together. My requisites are:
I must be able to step debug it in vscode.
It has a bunch of unit tests using pytest.
I can select to debug a specific test from vscode tab and it must stop in breakpoints.
pylint must not show any false positives.
The test files must be in a different directory of the main module files.
I must be able to run all the tests from the console.
The module is executed inside a virtual environment using python standard lib module venv
The code will use type hints
I may use another linter, even another test framework.
Nothing fancy, but I'm really having trouble to get it right. I want to know:
How should I organize my subdirectory: a folder with the main files and a sibling folder with the tests? Or a subfolder with the code and a subsubfolder with the tests?
Which dirs must have a init.py file?
How the tests should import the files from the module? Should I use relative imports?
Should I create a pytest.ini file?
Should I create a .env file?
What's the content of my launch.json the debugger file config in vscode?
Common dir structure:
app
__init__.py
yourappcode.py
tests (pytest looks for this)
__init__.py
test_yourunittests.py
server.py if you have one
.env
.coveragerc
README.md
Pipfile
.gitignore
pyproject.toml if you want
.vscode (helpful)
launch.json
settings.json
Or you could do one better. Ignore my structure and look at the some of famous python projects github page. Like fastAPI, Flask, asgi, aiohttp are some that I can think of right now
Also:
I think absolute imports are easier to work with compared to relative imports, I could be wrong though
vscode is able to use pytest. Make sure you have a testing extension. Vscode has a built in one im pretty sure. You can configure it to pytest and specify your test dir. You can also run your test from command line. If youre at the root, just running ‘pytest’ will recognise your tests dir if it’s named that by default. Also your actual test files need to start with prefix test_ i think.
The launch.json doesn’t need to be anything special. When you click on the settings button next to play button in the debug panel. Vscode will ask what kind of app is it. I.e If its a flask app, select python then select flask and it will auto generate a settings file which you can tweak however you want in order to get your app to run. I.e maybe you want to expose a different port or the commands to run your app are different
It sounds to me like you just need to spend a bit of time configuring vscode to your specific python needs. For example, you can use a virtualenv and linting in whichever way you want. You just need to have a settings.json file in the .vscode folder in your repo where you specify your settings. Configurations to specify python virtualenv and linting methods can be found online

How to open a specific folder when debugging VS Code extension?

I've developed an extension that reads a directory's package.json file. For the extension to work, you must be inside of a JavaScript file. I'm attempting to test this extension by using a test directory inside of the extension's src directory that houses a package.json file and an index.js file.
My goal is to allow the test to open the directory, open the index.js file and the run the tests there. This way the test directory goes anywhere the extension goes and the tests are predictable based on the package.json file I put into place.
How do I get the tests to open that test directory and run the tests from that specific index.js file?
I figured it out. I had to add the path to the directory into "args" array of the Extension Test object in launch.json.
"args": [
"${workspaceFolder}/src/test/test-directory/",
"${workspaceFolder}/src/test/test-directory/index.js",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test"
]
I was also able to have index.js open up as well. All of which I realized were totally useless in the tests that I were doing. But at least now I know how to do it and maybe someone else will, too.
Also, if you don't add ${workspaceFolder} in front of the directory you are referencing, VS Code assumes you want a new file created. So instead of opening the index.js file that I had available, it was creating a new empty file named index.js.

How to run files as a project in VS Code?

I'm trying to learn Vue.js as well so I create a simple folder called VueTest.
I have two files in the folder:
app.js
index.html
I found the info on how to configure the task runner to open up the current file and I have that setup to open in Chrome, which it does. However, because it's not running as a project, my index.html doesn't see the app.js file and so my Vue project is not working correctly. I just runs the HTML code an all I see is my mustache code (ex: {{Title}}).
How do I run files as a project?
If get it correct - you want to launch js app without opening teminals outside 'VS Code' then you have to see this
Have fun
I found my mistake, it's actually easy and I should have figured this out before posting.
To run Index.html on it's own, all I had to do was make a script reference in the page pointing to the app.js file. I didn't have to do that in JsFiddle.
you can't run files as a project in VS Code. it is just a text editor.

Change .vscode folder location

I'm programming a client side applications using SharePoint Designer 2013.
I want to change to VSCODE since it supports a lot of extensions for some Javascript library like angular, jQuery. And because of the Chrome/Node.js debugger extension.
But when I try to start any Debugger, I got the error:
Unable to create 'launch.json' file inside the '.vscode' folder (Error: UNKNOWN: unknown error, mkdir '\\servername\DavWWWRoot\sitename\Style Library\.vscode').
I get this error because it's impossible to create a folder in SharePoint where the name starts with dot.
So there's a possibility to change the name of this folder or the file location to any directory in my local computer?
No, it's not possible to move/rename that folder. VS code is a tool that bases project management on folder content. So it is essential that the project settings reside in the folder being managed.
You can move the "extensions" folder, but unfortunately not the argv.json (so the ".vscode" will, at least be recreated on vscode launch)
https://github.com/microsoft/vscode/issues/17691#issuecomment-559234574
I hope that'll finally change sometime .
https://github.com/microsoft/vscode/issues/3884
https://github.com/OmniSharp/omnisharp-roslyn/issues/953

Less Compiling Doesn't work for me in Netbeans 8.1 beta

I want to start using the option to compile my less files from within an html5 project in netbeans 8.1 (Windows 7). However it doesn't work for me.
1 . I npm installed less from the command line with -g option flag.
I opened up the tools...options...html/js menu and placed the path in the less path input box. I hit apply and then ok.
I made a change to my less file and hit the run button and it shows that it compiled in the output dialog box.
Message shown:
"C:\Users\Larry\AppData\Roaming\npm\lessc.cmd" "--source-map"
"--source-map-rootpath=../less" "--source-map-url=style.css.map"
"C:\Users\Larry\Desktop\interface\public_html\less\style.less"
"C:\Users\Larry\Desktop\interface\public_html\css\style.css" Done.
I have tried exiting netbeans and then loading it back up but it will still not work. I have even tried loading a new project with a different less file and it still doesn't work.
I would appreciate any suggestions.
It must have been something with the beta release of Netbeans 8.1. I downloaded and installed the production release of Netbeans 8.1. I then had to re add the path to the lessc.cmd file as described in step 2 of my question(step below).
I opened up the tools...options...html/js menu and placed the path in
the less path input box. I hit apply and then ok.
I then placed my less file with the same name as my css file in a folder named less in the root directory of my project. Now when I save or run my project the changes are reflected in my css file.
Note: Make sure you have a folder named css and less in your projects root directory and place the respective css and less files with the same name in the appropriate folders.
Example:
MyProject(root directory folder)
| |
less(Folder) css(Folder)
| |
style.less style.css