Running Silverstripe with MAMP and Gulp - gulp

I'm trying to set up a local dev environment for a Silverstripe build which was set up by someone else. I'm not all that familiar with Silverstripe so am a bit lost as to how to do this. I can't share much of the code for security reasons but I can see that gulp is used for watching the local changes. Happy to provide what ever else is needed to get this going just cant provide specifics obviously.
Here is what I've done so far:
installed MAMP
cloned Repo to the htdocs folder within MAMP
run composer install in the root and npm install in the theme directory
turned on the MAMP server - am redirected to localhost:8888
have gone to the localhost:8888/repo and am shown the error - cannot find index.php
When I run gulp the browser opens a localhost:3000 page but it never completes loading, rather it hangs.
I understand the index.php error but the previous dev had this running with the current set up so I am hoping to not move anything around just yet. There is a 'public' folder with an index.php file in it if there is a way I can tell the server to look here for it.
composer.json Contents:
{
"name": "silverstripe/installer",
"type": "silverstripe-recipe",
"description": "The SilverStripe Framework Installer",
"require": {
"php": ">=5.6.0",
"silverstripe/recipe-plugin": "^1.2",
"silverstripe/recipe-cms": "4.2.1#stable",
"silverstripe-themes/simple": "~3.2.0",
"loeken/cryptocompare-api-php-wrapper": "dev-master",
"zendesk/zendesk_api_client_php": "^2.2",
"intercom/intercom-php": "^3.2",
"tractorcow/silverstripe-fluent": "^4",
"silverstripe/googlesitemaps": "dev-master",
"ryanpotter/silverstripe-cms-theme": "^3.3"
},
"require-dev": {
"phpunit/phpunit": "^5.7",
"deployer/deployer": "^6.2",
"lekoala/silverstripe-debugbar": "^2.0"
},
"extra": {
"project-files-installed": [
"app/.htaccess",
"app/_config.php",
"app/_config/mysite.yml",
"app/src/Page.php",
"app/src/PageController.php"
],
"public-files-installed": [
".htaccess",
"index.php",
"install-frameworkmissing.html",
"install.php",
"web.config"
]
},
"config": {
"process-timeout": 600
},
"prefer-stable": true,
"minimum-stability": "dev"
}
Any suggestions of what to try next would be greatly appreciated. Nothing I can find online seems to mention using gulp and MAMP in tandem - unsure If I'm just understand their purpose incorrectly.
Cheers

I need '50 reputation' to comment so I will instead reply as an answer.
It sounds like you are using SilverStripe version ^4.1, since you got the 'public' folder.
Do the following:
Make sure you got a .htaccess file in the root (outside public folder) which redirects all requests to the public folder:
(root .htaccess)
RewriteEngine On
RewriteRule ^(.*)$ public/$1
Run composer vendor-expose in the root to expose all files which should be accessed by the visitors, (custom css, js, images etc...). The files & folders that gets exposed are specified in the composer.json file under "expose": [...]. The files gets copied over to the public folder

Related

Yii 2 - Overriding files of mdm extension in vendor to extension folder using aliases in config

I have installed mdm extension for admin in basic version of Yii2, that is located in vendor directory and I want to override some files into extension directory for UI changes, I referred this link and added some code in web and console file as:
'aliases' => [
'#mdm/admin' => '#app/extensions/mdm/yii2-admin',
],
But no changes are reflected after doing this.
Most likely version installed by Composer conflicts with version which you unpacked manually. Instruction in documentation are for installing extension without using Composer, so they're definitely not considering the fact, that you have the same extension installed in two different places.
If you want to edit this extension you should uninstall composer version and copy whole extension into extensions/mdm/yii2-admin.
But probably better option would be to fork it, and add repository to your composer.json which will point to your fork:
"repositories": [
{
"type": "vcs",
"url": "https://github.com/yourname/yii2-admin.git"
}
],
And change dependency constraints to use master branch:
"require": {
"mdmsoft/yii2-admin": "dev-master as 2.8.0",
// ...
},
Then all necessary changes you're preforming in your fork (at https://github.com/yourname/yii2-admin.git) and fetching changes to main project using composer update mdmsoft/yii2-admin. It will simplify syncing changes from upstream - you just need to merge changes for upstream if you want to update your fork with lates changes from original extension repository.

Unable to save file: Permission denied Ubuntu

