Skip to content

fix plugin development using npm link #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demo/app/App_Resources/Android/app.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
android {
defaultConfig {
generatedDensities = []
applicationId = "__PACKAGE__"
applicationId = "org.nativescript.demo"
}
aaptOptions {
additionalParameters "--no-version-vectors"
Expand Down
9 changes: 8 additions & 1 deletion demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@
"id": "org.nativescript.demo",
"tns-ios": {
"version": "3.0.0"
},
"tns-android": {
"version": "3.4.1"
}
},
"dependencies": {
"nativescript-theme-core": "^1.0.4",
"tns-core-modules": "^3.0.0"
},
"devDependencies": {
"nativescript-dev-sass": "file:.."
"babel-traverse": "6.26.0",
"babel-types": "6.26.0",
"babylon": "6.18.0",
"lazy": "1.0.11",
"nativescript-dev-sass": "file:../src"
}
}
47 changes: 47 additions & 0 deletions publish/pack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

SOURCE_DIR=../src;
TO_SOURCE_DIR=src;
PACK_DIR=package;
ROOT_DIR=..;
PUBLISH=--publish

install(){
npm i
}

pack() {

echo 'Clearing /src and /package...'
node_modules/.bin/rimraf "$TO_SOURCE_DIR"
node_modules/.bin/rimraf "$PACK_DIR"

# copy src
echo 'Copying src...'
node_modules/.bin/ncp "$SOURCE_DIR" "$TO_SOURCE_DIR"

# copy README & LICENSE to src
echo 'Copying README and LICENSE to /src...'
node_modules/.bin/ncp "$ROOT_DIR"/LICENSE "$TO_SOURCE_DIR"/LICENSE
node_modules/.bin/ncp "$ROOT_DIR"/README.md "$TO_SOURCE_DIR"/README.md

# compile package and copy files required by npm
echo 'Building /src...'
cd "$TO_SOURCE_DIR"
node_modules/.bin/tsc
cd ..

echo 'Creating package...'
# create package dir
mkdir "$PACK_DIR"

# create the package
cd "$PACK_DIR"
npm pack ../"$TO_SOURCE_DIR"

# delete source directory used to create the package
cd ..
node_modules/.bin/rimraf "$TO_SOURCE_DIR"
}

install && pack
9 changes: 9 additions & 0 deletions publish/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "nativescript-publish",
"version": "1.0.0",
"description": "Publish helper",
"devDependencies": {
"ncp": "^2.0.0",
"rimraf": "^2.5.0"
}
}
11 changes: 11 additions & 0 deletions publish/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

PACK_DIR=package;

publish() {
cd $PACK_DIR
echo 'Publishing to npm...'
npm publish *.tgz
}

./pack.sh && publish
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions lib/converter.js → src/lib/converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ var currentSassProcess = null;
function convert(logger, projectDir, options) {
return new Promise(function (resolve, reject) {
options = options || {};

var peerSassPath = path.join(__dirname, '../../node-sass');
var sassPath = path.join(peerSassPath, 'bin/node-sass');
var sassPath = require.resolve('node-sass/bin/node-sass');
var appDir = path.join(projectDir, "app");
var importerPath = path.join(__dirname, "importer.js");

Expand All @@ -36,7 +34,9 @@ function convert(logger, projectDir, options) {
}

logger.trace(process.execPath, nodeArgs.join(' '));
currentSassProcess = spawn(process.execPath, nodeArgs);
var env = Object.create( process.env );
env.PROJECT_DIR = projectDir;
currentSassProcess = spawn(process.execPath, nodeArgs, { env: env });

var isResolved = false;
var watchResolveTimeout;
Expand Down
4 changes: 2 additions & 2 deletions lib/importer.js → src/lib/importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ var path = require("path");
module.exports = function(url, prev, done) {
if (url[0] === '~' && url[1] !== '/') {
// Resolve "~" paths to node_modules
url = path.resolve(__dirname, "../../../node_modules", url.substr(1));
url = path.resolve(process.env.PROJECT_DIR, "node_modules", url.substr(1));
} else if (url[0] === '~' && url[1] === '/') {
// Resolve "~/" paths to the app root
url = path.resolve(__dirname, "../../../app/"+ url.substr(2));
url = path.resolve(process.env.PROJECT_DIR, "app/"+ url.substr(2));
}

return { file: url };
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.