Ionic 4 CLI can't generate service - ionic4

In my ionic 4 project directory I am doing
ionic g service api/login to create service through cli. But I am getting
[ERROR] type must be one of: component, directive, page, pipe, provider, tabs (not service)
Use the --help flag for more details.
then I seek for help ionic g --help so it giving me these examples
Examples:
$ ionic g
$ ionic g
$ ionic g component
$ ionic g directive
$ ionic g page
$ ionic g pipe
$ ionic g provider
$ ionic g tabs
$ ionic g component foo
$ ionic g page Login
$ ionic g page Detail --no-module
$ ionic g page About --constants
$ ionic g pipe MyFilterPipe
I cannot see service anywhere. How can I generate service an alternative way is also fine if you can suggest.

Use the command argument “provider” instead of service:
ionic g provider your-service
The terms provider and service are synonymous here.

Related

How to build container serving Vue SPA using Cloud Native Buildpacks

Currently I'm trying to build container serving VueJS application via Cloud Native Buildpacks.
I already have working Docker file that builds VueJS in production mode and then copy results to nginx image, but I would like to try to use CNB.
So I just have created empty VueJS project for test via vue create vue-tutorial and trying to do with CNB somehting like described there https://cli.vuejs.org/guide/deployment.html#heroku but using CNB.
Does anyone know working recipe how to do that with CNB?
P.S. Currently I'm trying to build that with
pack build spa --path . \  SIGINT(2) ↵  17:22:41
--buildpack gcr.io/paketo-buildpacks/nodejs \
--buildpack gcr.io/paketo-buildpacks/nginx
but getting next error (and I'm not sure that I'm on right way):
===> DETECTING
ERROR: No buildpack groups passed detection.
ERROR: Please check that you are running against the correct path.
ERROR: failed to detect: no buildpacks participating
ERROR: failed to build: executing lifecycle: failed with status code: 100
UPD
My current dockerfile
# build stage
FROM node:lts-alpine as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
# production stage
FROM nginx:1.19-alpine as production-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
We chatted about this in Slack, but I wanted to capture it here too:
pack build --buildpack heroku/nodejs --buildpack https://cnb-shim.herokuapp.com/v1/heroku-community/static yourimage
This command may do what you want. The static buildpack used in that example is not yet converted to a cloud native buildpack, but the shim may allow you to build a workable artifact. Then run your image with something like docker run -it -e PORT=5000 -p 5000:5000 yourimagename

How automate build number & app version of react-native ios app based on git-tag?