With the help of a YouTube tutorial, I am working on my first MEAN stack project. So far, I have created index.html, server.js and package.json files. When I installed Mongoose and Body-Parser using terminal, my package.json file stored in Documents showed updated dependencies for package.json like
{
"name": "njnjn",
"version": "0.0.1",
"dependencies": {
"body-parser": "^1.15.2",
"express": "^4.14.0",
"mongoose": "^4.7.5"
}
}
but I did not see updated dependencies on Atom which had something like
{
"name": "njnjn",
"version": "0.0.1",
"dependencies": {
"express": "^4.14.0"
}
}
So, I could not see the updated dependencies for Mongoose and body-parser on the package.json. I'm working on in Atom but I could see the updated dependencies for mongoose and body-parser on package.json in Documents.
I want the dependencies to be updated on both files: the one in Documents and the one I'm editing in Atom (I thought those files were supposed to be the same)
Also, when I tried saving my package.json on Atom(one without updated dependencies for Mongoose and body-parser), an error message popped up saying "Unable to save file: Permission denied." I don't think this error is associated with Atom only because I could not save my package.json file on Sublime as well.
How do I solve this problem so that dependencies for mongoose and body-parser will be updated on the package.json file in my text editor. And how can I save my package.json file on my text editor?
I tried searching everywhere for solution and saw a similar problem on Stack overflow for which the best solution told "to temporarily become root and edit the file:
sudo atom /path/to/file"
Because I'm new to Ubuntu, programming and command line, I did not understand the solution. Could you guys please help me?
you can set the permissions recursively.
sudo chmod -R 777 your file path
e.g.
sudo chmod -R 777 /path/to/file
for more information click on this link
"Permission denied" means that your current user have not the authentication to change the file. Only the owner of the files and root have the authentication to change them in default.
sudo+command means you will use root's authentication. This requires that your current user is in 'root' user group(That also means that your current user is in sudoers).
You can get more help here:https://en.wikipedia.org/wiki/Sudo
By the way, you are the owner of /home/yourUserName in default. Maybe your file should be created there?
This error occurs because of the following problem
1:- Those folders do you want to save your file is private that's why they say access denied
For salve, this problem follow the command
1 :- $ sudo su
2:- Go on that folder you want to save for example
$ cd Desktop
3:- $ chown -v user-name /foldername

Visual Studio Code debugging chrome, Breakpoints wont hit

