Skip to content

Commit

Permalink
Moving tns_modules inside app folder - #40.
Browse files Browse the repository at this point in the history
If the tns_modules folder exists at root level a warning will be displayed and the NativeScript modules search path will change to be backwards compatible.
  • Loading branch information
jasssonpet committed Mar 19, 2015
1 parent 0efc1b9 commit e6bd67e
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 55 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Expand Up @@ -4,8 +4,8 @@
[submodule "tests/NativeScriptTests/NativeScriptTests/app/shared"]
path = tests/NativeScriptTests/NativeScriptTests/app/shared
url = git@github.com:NativeScript/common-runtime-tests-app.git
[submodule "tests/NativeScriptTests/NativeScriptTests/tns_modules/shared"]
path = tests/NativeScriptTests/NativeScriptTests/tns_modules/shared
[submodule "tests/NativeScriptTests/NativeScriptTests/app/tns_modules/shared"]
path = tests/NativeScriptTests/NativeScriptTests/app/tns_modules/shared
url = git@github.com:NativeScript/common-runtime-tests-modules.git
[submodule "src/ios-runtime-jsc"]
path = src/jsc
Expand Down
19 changes: 0 additions & 19 deletions build/project-template/__PROJECT_NAME__.xcodeproj/project.pbxproj
Expand Up @@ -13,7 +13,6 @@
858B842D18CA22B800AB12DE /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 858B833A18CA111C00AB12DE /* InfoPlist.strings */; };
858B842F18CA22B800AB12DE /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 858B834318CA111C00AB12DE /* Images.xcassets */; };
CD45EE7C18DC2D5800FB50C0 /* app in Resources */ = {isa = PBXBuildFile; fileRef = CD45EE7A18DC2D5800FB50C0 /* app */; };
CD50DD26192CB5740033AEA3 /* tns_modules in Resources */ = {isa = PBXBuildFile; fileRef = CD50DD24192CB5740033AEA3 /* tns_modules */; };
E0B20F6419A3312900D531CF /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = E0B20F4F19A3312900D531CF /* Default-568h@2x.png */; };
E0B20F6519A3312900D531CF /* Default-Landscape.png in Resources */ = {isa = PBXBuildFile; fileRef = E0B20F5019A3312900D531CF /* Default-Landscape.png */; };
E0B20F6619A3312900D531CF /* Default-Landscape@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = E0B20F5119A3312900D531CF /* Default-Landscape@2x.png */; };
Expand Down Expand Up @@ -66,7 +65,6 @@
858B843318CA22B800AB12DE /* __PROJECT_NAME__.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = __PROJECT_NAME__.app; sourceTree = BUILT_PRODUCTS_DIR; };
C9FC49201A3086DF005E5D6A /* TNSDebugging.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = TNSDebugging.framework; sourceTree = "<group>"; };
CD45EE7A18DC2D5800FB50C0 /* app */ = {isa = PBXFileReference; lastKnownFileType = folder; path = app; sourceTree = "<group>"; };
CD50DD24192CB5740033AEA3 /* tns_modules */ = {isa = PBXFileReference; lastKnownFileType = folder; path = tns_modules; sourceTree = "<group>"; };
E0B20F4F19A3312900D531CF /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "__PROJECT_NAME__/Resources/icons/Default-568h@2x.png"; sourceTree = "<group>"; };
E0B20F5019A3312900D531CF /* Default-Landscape.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-Landscape.png"; path = "__PROJECT_NAME__/Resources/icons/Default-Landscape.png"; sourceTree = "<group>"; };
E0B20F5119A3312900D531CF /* Default-Landscape@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-Landscape@2x.png"; path = "__PROJECT_NAME__/Resources/icons/Default-Landscape@2x.png"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -167,7 +165,6 @@
858B833718CA111C00AB12DE /* __PROJECT_NAME__ */ = {
isa = PBXGroup;
children = (
CD50DD24192CB5740033AEA3 /* tns_modules */,
CD45EE7A18DC2D5800FB50C0 /* app */,
858B834318CA111C00AB12DE /* Images.xcassets */,
858B833818CA111C00AB12DE /* Supporting Files */,
Expand Down Expand Up @@ -195,7 +192,6 @@
buildPhases = (
858B83F218CA22B800AB12DE /* Sources */,
858B83F418CA22B800AB12DE /* Frameworks */,
858B843F18CA32B300AB12DE /* Touch js folder */,
858B842C18CA22B800AB12DE /* Resources */,
85F5BDFC1A9363BE006B9701 /* Embed Frameworks */,
85F5BDF81A93634F006B9701 /* Merge metadata */,
Expand Down Expand Up @@ -241,7 +237,6 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
CD50DD26192CB5740033AEA3 /* tns_modules in Resources */,
CD45EE7C18DC2D5800FB50C0 /* app in Resources */,
858B842D18CA22B800AB12DE /* InfoPlist.strings in Resources */,
858B842F18CA22B800AB12DE /* Images.xcassets in Resources */,
Expand Down Expand Up @@ -272,20 +267,6 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
858B843F18CA32B300AB12DE /* Touch js folder */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Touch js folder";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/bash;
shellScript = "find \"${SRCROOT}/__PROJECT_NAME__/app/\". -exec touch {} \\;\nfind \"${SRCROOT}/__PROJECT_NAME__/tns_modules/\". -exec touch {} \\;";
};
85F5BDF81A93634F006B9701 /* Merge metadata */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down
4 changes: 0 additions & 4 deletions examples/Gameraww/Gameraww.xcodeproj/project.pbxproj
Expand Up @@ -25,7 +25,6 @@
C908F4641A5EC27B005401A3 /* metadata-arm64.bin in Resources */ = {isa = PBXBuildFile; fileRef = C908F4621A5EC27B005401A3 /* metadata-arm64.bin */; };
C908F4661A5EC27B005401A3 /* metadata-armv7.bin in Resources */ = {isa = PBXBuildFile; fileRef = C908F4631A5EC27B005401A3 /* metadata-armv7.bin */; };
C90B552A1A962F0A00167E14 /* libNativeScript.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C90B54F71A9607D800167E14 /* libNativeScript.a */; };
CD6782E519826B7500C9D350 /* tns_modules in Resources */ = {isa = PBXBuildFile; fileRef = CD6782E419826B7500C9D350 /* tns_modules */; };
CDFA780A18DB354B0035D043 /* app in Resources */ = {isa = PBXBuildFile; fileRef = CDFA780918DB354B0035D043 /* app */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -155,7 +154,6 @@
CD45F08D18DC5FE800FB50C0 /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; };
CD45F08E18DC5FE800FB50C0 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
CD45F08F18DC5FE800FB50C0 /* Twitter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Twitter.framework; path = System/Library/Frameworks/Twitter.framework; sourceTree = SDKROOT; };
CD6782E419826B7500C9D350 /* tns_modules */ = {isa = PBXFileReference; lastKnownFileType = folder; path = tns_modules; sourceTree = "<group>"; };
CDFA780918DB354B0035D043 /* app */ = {isa = PBXFileReference; lastKnownFileType = folder; path = app; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -278,7 +276,6 @@
85574E5D18894B28005EC840 /* Gameraww */ = {
isa = PBXGroup;
children = (
CD6782E419826B7500C9D350 /* tns_modules */,
CDFA780918DB354B0035D043 /* app */,
85736C341889F8A1006B1201 /* GAMApplication.storyboard */,
85574E6918894B28005EC840 /* Images.xcassets */,
Expand Down Expand Up @@ -461,7 +458,6 @@
85574E6218894B28005EC840 /* InfoPlist.strings in Resources */,
85736C351889F8A1006B1201 /* GAMApplication.storyboard in Resources */,
C908F4661A5EC27B005401A3 /* metadata-armv7.bin in Resources */,
CD6782E519826B7500C9D350 /* tns_modules in Resources */,
85574E6A18894B28005EC840 /* Images.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
22 changes: 0 additions & 22 deletions examples/TNSApp/TNSApp.xcodeproj/project.pbxproj
Expand Up @@ -20,7 +20,6 @@
F9817F1E1989043C0073E328 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = F9817F1D1989043C0073E328 /* libz.dylib */; };
F9817F20198904600073E328 /* libc++.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = F9817F1F198904600073E328 /* libc++.dylib */; };
F9817F23198906040073E328 /* app in Resources */ = {isa = PBXBuildFile; fileRef = F9817F22198906040073E328 /* app */; };
F9817F2819893F6C0073E328 /* tns_modules in Resources */ = {isa = PBXBuildFile; fileRef = F9817F2719893F6C0073E328 /* tns_modules */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -86,7 +85,6 @@
F9817F1D1989043C0073E328 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
F9817F1F198904600073E328 /* libc++.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = "libc++.dylib"; path = "usr/lib/libc++.dylib"; sourceTree = SDKROOT; };
F9817F22198906040073E328 /* app */ = {isa = PBXFileReference; lastKnownFileType = folder; path = app; sourceTree = "<group>"; };
F9817F2719893F6C0073E328 /* tns_modules */ = {isa = PBXFileReference; lastKnownFileType = folder; path = tns_modules; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -162,7 +160,6 @@
F9817ED31988FBC60073E328 /* TNSApp */ = {
isa = PBXGroup;
children = (
F9817F2719893F6C0073E328 /* tns_modules */,
F9817F22198906040073E328 /* app */,
F9817EE81988FBC60073E328 /* Images.xcassets */,
F9817ED41988FBC60073E328 /* Supporting Files */,
Expand Down Expand Up @@ -190,7 +187,6 @@
buildPhases = (
F9817EC61988FBC60073E328 /* Sources */,
F9817EC71988FBC60073E328 /* Frameworks */,
F9817F24198907A50073E328 /* Update JavaScript */,
F9817EC81988FBC60073E328 /* Resources */,
);
buildRules = (
Expand Down Expand Up @@ -281,31 +277,13 @@
F9817F23198906040073E328 /* app in Resources */,
F9817EE91988FBC60073E328 /* Images.xcassets in Resources */,
C9E0D9141A63D55700A80E1F /* metadata-armv7.bin in Resources */,
F9817F2819893F6C0073E328 /* tns_modules in Resources */,
F9817ED81988FBC60073E328 /* InfoPlist.strings in Resources */,
C9E0D9131A63D55700A80E1F /* metadata-arm64.bin in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
F9817F24198907A50073E328 /* Update JavaScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Update JavaScript";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "find \"${SRCROOT}/TNSApp/app/\". -exec touch {} \\;\nfind \"${SRCROOT}/TNSApp/tns_modules/\". -exec touch {} \\;";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
F9817EC61988FBC60073E328 /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand Down
16 changes: 12 additions & 4 deletions src/NativeScript/NativeScript/require.js
Expand Up @@ -10,15 +10,23 @@
ModuleError.prototype.constructor = ModuleError;
global.ModuleError = ModuleError;

var CORE_MODULES_ROOT = NSString.stringWithString("tns_modules");
var USER_MODULES_ROOT = NSString.stringWithString("app");

var fileManager = NSFileManager.defaultManager();
var nsstr = NSString.stringWithString.bind(NSString);
var isDirectory = new interop.Reference(interop.types.bool, false);

applicationPath = nsstr(applicationPath).stringByStandardizingPath;

var isDirectory = new interop.Reference();
var USER_MODULES_ROOT = nsstr('app');

var CORE_MODULES_ROOT = nsstr('app/tns_modules');
var DEPRECATED_CORE_MODULES_ROOT = nsstr('tns_modules');

var deprecatedCoreModulesPath = NSString.pathWithComponents([applicationPath, DEPRECATED_CORE_MODULES_ROOT]);
if (fileManager.fileExistsAtPathIsDirectory(deprecatedCoreModulesPath, isDirectory) && isDirectory.value) {
console.warn('NativeScript modules search path changed to "' + DEPRECATED_CORE_MODULES_ROOT + '".' +
' Future releases of NativeScript will search for NativeScript modules only in "' + CORE_MODULES_ROOT + '".');
CORE_MODULES_ROOT = DEPRECATED_CORE_MODULES_ROOT;
}

function __findModule(moduleIdentifier, previousPath) {
if (!previousPath) {
Expand Down
Expand Up @@ -32,7 +32,6 @@
CDF4F27B1988D81F000F869E /* app in Resources */ = {isa = PBXBuildFile; fileRef = CDF4F27A1988D81F000F869E /* app */; };
CDF4F290198A3F62000F869E /* TNSTestNativeCallbacks.m in Sources */ = {isa = PBXBuildFile; fileRef = CDF4F28F198A3F62000F869E /* TNSTestNativeCallbacks.m */; };
F953EAD1199A2E7C0023F191 /* Utilities.m in Sources */ = {isa = PBXBuildFile; fileRef = F953EAD0199A2E7C0023F191 /* Utilities.m */; };
F9F4778C1A07B6BF0051BAD9 /* tns_modules in Resources */ = {isa = PBXBuildFile; fileRef = F9F4778B1A07B6BF0051BAD9 /* tns_modules */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -103,7 +102,6 @@
CDF4F28F198A3F62000F869E /* TNSTestNativeCallbacks.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TNSTestNativeCallbacks.m; sourceTree = "<group>"; };
F953EACF199A2E7C0023F191 /* Utilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Utilities.h; sourceTree = "<group>"; };
F953EAD0199A2E7C0023F191 /* Utilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Utilities.m; sourceTree = "<group>"; };
F9F4778B1A07B6BF0051BAD9 /* tns_modules */ = {isa = PBXFileReference; lastKnownFileType = folder; path = tns_modules; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -237,7 +235,6 @@
isa = PBXGroup;
children = (
CDF4F27A1988D81F000F869E /* app */,
F9F4778B1A07B6BF0051BAD9 /* tns_modules */,
CD7BF9821987F632007FA09B /* TestFixtures */,
F953EACF199A2E7C0023F191 /* Utilities.h */,
F953EAD0199A2E7C0023F191 /* Utilities.m */,
Expand Down Expand Up @@ -338,7 +335,6 @@
buildActionMask = 2147483647;
files = (
CDF4F27B1988D81F000F869E /* app in Resources */,
F9F4778C1A07B6BF0051BAD9 /* tns_modules in Resources */,
C9E0D90E1A63D4AD00A80E1F /* metadata-armv7.bin in Resources */,
CDBEF5D31987EE4C00C7E209 /* InfoPlist.strings in Resources */,
CDBEF5DB1987EE4C00C7E209 /* Images.xcassets in Resources */,
Expand Down

0 comments on commit e6bd67e

Please sign in to comment.