What I want to do is automating build number & app version of ios app based on git-tag. Previous native ios project, I automate build number of app using this script :
## Refer to https://www.mokacoding.com/blog/automatic-xcode-versioning-with-git/
git=$(sh /etc/profile; which git)
number_of_commits=$("$git" rev-list HEAD --count)
git_release_version=$("$git" describe --tags --always --abbrev=0)
target_plist="$TARGET_BUILD_DIR/$INFOPLIST_PATH"
dsym_plist="$DWARF_DSYM_FOLDER_PATH/$DWARF_DSYM_FILE_NAME/Contents/Info.plist"
for plist in "$target_plist" "$dsym_plist"; do
echo "plist :: $plist"
if [ -f "$plist" ]; then
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $number_of_commits" "$plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${git_release_version#*v}" "$plist"
fi
done
but, in react native app, not working!
While debuging, I found that target_plist & dsym_plist is not exist.
How do I make it work on React Native App?

Correctly upload react native source maps to Bugsnag

I'm trying to setup Bugsnag on my react native 0.59.1, but I am not able to properly upload source maps.
The bugsnag-react-native plugin is properly installed and linked and I see errors in my bugsnag dashboard, the only problem is to properly use the source maps.
What I tried
In one of my javascript files, I added a simple fake error:
Bugsnag.notify(new Error('Error'))
The, following the official documentation I generated the bundle file and the source maps:
react-native bundle \
--dev false \
--platform android \
--entry-file index.js \
--bundle-output android-release.bundle \
--sourcemap-output android-sourcemaps.map
I uploaded them to bugsnag:
curl https://upload.bugsnag.com/react-native-source-map \
-F apiKey="XXXXX" \
-F appVersion="10.0.2" \
-F appVersionCode="100004" \
-F dev=false \
-F platform=android \
-F sourceMap=#android-sourcemaps.map \
-F bundle=#android-release.bundle \
-F projectRoot=`pwd`
In my bugsnag settings I can see the source maps with the proper versions:
But in the error report I get:
Note: I checked and the versions of the source maps are the same of the version in the event App tab.
I honestly don't know what to try anymore, do you have some ideas?
I'd advise you raise this directly with us at Bugsnag via the Support link on the dashboard so we can look at the details of the errors on your account and advise on why the source maps aren't being applied.
Looking at that screenshot though I suspect the issue may be that you're using RAM bundles in which case you'd need to use the react-native ram-bundle command in place of react-native bundle:
https://docs.bugsnag.com/platforms/react-native/react-native/showing-full-stacktraces/#generating-source-maps
Thanks!

Use specific package name when setting up a react-native project

When creating a react-native app with react-native init MyApp the Android and iOS package names are automatically set to com.myapp.
Changing the Android package name (especially if you need something longer like com.organisation.propject.app) later in the development is pretty fiddly and I was wondering if there was a way to set the package name when setting up a project with react-native init?
Note: it's working only in RN 0.37 and maybe one or two versions up, in 0.40+ this feature was removed.
You need to specify a --package option:
$ react-native init MyApp --package=com.organization.project.app
The below worked for me. Substitute your own app name for "Foo App" and your own package name for org.newpackage.app.
NEW_APP_NAME="Foo App"
NEW_PACKAGE_NAME=org.newpackage.app
OLD_PACKAGE_NAME=org.reactjs.native.example
npx react-native init rndemo && \
cd rndemo && \
npx react-native-rename "${NEW_APP_NAME}" -b ${NEW_PACKAGE_NAME} && \
rm -rf ios/Pods && \
pod install --project-directory=./iOS && \
grep -rl ${OLD_PACKAGE_NAME} * | \
xargs sed -i '.bak' "s/${OLD_PACKAGE_NAME}/${NEW_PACKAGE_NAME}/g"
I've created a gist that does this, prompting interactively for the app name and package name. The gist is a tiny bit more sophisticated, in that (in the above example) it would initially create the app fooapp instead of rndemo.
Explanation:
Create a react-native app. It's called rndemo temporarily; we need to know what it's going to be called so we can change to it.
Run react-native-rename to rename the new project to whatever you specified; this lets us replace the package name too.
Remove the installed cocoa pods and reinstall them (so they'll pick up the new folder locations etc).
Search for the default package name org.reactjs.native.example and replace it with your new package name. Currently this will only find ios/FooApp.xcodeproj/project.pbxproj. The old project.pbxproj file will be saved with a '.bak' extension. This step would probably be better done with find . -name project.pbxproj -exec ..... but this was good enough for my needs.

How can I tell phantomJS to skip a section of a page when it compiles?

I have a site that uses the Yeti Launch app from Zurb to compile my site and make a dist version of it. However Yeti fails in building the site because phantomjs returns a (correct) error when compiling an external javascript file (the addthis plugin). So my question is, how can I tell phantom to skip a couple of lines of code? Much like a in HTML?
The line that makes phantom angry:
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-57056d887bbc9401"></script>
The error I get from Yeti:
$ TypeError: 'null' is not an object (evaluating 'e.split')
$ http://s7.addthis.com/js/300/addthis_widget.js#pubid=ra-57056d887bbc9401:1 in i
$ http://s7.addthis.com/js/300/addthis_widget.js#pubid=ra-57056d887bbc9401:6
$ http://s7.addthis.com/js/300/addthis_widget.js#pubid=ra-57056d887bbc9401:2
$ http://s7.addthis.com/js/300/addthis_widget.js#pubid=ra-57056d887bbc9401:9
$ http://s7.addthis.com/js/300/addthis_widget.js#pubid=ra-57056d887bbc9401:2 in r
$ http://s7.addthis.com/js/300/addthis_widget.js#pubid=ra-57056d887bbc9401:5
$ http://s7.addthis.com/js/300/addthis_widget.js#pubid=ra-57056d887bbc9401:5
$ Ended execution of digitaliserad.nu.