I have a Angular2/typescript app I am developing in VSCode. I use Gulp to build the typescript files and gulp-sourcemap to create map files. Attaching/launching chrome works well after some tinkering with the chrome debug extension for VSCode, but I cannot get the breakpoints to hit. I run the website with "dnx web", but I don't think that should matter.
My folder structure is like this:
project/wwwroot/index.html
project/wwwroot/app/myfile.js
project/wwwroot/app/myfile.js.map
project/scripts/myfile.ts
My launch.json looks like this:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "chrome",
"request": "launch",
"url": "http://localhost:8001/portfolios",
"runtimeArgs": [
"--new-window", //Open in new window
"--user-data-dir=C:/temp/",
"--remote-debugging-port=9222"
],
"webRoot": "${workspaceRoot}/wwwroot",
"sourceMaps": true
}
]
}
and my gulp build task looks like this:
gulp.task('ts', function (done) {
var files = gulp.src(tsToMove)
.pipe(sourcemaps.init())
.pipe(ts(tsConfig), undefined, ts.reporter.fullReporter());
return files.js.pipe(sourcemaps.write(".",{sourceRoot: '../scripts'}))
.pipe(gulp.dest('scripts'));
})
I have verified that maps files are generated and stored in the same folder as the js files. when building.
Thanks for any hints.
Setting the workspace location to the location of my typescript files, and not my build files, worked for me.
Unverified Breakpoint (my compiled file location)
"webRoot": "${workspaceRoot}/build/client"
Working Breakpoint (my ts file location)
"webRoot": "${workspaceRoot}/client"
I feel I should mention that I am using the Debugger for Chrome extension
So I've been messing with this for hours and finally got it working: RVCA18 was right on with his answer:
You need to make sure that webRoot is set correctly, and correctly will depend on where you are running dnx from. If from your 'project' folder, then that's your actual webRoot.
You can also use your sourcemap file. If you open the file, it has a structure something like this:
{"version":3,"sources":[],"names":[],"sourcesContent":[]}
Find the sources prop which is an array of all of your source files. For example, if I search for one of my class names, I find the source to be something like: "webpack:///./app/components/TargetCard.js". I am using webpack and have a dir structure like below (simplified):
main
app
dist
which means that my webRoot as far as VSCode is concerned should equate to the dir one level above 'app', or 'main'. This is also where I run webpack from, so it makes sense. If I open the 'main' folder in VSCode, then my ${workspaceRoot} will also be 'main', so to have the debugger find my files I should set webRoot to simply be ${workspaceRoot}.
If you are using the debugger for chrome extension I would check that you are running chrome with remote debugging?
I was able to get mine working after I started running chrome with remote debugging.
from https://code.visualstudio.com/blogs/2016/02/23/introducing-chrome-debugger-for-vs-code
For now, Chrome needs to be started with remote debugging enabled, and only supports one concurrent connection. This means if you open up DevTools inside Chrome, the connection to VS Code will get terminated by Chrome. This is slightly annoying, and we hope this issue will be fixed sometime soon.
To do this i have a batch file that opens chrome with this command.
start /d "C:\Program Files (x86)\Google\Chrome\Application" chrome.exe --remote-debugging-port=9222
I totally agree with RVCA18. It's about the webRoot Setting that was wrong.
I had VS-Code ${workspaceRoot} pointing to a subfolder (just because I opened the project like that and had no script in the top-level folder). Since the index.html that is launched is in the top level folder I had to set the following Option in launch.json
"webRoot": "${workspaceRoot}/.."
For me, the problem occured in Visual Studio Code, using addons "Debugger for Chrome" with "Live Server".
I got it to work with the following settings:
Live Server's settings.json:
"liveServer.settings.AdvanceCustomBrowserCmdLine": "chrome --user-data-dir=C:/tmp --remote-debugging-port=9222",
launch.json:
"configurations": [
{
"name": "Attach to Chrome",
"port": 9222,
"request": "attach",
"type": "pwa-chrome",
"url": "http://127.0.0.1:5500/${relativeFile}",
"sourceMaps": true,
"webRoot": "${workspaceFolder}"
},

Firebase deploy error on public key / directory

I am building an IOS app using Firebase. I have an error when I try to deploy
"Error: Specified public directory does not exist, can't deploy hosting"
I have been following the hosting guide here Guide Link But being new learner, I am not understanding what should I put in firebase.json
So my code in firebase.json
{
"firebase": "xxxxxx", //(my app name)
"public": "/usr/local", //(I am not sure what should i put in here)
"ignore": [
"firebase.json",
"**.*",
"**/node_modules/**"
]
}
I am not sure what should I put in "public" property. I think that is the reason why I get the error. I don't understand what public directory mean in here.
Easily deploy and host your app's static assets (HTML, CSS,
JavaScript, etc) with our production-grade hosting service. All of
your content is served over HTTPS and backed by a global CDN.
It cleary states only static thing is expected to be hosted.
In "public" you are supposed to put dist (distribution) folder distination, In web apps Its a folder that contains all assets to keep app up and running on firebase hosting service.
Above answer is to clear Concept, Provide more details of your app and structure for further help.
what are you building your app with?
I imagine the cause of the error is that you need to generate a 'dist' folder for your app and you haven't done that yet before running 'firebase deploy'.
Check the firebase.json file in your project directory, it will show you that Firebase is looking for a dist folder to read from.
IF it can't find it, you will get the error that you have.
For instance, if it is an Angular2 application and you use the Angular-cli, just do the following:
Run the command 'ng build' in your project's root directory.
This command will generate a 'dist' folder from the 'src' folder where you wrote your application code.
Then run '
firebase deploy'.

Composer doesn't load repository packages from cache

When I install my app from a clean checkout, It always grabs my packages from my local repository as opposed to installing from cache like the remote packages.
My composer file:
{
"name": "app/name",
"description": "Desc",
"homepage": "http://homepage.com",
"repositories": [
{
"type": "composer",
"url": "http://packages.localrepository.com/",
"options": {
"http": {
"proxy": ""
}
}
}
],
"require": {
"php": ">=5.3.3",
"zendframework/zendframework": "2.*",
"guzzlehttp/guzzle": "4.*",
"local/health-check": "1.*",
"local/file-upload": "1.*",
"rediska/rediska": "dev-master"
}
}
This produces:
[exec] - Installing guzzle/guzzle (v3.9.2)
[exec] Loading from cache
[exec]
[exec] - Installing local/health-check (1.2.0)
[exec] Cloning f62651a1e2328a03ab7fd3fa8f84239ce7ee3a7c
This would be to accommodate the current build process that does a clean checkout each time. Any ideas?
The remote packages are hosted on Github or other hosting services that do provide a means to download ZIP or TGZ files of tagged releases. Composer knows the API of these services and tries to download the ZIP when appropriate (and you can try to force it by using --prefer-dist if it chose badly).
Your own hosted code isn't on Github, I assume. So if Composer doesn't know where to get a ZIP, the only other way is to clone the repository, no matter what the command line says (on the other hand, you can try to force cloning by using --prefer-source).
Note that neither of those two options guarantee anything - if Composer cannot download a ZIP it will clone - if it cannot clone, e.g. when the meta data of that package only mentions ZIP downloads, but no repository, it will download a ZIP.
Switching from one method to the other usually requires deleting the vendor folder as well as the composer.lock file, and then running Composer again. This will act as an update operation, so be warned that you will have to deal with this if it destroys your dependencies (i.e. you rely on branch names like "dev-master" instead of tagged versions).