This question already has answers here:
How to share a closed source Flutter library written in Dart?
(3 answers)
Closed 9 months ago.
I am trying to distribute a library written in Dart, but reading this link https://dart.dev/guides/libraries/create-library-packages I found no mention to distributing a closed source library.
Is it possible? Is there is a way to generate something like a JAR and distributing it?
I guess the only way to achieve this is to share the complete project/library source code and then include the dependency from the local file system using path dependencies. See Dart documentation: https://dart.dev/tools/pub/dependencies#path-packages
I've done some research and according to it there's no way at the moment.
I've created an issue in Dart lang github: https://github.com/dart-lang/language/issues/1119.
Then I found existing issue, but there's no update there for a while: https://github.com/dart-lang/sdk/issues/37952
There are many ways to distribute a dart/flutter package. Check the full documentation at :
https://dart.dev/tools/pub/dependencies
1 Distribute package via git
You can share your package via a private git repository and give others access to it. They have to update their pubspec.yaml like this and need access to the git repository:
name: My Project
description: Foo Bar
dependencies:
kittens:
git: git://github.com/munificent/kittens.git
2 Distribute package via .zip
Another way ist to wrap the package in a .zip file, share it with other people. They need to extract the .zip and update their pubscpec.yaml file like this :
name: My Project
description: Foo Bar
dependencies:
kittens:
path: /Path/To/Extracted/Zip
3 Create your own package server
Create your own server that matches the pub api or start your own server from https://github.com/dart-lang/pub_server.
dependencies:
transmogrify:
hosted:
name: transmogrify
url: http://your-package-server.com
version: ^1.4.0
Related
How can I access a binary framework in the GitHub Release with SPM when the repo is private?
If I access my framework from a public repo then this works:
.binaryTarget(
name: “Xxxxxxx”,
url: "https://nexusxxxxx/nexus/content/repositories/xxxxx/multiplatformxc-release/1.2.3/multiplatformxc-release-1.2.3.zip",
checksum: checksum
)
But I want to access the same file from my github repo, which is private.
The file is generated and saved the GitHub Release section.
So, the URL is something like:
https://github.com/xxxxx-uk/xxxxx-multiplatform/releases/download/v1.2.3/xxxxxx-multiplatform.xcframework.zip
Evidently, if I use something like:
.binaryTarget(
name: “Xxxxxxx”,
url: "https://github.com/xxxxx-uk/xxxxx-multiplatform/releases/download/v1.2.3/xxxxxx-multiplatform.xcframework.zip",
checksum: checksum
)
is going to fail because it is private, in fact, this is the error message I see from SPM:
artifact of binary target ‘Xxxxxxx’ failed download: invalid status code 404
(that is, unauthorized)
Is it possible that somehow we can use SSH authentication?
(I am already using that for .package and it is working great)
If I use something like:
.binaryTarget(
name: “Xxxxxxx”,
url: "git#github.com:xxxxx-uk/xxxxx-multiplatform/releases/download/v1.2.3/xxxxxx-multiplatform.xcframework.zip",
checksum: checksum
)
is failing with this error:
invalid URL scheme for binary target ‘Xxxxxx; valid schemes are: https
(but as I said, it is working for packages)
So, is this technically possible? Thanks.
Unfortunately, this is not technically possible as of Xcode 13.
Downloading release assets in a private GitHub repo requires making an authenticated request that SPM doesn't currently support.
For the relevant discussion, see:
https://forums.swift.org/t/spm-support-basic-auth-for-non-git-binary-dependency-hosts/37878/35
I'm trying to add functionality to the serviceworker that create-react-app provides out of the box. Thankfully, cra-append-sw lets me do that without needing to eject from cra.
However, when installing cra-append-sw, npm gives me a warning that #babel/polyfill#7.4.4 has been deprecated (#babel/polyfill is listed as a cra-append-sw dependency):
As of Babel 7.4.0, this package has been deprecated in favor of directly including core-js/stable (to polyfill ECMAScript features) and regenerator-runtime/runtime (needed to use transpiled generator functions):
import "core-js/stable";
import "regenerator-runtime/runtime";
Then, when I try to npm run build to append a custom service worker, the build spits out a long error message, the top of which is:
ERROR in multi ./custom-sw.js
Module not found: Error: Can't resolve './custom-sw.js' in '/Users/michaelmersiades/workspace/vanilla-cra'
resolve './custom-sw.js' in '/Users/--/workspace/vanilla-cra'
using description file: /Users/--/workspace/vanilla-cra/package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration
and custom-sw.js is not showing up in the build folder.
Is this fixable? If so, how? Or is this an issue for the good ira-append-sw folk?
My thanks in advance to anyone who can help.
Silly error. The custom-sw.js file was inside /src, but it needed to be in / (the root folder).
Moving it to / solved the problem.
I am trying to add TestContainers-Go to my project. I use glide and TestNginxLatestReturn example from Github readme file.
In glide I put
- package: github.com/testcontainers/testcontainers-go
version: v0.0.3
but at runtime I get this error in IDEA.
# github.com/testcontainers/testcontainers-go
../../../../../../pkg/mod/github.com/testcontainers/testcontainers-go#v0.0.3/docker.go:326:32: p.client.DaemonHost undefined (type *client.Client has no field or method DaemonHost)
Any idea why I get this and how to fix it?
Have you tried with Go modules? I noticed glide's last commit is from 2'5 years ago, not sure if you're still using it.
With Go modules, it would be a matter of adding the dependency to your go.mod file. Something like this:
require (
github.com/testcontainers/testcontainers-go v0.12.0
)
You can find more info about installing it in project's docs: https://golang.testcontainers.org/quickstart/gotest/#1-install
Related to the current error with glide, it seems the Docker dependency in testcontainers-go v0.0.3 (docker/docker-v0.7.3) should include the client.DaemonHost method, which was added on 22 May 2017 in https://github.com/moby/moby/commit/6ce6ae1cd11d888e0c8ede20926b86981cee5ce1.
I recommend you using a newer version of the library (v0.12.0)
My client uses Stash (which it seems has been renamed Bitbucket Server) to host project repositories. We use a private Bower registry for our private libraries.
In this new project I am building, I am using JSPM. I have used jspm-git to create a stash registry. Getting the public libraries such as jQuery, Angular and Lodash obviously works fine.
I get into an issue when I run this:
jspm install mapped-name=stash:project-name/lib-name
Obviously the actual lib names are redacted to respect my client's intellectual property.
This is the error I get:
warn Error on build
TypeError: undefined is not a function
at Object.posix.isAbsolute (path.js:479:15)
at Object.posix.normalize (path.js:461:26)
at GitLocation.build ([REDACTED]/node_modules/jspm-git/git.js:426:17)
at [REDACTED]/node_modules/jspm/lib/registry.js:117:30
at lib$rsvp$$internal$$tryCatch ([REDACTED]/node_modules/jspm/node_modules/rsvp/dist/rsvp.js:493:16)
at lib$rsvp$$internal$$invokeCallback ([REDACTED]/node_modules/jspm/node_modules/rsvp/dist/rsvp.js:505:17)
at [REDACTED]/node_modules/jspm/node_modules/rsvp/dist/rsvp.js:1001:13
at lib$rsvp$asap$$flush ([REDACTED]/node_modules/jspm/node_modules/rsvp/dist/rsvp.js:1198:9)
at process._tickCallback (node.js:355:11)
I do not know if I forgot a step, or if I misconfigured something, or if there is even a bug with JSPM or jspm-git. Any guidances to help me debug this would be appreciated.
It turned out to be a missing publishConfig entry in the package.json file.
I had asked this question as well in the jspm-git repo, and a collaborator seems to agree that improving the error message could provide guidance. Some improvement to look forward to?
I hope this thread is of use to anyone that faces a similar issue.
I have created some local libraries in my dart lib directory.
These libraries are visible in dart packages for each newly created folder in the web directory. However, when I attempt to access them using the dart's package nomenclature eg package:reg/name.dart, the system always generates an error.
I think I am missing something.
I have read http://pub.dartlang.org/doc/package-layout.html but this did not help me either.
You need to ensure that the name you're using as the package matches that in pubspec.yaml.
Eg. if in pubspec.yaml you havename: my_app and your file is at lib\my_library.dart then you need to use import 'package:my_app/my_library.dart';.